camel icon indicating copy to clipboard operation
camel copied to clipboard

feat: add openai response api

Open GitHoobar opened this issue 9 months ago • 2 comments

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-number in the PR description (required)
  • [x] I have checked if any dependencies need to be added or updated in pyproject.toml and uv 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!

GitHoobar avatar Mar 12 '25 13:03 GitHoobar

@Wendong-Fan this is done as of now.

GitHoobar avatar Mar 16 '25 11:03 GitHoobar

Hey @AveryYay , I made some changes but didn't push them, I think they do contain what you mentioned here. Thanks.

GitHoobar avatar Mar 18 '25 06:03 GitHoobar

Thanks @GitHoobar! The functionality looks good! However, I think we can directly use the function client.responses.create from the openAI SDK instead of implementing using requests both 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

GitHoobar avatar Mar 21 '25 16:03 GitHoobar

Thanks @GitHoobar! The functionality looks good! However, I think we can directly use the function client.responses.create from the openAI SDK instead of implementing using requests both 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)

MuggleJinx avatar Mar 22 '25 10:03 MuggleJinx

oh yes, I used that earlier but was running into an error, I checked the forum its fixed now. Lemme fix this. Thanks @MuggleJinx

GitHoobar avatar Mar 22 '25 10:03 GitHoobar

@Wendong-Fan gtg?

GitHoobar avatar Mar 24 '25 00:03 GitHoobar