-
-
Notifications
You must be signed in to change notification settings - Fork 587
Add support for Responses API #541
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
Full support to the new Responses API https://platform.openai.com/docs/api-reference/responses
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 started going through this, but it doesn't really follow the pattern at all :/
Some top level comments
- Place the Contract into src/Contracts/Resources
- Drop the Transporter/Payload iterations - you can reuse that logic.
- Move the Response API into src/Resources
- Split the Response/Resource into src/Resources & src/Responses
- Introduce some heavy tests.
Thanks for reviewing the PR, I will go over it again and let you know |
Can you run some of the tooling locally? Without tests and the bar having to be at 100% and some linting errors - this has a bit further to go.
I put them in order of complexity. |
Please find attached test results, sorry I don't have time to fix all errors. Phpstan already gave me a lot of headaches. test:unit.txt |
@iBotPeaches Please check my last commit 412f35c with above commit I tested live all models and all are working. Thank you for your understanding |
@momostafa - thanks for your work so far. I triggered the pipeline so you can see the failures right now. I'll look for some time if you've tapped out to take this further. |
You are welcome and thank you for your time looking into my PR. I am seriously overloaded but since there only 2 fails I will work on it tonight and I will get back to you. |
Hi, Now test:lint pass on my local machine please check momostafa@29436e8 |
Sorry... I will check the other failing |
|
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.
Getting closer! A few things here and there, but the major aspect I see missing is the tests. You produced some fixtures, but nothing to assert any of the work you did - works.
- You'll need a Resource test, ie like Assistants
- You'll need a Response test for all types of responses, ie like Assistants
- Finally, a simple test to assert the mocking/pass-through all works with a more full body Response test - ie w/ Assistants again
src/Testing/Responses/Fixtures/Responses/CreateStreamedResponseFixture.txt
Show resolved
Hide resolved
Yeah getting closer : ) thank you for your patience and detailed inputs on what's needs to be fixed. I will try to resolve it today |
No worries, I'm excited to get this as well. Thanks for continuing to work on it. I know this is a big new endpoint, which I'll probably migrate all my Chat endpoints towards once completed. |
@momostafa , thank you for this great contribution! I am also looking forward to see this merged. Question: Does the documentation in the description reflect the current state of this PR? In your readme file this can be found:
According to the Responses API specification,
Also, it is also not mentioned, what would be the implied role if it is not given in Updating the repository README file as part of this PR would be very helpful. |
I had to modify OpenAI\Testing\Responses\Concerns\Fakeable as $class = str_replace('Responses\\', 'Testing\\Responses\\Fixtures\\', static::class).'Fixture'; was conflicting with newly added Responses folder and added docblock explaining the modification and tested against all files. Updated readme can be found at README-RESPONSES.md Added dedicated ClientFake for Responses tests/Testing/ClientFakeResponses.php
You are most welcome, I am glad to be able to make a small contribution to the community. Sorry for the delay since last update as it was quite a challenge to pass Pest tests as finally I found that fake function at Fakeable trait. I have submitted a review and I hope it will pass this time. Thank you |
@iBotPeaches Hi, Please check last commit caf4413
Please review and I appreciate if you can fix what is left so we can all benefit of using the Response API. Thank you for your understanding and guidance through the process. |
Had a bit more time before bed. Notes:
|
Thank you, for your time fixing what is needed and your inputs certainly a good learning curve for me. The whole streaming thing was very confusing for me as well as the multiple tests, testing folders... was driving me crazy : ))) |
No worries. I very much need this feature too so will get this done. I think you got a bit confused as you hit arrays/objects, which is why the tests weren't working well. Generally anytime you are typing an array/object - that suggests you need to make a class that represents that data structure. I'm basically going down the list and fixing any array/object. Hopefully those examples help explain the changes. |
Thanks for pointing out at such patterns I was totally away from coding for 6+ years and just got back about 7 month ago and I am still catching up with all PHP changes as well as learning about Laravel for the first time. Besides that PHP is totally neglected by AI providers and we don't have the leverage of having a PHP SDK (like Python & TypeScript) that would eliminate a lot of confusion and guess work...! |
This is going to be a large large pr. Making my way through it. I didn't fully understand the scope of the Responses API until I sat down and dove into it. It has support for everything (reasoning, tool call, computer calling, file searching, function call, regular text) on top of custom tools and formats. If I had to summarize remaining work:
With Easter near, will lose a few days of time, but otherwise I'm hoping to get this all done & merged before April is over. |
What:
Adds the new feature Responses API: https://platform.openai.com/docs/api-reference/responses
Fixes: #535
Laravel PR: openai-php/laravel#147