-
Notifications
You must be signed in to change notification settings - Fork 15
feat: [OpenAI] Stable convenience - Latest #323
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
Conversation
foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java
Outdated
Show resolved
Hide resolved
foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java
Outdated
Show resolved
Hide resolved
foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java
Show resolved
Hide resolved
foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java
Show resolved
Hide resolved
...-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/NewOpenAiClientTest.java
Outdated
Show resolved
Hide resolved
sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java
Outdated
Show resolved
Hide resolved
sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/controllers/OpenAiController.java
Outdated
Show resolved
Hide resolved
sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/NewOpenAiService.java
Show resolved
Hide resolved
| .tools(null) | ||
| .parallelToolCalls(null); | ||
|
|
||
| return OpenAiClient.forModel(GPT_4O).chatCompletion(request); |
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.
(Comment)
I understand that we're waiting for orchestration multi-modal chat-message PR to be merged. Once available, we can update the openai convenience API. then this code here (based on generated classes) will hopefully not be necessary anymore.
sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/NewOpenAiService.java
Show resolved
Hide resolved
bb53787 to
2b4b12b
Compare
foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java
Show resolved
Hide resolved
...penai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionResponse.java
Show resolved
Hide resolved
sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/NewOpenAiService.java
Outdated
Show resolved
Hide resolved
- controller linked to new openai service only
- Move Jackson object initialization to field declaration - update `streamChatCompletionDeltas` in `NewOpenAiService` to use basic string message - `@deprecated` tag on deprecated `chatCompletion` doc - `@Deprecated` annotation on embedding api in client - `OpenAiController` streamChatCompletionDeltas emits usage
- make jackson mixin package private
b3ead80 to
f33bfad
Compare
...openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionRequest.java
Show resolved
Hide resolved
...penai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionResponse.java
Show resolved
Hide resolved
587c307 to
d4a03e5
Compare
...s/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionDelta.java
Outdated
Show resolved
Hide resolved
...s/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientGeneratedTest.java
Outdated
Show resolved
Hide resolved
...s/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientGeneratedTest.java
Outdated
Show resolved
Hide resolved
...s/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientGeneratedTest.java
Outdated
Show resolved
Hide resolved
...s/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientGeneratedTest.java
Outdated
Show resolved
Hide resolved
...ion-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientTest.java
Show resolved
Hide resolved
...ion-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientTest.java
Show resolved
Hide resolved
...ion-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientTest.java
Show resolved
Hide resolved
...ion-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientTest.java
Outdated
Show resolved
Hide resolved
...ion-models/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientTest.java
Show resolved
Hide resolved
- Enums over string values in test - missed getContent assertion - replicate history test in old api test - Remove `@Value` from OpenAiChatCompletionDelta
…r visibility - follow createX naming format over toX. - move openai object mapper construction logic to utility method - make OpenAiChatCompletionDelta constructor access package private
...openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionRequest.java
Outdated
Show resolved
Hide resolved
| null, | ||
| null, | ||
| null, | ||
| null); |
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.
(Comment)
I was investigating whether @NoArgsConstructor would work. And yes it does, but unfortunately we would then need to (1) make messages a mutable list and (2) write a wither for it manually, which would invoke all-args constructor again. Therefore no code would be saved.
On a second note: In the future, we could add DEFAULT_XYZ here instead of null. They would be default values for the model fields - currently all of them null / undefined anyway. But it could be useful in the future, and for documentation purpose. We may consider this in future PRs, not part of your branch.
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 considered including the default but
- adding default values means the
withXYZwill not be generated for@Value -> finalfields. - also, keeping track of defaults and as it may change for the api
- could load from the generated model object itself - but maybe not so neat
- Say, we set default value for a nullable property -> It would now be part of all serialised json values and does not scale well for every property and message frequency.
I don't believe any of them are dealbreakers but still hesitant.
...s/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientGeneratedTest.java
Outdated
Show resolved
Hide resolved
...s/openai/src/test/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClientGeneratedTest.java
Outdated
Show resolved
Hide resolved
...s/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionDelta.java
Outdated
Show resolved
Hide resolved
...s/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionDelta.java
Outdated
Show resolved
Hide resolved
...openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionRequest.java
Outdated
Show resolved
Hide resolved
...openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiChatCompletionRequest.java
Show resolved
Hide resolved
foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiClient.java
Show resolved
Hide resolved
- remove docs for overriding methods
Context
AI/ai-sdk-java-backlog#172.
PR split out of #305
We would like start using generated model classes for OpenAI module to keep up with spec changes easier.
Previously, thanks to Charles, we had a beautiful convenience API+model classes in place. But, we are migrating away from current convenience API to achieve parity with orchestration module. This equates to breaking changes.
100% convenience parity seems difficult due how both modules should treat ai model parameter configuration.
Model Parameter Configuration
Under
orchestrationscenario, the ai model itself is selected on a per request level. While, infoundation-modelscenario, we have a deployment specific to a model, while parameters alone (eg: temperature) are altered per request.=> parameters scoping under a model, like in
OrchestrationAiModelclass, is not sensible in OpenAI convenience API.Feature scope:
chatCompletionandstreamChatCompletionmethods in client@lombok.Valuetype)toCreateChatCompletionRequestMessage, ie. toDTO equivalent, is non-public and moved to new utility classOpenAiChatCompletionDeltaDefinition of Done
Aligned changes with the JavaScript SDK