Giter Club home page Giter Club logo

Comments (4)

DC-Sebastian avatar DC-Sebastian commented on June 5, 2024

After looking again at what a response from openai looks like, I realize why it doesn't work

Openai outputs the response with message while Azure with a vector database outputs the response with messages.

OpenAI response example:

  "choices": [{
    "index": 0,
    "message": {
      "role": "assistant",
      "content": "\n\nHello there, how may I assist you today?",
    },
    "logprobs": null,
    "finish_reason": "stop"
  }],

Azure response example:

   "choices": [
        {
            "index": 0,
            "messages": [
                {
                    "role": "tool",
                    "content": "{\"citations\": [{\"content\": \"\\nAzure AI services are cloud-based artificial intelligence (AI) services...\", \"id\": null, \"title\": \"What is Azure AI services\", \"filepath\": null, \"url\": null, \"metadata\": {\"chunking\": \"orignal document size=250. Scores=0.4314117431640625 and 1.72564697265625.Org Highlight count=4.\"}, \"chunk_id\": \"0\"}], \"intent\": \"[\\\"Learn about Azure AI services.\\\"]\"}",
                    "end_turn": false
                },
                {
                    "role": "assistant",
                    "content": " \nAzure AI services are cloud-based artificial intelligence (AI) services that help developers build cognitive intelligence into applications without having direct AI or data science skills or knowledge. [doc1]. Azure Machine Learning is a cloud service for accelerating and managing the machine learning project lifecycle. [doc1].",
                    "end_turn": true
                }
            ]
        }
    ]

Here is another example of what Azure's streaming response looks like:

data:{"id": "", "model": "", "created": 1705234910, "object": "chat.completion.chunk", "choices": [{"index": 0, "messages": [{"delta": {"role": "tool", "content": "matched vector database content"}, "index": 0, "end_turn": false}], "finish_reason": null}]}

data:{"id": "", "model": "", "created": 1705234910, "object": "chat.completion.chunk", "choices": [{"index": 0, "messages": [{"delta": {"role": "assistant"}, "index": 1, "end_turn": false}], "finish_reason": null}]}

data:{"id": "", "model": "", "created": 1705234910, "object": "chat.completion.chunk", "choices": [{"index": 0, "messages": [{"delta": {"content": "text"}, "index": 1, "end_turn": false}], "finish_reason": null}]}

data:{"id": "", "model": "", "created": 1705234910, "object": "chat.completion.chunk", "choices": [{"index": 0, "messages": [{"delta": {"content": "text"}, "index": 1, "end_turn": false}], "finish_reason": null}]}

data:{"id": "", "model": "", "created": 1705234910, "object": "chat.completion.chunk", "choices": [{"index": 0, "messages": [{"delta": {"content": "[DONE]"}, "index": 2, "end_turn": true}], "finish_reason": null}]}

Is it possible to adapt openai-php so that messages can also be processed?

from client.

gehrisandro avatar gehrisandro commented on June 5, 2024

HI @DC-Sebastian

Thanks for the comprehensive explanation.

I am not sure atm if we should fully support Azure as the API seem to diverge more and more.

I will talk about that with @nunomaduro

from client.

DC-Sebastian avatar DC-Sebastian commented on June 5, 2024

Thank you for your answer. Of course, I can understand if you can't support the new functionalities of Azure, supporting two APIs that evolve differently is a lot of extra work.

from client.

jhuhta avatar jhuhta commented on June 5, 2024

Have you decided on the Azure support? Currently, it seems it's impossible to use this library for chat/completions because the response message structure is different. However, this one would be a small thing to address still, but obviously I don't know about the possible next updates.

from client.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.