Comments (4)
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:
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.
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.
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.
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)
- [Bug]: Wrong type RetrieveJobResponseError constructor
- [Support]: How to modify to adapt a locally-deployed OpenAI API compatible embedding service?
- [Bug]: GPT-3 Model Being Used Despite Specifying GPT-4 in Client Request HOT 1
- Azure Chat with Custom Data problem HOT 1
- [Bug]: ThreadRunResponse missing step_details information HOT 1
- [Bug]: getErrorCode(): Return value must be of type ?string, int returned HOT 1
- [Bug]: all runs result with failure code: "server_error", message: "Sorry, something went wrong." HOT 1
- 提问我该如何结束发起的http请求呢
- Constant HTTP 500 Server errors HOT 3
- [Enhancement] streaming support for assistant api HOT 7
- [Bug]: Images (Dall-e 3) method not working with Azure HOT 1
- How to set the frequency_penalty? HOT 1
- [Bug]: Warning: Undefined array key "code" in Responses/FineTuning/RetrieveJobResponseError.php on line 42 HOT 2
- [Bug]: local.ERROR: 'json_object' is not of type 'object' - 'response_format' {"exception":"[object] (OpenAI\Exceptions\ErrorException(code: 0): 'json_object' is not of type 'object' - 'response_format' at /app/vendor/openai-php/client/src/Transporters/HttpTransporter.php:131) HOT 7
- [Bug]: JSON format is not supported
- [Improvement]: `dd` is not a PHP function, the first image of readme.md needs to be changed. use `var_dump` or `print_r` HOT 1
- [Bug]: HOT 1
- Fatal error: Cannot declare class OpenAI, because the name is already in use in E:\Xampp_8.2\htdocs\ia\vendor\openai-php\client\src\OpenAI.php on line 8 [Bug]: HOT 2
- [Feature]: Compatibility with assistants v2 HOT 4
- [improvement]: No support for assistant version v2 HOT 27
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from client.