openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.7k stars 483 forks source link

Fix function call responses from Azure throwing errors #184

Closed karlerss-teamdash closed 1 year ago

karlerss-teamdash commented 1 year ago

The responses from Azure for gpt-35-turbo-16k don't seem to have the content attribute (with OpenAI it's set to null).

This PR fixes the ErrorException: Undefined array key "content" error.

ukkok commented 1 year ago

Just faced same issue and fixed with exactly same solution. Can confirm that this works.

From Azure documentation, content should not be returned by default:

In some cases, the model may generate both content and a function_call.

https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/function-calling#using-function-in-the-chat-completions-api

gehrisandro commented 1 year ago

@karlerss-teamdash Many thanks for the PR!