feat: add openai response api
Description
close #1812
Checklist
Go over all the following points, and put an x in all the boxes that apply.
- [x] I have read the CONTRIBUTION guide (required)
- [x] I have linked this PR to an issue using the Development section on the right sidebar or by adding
Fixes #issue-numberin the PR description (required) - [x] I have checked if any dependencies need to be added or updated in
pyproject.tomlanduv lock - [ ] I have updated the tests accordingly (required for a bug fix or a new feature)
- { ] I have updated the documentation if needed:
- [x] I have added examples if this is a new feature
If you are unsure about any of these, don't hesitate to ask. We are here to help!
@Wendong-Fan this is done as of now.
Hey @AveryYay , I made some changes but didn't push them, I think they do contain what you mentioned here. Thanks.
Thanks @GitHoobar! The functionality looks good! However, I think we can directly use the function
client.responses.createfrom the openAI SDK instead of implementing usingrequestsboth for readability and future extension. I think this would be easier. What do you think?
ahh I am not sure if this is to add the response api or the agent sdk. I also tried agent sdk and ran into a lot of errors earlier. Didn't gave it a try after that. what do you think @Wendong-Fan @MuggleJinx
Thanks @GitHoobar! The functionality looks good! However, I think we can directly use the function
client.responses.createfrom the openAI SDK instead of implementing usingrequestsboth for readability and future extension. I think this would be easier. What do you think?ahh I am not sure if this is to add the response api or the agent sdk. I also tried agent sdk and ran into a lot of errors earlier. Didn't gave it a try after that. what do you think @Wendong-Fan @MuggleJinx
Ah no, nothing to do with the new openAI agent sdk. In the original OpenAI sdk, they provide method to create the new response api. I mean we can directly use this function client.responses.create instead of sending http request by ourselves, I guess this should be easier and better. What do you think?
For example, this is from the official document (https://platform.openai.com/docs/guides/responses-vs-chat-completions?api-mode=responses#page-top):
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-4o",
input=[
{
"role": "user",
"content": "Write a one-sentence bedtime story about a unicorn."
}
]
)
print(response.output_text)
oh yes, I used that earlier but was running into an error, I checked the forum its fixed now. Lemme fix this. Thanks @MuggleJinx
@Wendong-Fan gtg?