openai
openai copied to clipboard
fix: `/chat` body compatibility
As the OpenAI API ref, the body of /chat/completions
can be:
{
"model": "gpt-4o",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}
In this example, the messages[0].content
is String, not {"type": text, "content": ""}
.
Some third-party API forward provider (such as deepseek
) use this example struct as the only correct struct, without supporting the struct now implemented in this package.
I have made a change as follow: If messages[INDEX].content
only has one child of type text
, then the content will set as a string.
Thanks for your review. :)