simple-openai icon indicating copy to clipboard operation
simple-openai copied to clipboard

Add support for OpenAI responses API

Open the-gigi opened this issue 7 months ago • 6 comments

Adding support to the OpenAI responses API See https://github.com/sashirestela/simple-openai/issues/307

  • Building on the domain classes added by @sashirestela
  • Add additional domain classes
  • Add the services to OpenAI and SimpleOpenAI
  • Add unit tests
  • Add comprehensive demo
  • Update the README (except the image of the Google sheet with the endpoints)

During the work I also added some resources and discovered they miss a newline in the end. I fixed it with a refactoring, which added a newline to many other resource files. I hope it's OK.

the-gigi avatar May 05 '25 06:05 the-gigi

@sashirestela spotless check fail, but it passes on my machine 🤷

image

the-gigi avatar May 05 '25 06:05 the-gigi

@the-gigi, thanks for your PR. There are previous things that you need to do before I could go on a deep revision. Below are my first observations:

  1. Focus on implementing the new functionality, don't add other changes not related to the main topic.
  2. In the failing build you can see the detail of the 9 files with format violations.
  3. You need to sync your branch with the latest changes that I uploaded to the 307-new-responses-api branch one week ago. That was necessary because the domain classes were incomplete.

sashirestela avatar May 06 '25 02:05 sashirestela

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 95.80838% with 7 lines in your changes missing coverage. Please review.

Project coverage is 95.03%. Comparing base (ea72591) to head (0919495).

Files with missing lines Patch % Lines
...ain/java/io/github/sashirestela/openai/OpenAI.java 50.00% 2 Missing :warning:
...ela/openai/domain/response/ResponseToolChoice.java 94.44% 1 Missing and 1 partial :warning:
...a/openai/domain/response/events/ResponseDelta.java 0.00% 1 Missing :warning:
...nai/domain/response/events/ResponseOutputItem.java 0.00% 1 Missing :warning:
...nai/domain/response/events/ResponseOutputText.java 0.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##               main     #322      +/-   ##
============================================
+ Coverage     94.91%   95.03%   +0.11%     
- Complexity      161      181      +20     
============================================
  Files            73       85      +12     
  Lines          1102     1269     +167     
  Branches         48       54       +6     
============================================
+ Hits           1046     1206     +160     
- Misses           36       42       +6     
- Partials         20       21       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov-commenter avatar May 06 '25 03:05 codecov-commenter

@the-gigi, thanks for your PR. There are previous things that you need to do before I could go on a deep revision. Below are my first observations:

  1. Focus on implementing the new functionality, don't add other changes not related to the main topic.

Sounds good. I reverted the newline at the end of file changes.

  1. In the failing build you can see the detail of the 9 files with format violations.

I figured it out. It looks like between forking from a branch, rebasing and squashing commits that spotless skipped checking/applying for the new files. To fix it, I had to temporarily comment out this in pom.xml (don't worry. not committed)

      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>${spotless.version}</version>
        <configuration>
          <!--ratchetFrom>origin/main</ratchetFrom -->  👈 
  1. You need to sync your branch with the latest changes that I uploaded to the 307-new-responses-api branch one week ago. That was necessary because the domain classes were incomplete.

That's too bad. When I took over and started from your original [307-new-responses-api] branch I thought I'll work on it until the PR. I didn't realize you keep working on it too. So, I continued your work on the domain. Your additional changes are mostly incompatible with the current state of the PR (except for the Reasoning class where we are compatible). I added the unrelated change to ChatRequest.java. I'll see how complicated it is to integrate your domain changes, but if it's not trivial I might not have the time in the next couple of months (work + vacation).

the-gigi avatar May 06 '25 14:05 the-gigi

That's too bad. When I took over and started from your original [307-new-responses-api] branch I thought I'll work on it until the PR. I didn't realize you keep working on it too. So, I continued your work on the domain. Your additional changes are mostly incompatible with the current state of the PR (except for the Reasoning class where we are compatible). I added the unrelated change to ChatRequest.java. I'll see how complicated it is to integrate your domain changes, but if it's not trivial I might not have the time in the next couple of months (work + vacation).

Sadly, some domain classes were pending. Moreover, OpenAI is committing domain changes even these days. It seems that the Response API is quite unstable yet. I'm doing a final revision to domain classes today and I'm identifying some changes.

sashirestela avatar May 08 '25 21:05 sashirestela

Another PR is in progress to include the latest domain changes from OpenAI. Thanks anyway @the-gigi

sashirestela avatar May 19 '25 12:05 sashirestela

Another PR is in progress to include the latest domain changes from OpenAI. Thanks anyway @the-gigi

No problem. I'm always happy to help when I can.

the-gigi avatar May 21 '25 04:05 the-gigi