-
-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Undefined array key "message" (Azure with Vector Database) #320
Comments
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. "choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?",
},
"logprobs": null,
"finish_reason": "stop"
}], "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:
Is it possible to adapt openai-php so that messages can also be processed? |
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 |
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. |
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. |
Description
I am trying to use Azure in conjunction with a vector database
According to Microsoft's documentation, the endpoint looks like this:
YOUR_RESOURCE_NAME/openai/deployments/YOUR_DEPLOYMENT_NAME/extensions/chat/completions?api-version=2023-06-01-preview
Example Response from the Azure API:
The factory code for openai-php should look like this
However, I get the error message
Undefined array key "message"
Is the reason for the error message that the message contains a "role": "tool" with the data from the vector database?
If this is the problem, is it possible to add the "role" : "tool" to the library, the rest of the response corresponds to the format of open ai.
Steps To Reproduce
See Description.
OpenAI PHP Client Version
v0.8.1
PHP Version
8.2.1
Notes
No response
The text was updated successfully, but these errors were encountered: