-
-
Notifications
You must be signed in to change notification settings - Fork 136
[Platform] Migrate OpenAI to Responses API #871
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
base: main
Are you sure you want to change the base?
Conversation
|
lol, please hold. Forgot to add a whole bunch of tests. Feel free to review functionality in the meantime |
47ae95d to
57f7762
Compare
57f7762 to
546019d
Compare
546019d to
9af9306
Compare
70d3673 to
8166232
Compare
chr-hertel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
I extracted the |
8166232 to
95ea744
Compare
Since we're migrating to the Responses API (from chat completions), and
that API doesn't support audio yet. It should be added back when it does
("coming soon", apparently)
See: https://platform.openai.com/docs/guides/migrate-to-responses
As every OpenAI model with vision capabilities also support PDF input, as per docs: https://platform.openai.com/docs/guides/pdf-files?api-mode=responses
In order to migrate from chat completions to Responses, which enforces different data structures
Since we're migration from chat completions to Responses, which has a differnt data structure for function calls
To migrate from OpenAI's chat completions to Responses, we need to change incoming messages to the updated data structure
Chat completions is deprecated. Responses is the recommended API to use now. See: https://platform.openai.com/docs/guides/migrate-to-responses
95ea744 to
44c019d
Compare
| if (isset($event['delta'])) { | ||
| yield $event['delta']; | ||
| } | ||
| if (!str_contains('completed', $event['type'] ?? '')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (!str_contains('completed', $event['type'] ?? '')) { | |
| if (!str_contains($event['type'] ?? '', 'completed')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, thanks for that. Tests should've probably caught this one...
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Bridge\OpenAi\Contract\Gpt\Message\Content; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| namespace Bridge\OpenAi\Contract\Gpt\Message\Content; | |
| namespace Symfony\AI\Platform\Tests\Bridge\OpenAi\Contract\Gpt\Message\Content; |
| * file that was distributed with this source code. | ||
| */ | ||
|
|
||
| namespace Bridge\OpenAi\Contract\Gpt\Message\Content; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| namespace Bridge\OpenAi\Contract\Gpt\Message\Content; | |
| namespace Symfony\AI\Platform\Tests\Bridge\OpenAi\Contract\Gpt\Message\Content; |
| /** | ||
| * @phpstan-import-type JsonSchema from Factory | ||
| * | ||
| * @author Christopher Hertel <[email protected]> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just curious, why do these have Chris' name while others have yours?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I duplicated the files and changed the classes lmao.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use yours 😊


This PR migrates OpenAI from chat completions (deprecated) to the Responses API. I tried to keep the scope small and just support everything already in place as seamlessly as possible. The Responses API does offer some more functionality that we should look into supporting (e.g. MCP tool calling, expanded reasoning functionality), but I found that OOS for this migration.
One thing to note it that the Responses API as of now lacks Audio capabilities ("coming soon", according to the docs), so that example is temporarily disabled and so is the
Gptaudio capability for now.Note: my PRs are best reviewed commit by commit