Commit 0d54069
authored
feat: [OpenAI] Integrate Messaging Convenience (#326)
* Full openapi generated code for openai module
* Fix rearrangement of code
* Convenience level separated out
* Reflect deprecation of direct string input on client with unit tests
* E2e for both new and old apis
- controller linked to new openai service only
* Increasing test coverage
* Test coverage for tool
* Fix type
* PR changes
- 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
* Remove docs on OpenAi controller
* Remove docs on OpenAi controller
* tag public api with `@since`
- make jackson mixin package private
* Clean up test code for better separation and reduce repetition
* Adapt tool test for better usecase
* Remove deprecation annotation and java doc tag
* Beta annotation on all new classes and client methods returning/taking unstable classes
* Fix changes for new generated model class location
* Update @SInCE because of latest release
* Convert request and response classes to Value classes
* Fix @with equality check for Boolean
* Move NewOpenAiService to test
- Use Old OpenAiService
- Adapt tests
* utility class introduced for mapping to low level request message
* Remove embedding convenience from PR
* Method renaming
* Charles suggested changes
- Enums over string values in test
- missed getContent assertion
- replicate history test in old api test
- Remove `@Value` from OpenAiChatCompletionDelta
* Method renaming and make OpenAiChatCompletionDelta constructor access package private
* Method renaming, add utility method for jackson and change constructor visibility
- follow createX naming format over toX.
- move openai object mapper construction logic to utility method
- make OpenAiChatCompletionDelta constructor access package private
* Improve one plus list construction
* Make new delta test more readable
- remove docs for overriding methods
* Improve java doc in client and request
* Remove the redundant test for usage in low level
* Minimum integration of messaging convenience
- Add user, assistant and system conv on par with orchestration
- Adapt sample app service class for image input (new api)
- Adapt toDTO to account for OpenAI gen model architecture
* Add tool message class
* Clean up test code for better separation and reduce repetition
* Improve messaging throw behaviour and test coverage
- Throw on unsupported content item
- improve code quality user message to DTO mapper
- Add unit tests for messaging convenience api
* PMD suggestions
* Increase test coverage - tool message test
* `@since` annotation
* Rebase fix and make message class constructors package private
* Fix access for createChatCompletionRequestMessage in tool message
* Renaming new classes in sample code
* PR review suggested changes
- Message constructors are package private and chained
- Remove unnecessary method level `@since` annotation
* PR Suggestions
- improve docs
- fix toolmessage to include toolCallId
- reduce toolmessage to single text
- improve error message
- include test for immutability in messages
* improve javadocs
---------
Co-authored-by: Roshin Rajan Panackal <[email protected]>1 parent 0edd308 commit 0d54069
File tree
12 files changed
+651
-65
lines changed- foundation-models/openai/src
- main/java/com/sap/ai/sdk/foundationmodels/openai
- test/java/com/sap/ai/sdk/foundationmodels/openai
- sample-code/spring-app/src/test/java/com/sap/ai/sdk/app
- controllers
- services
12 files changed
+651
-65
lines changedLines changed: 21 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
4 | 6 | | |
5 | 7 | | |
| 8 | + | |
6 | 9 | | |
| 10 | + | |
| 11 | + | |
7 | 12 | | |
8 | 13 | | |
9 | 14 | | |
| |||
15 | 20 | | |
16 | 21 | | |
17 | 22 | | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | | - | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
24 | | - | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
25 | 42 | | |
26 | 43 | | |
27 | 44 | | |
| |||
30 | 47 | | |
31 | 48 | | |
32 | 49 | | |
| 50 | + | |
33 | 51 | | |
34 | 52 | | |
35 | | - | |
| 53 | + | |
36 | 54 | | |
37 | 55 | | |
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
foundation-models/openai/src/main/java/com/sap/ai/sdk/foundationmodels/openai/OpenAiImageItem.java
Lines changed: 63 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
Lines changed: 52 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
17 | | - | |
| 19 | + | |
18 | 20 | | |
19 | 21 | | |
20 | 22 | | |
21 | | - | |
22 | | - | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
23 | 36 | | |
24 | 37 | | |
25 | 38 | | |
26 | 39 | | |
27 | 40 | | |
28 | | - | |
| 41 | + | |
29 | 42 | | |
30 | 43 | | |
31 | 44 | | |
32 | | - | |
33 | | - | |
| 45 | + | |
| 46 | + | |
34 | 47 | | |
35 | 48 | | |
36 | 49 | | |
37 | 50 | | |
38 | 51 | | |
39 | | - | |
| 52 | + | |
40 | 53 | | |
41 | 54 | | |
42 | 55 | | |
43 | | - | |
44 | | - | |
| 56 | + | |
| 57 | + | |
45 | 58 | | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
46 | 88 | | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
Lines changed: 61 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
3 | 5 | | |
| 6 | + | |
4 | 7 | | |
5 | 8 | | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
6 | 12 | | |
| 13 | + | |
| 14 | + | |
7 | 15 | | |
8 | 16 | | |
| 17 | + | |
9 | 18 | | |
10 | 19 | | |
11 | 20 | | |
| |||
15 | 24 | | |
16 | 25 | | |
17 | 26 | | |
18 | | - | |
| 27 | + | |
| 28 | + | |
19 | 29 | | |
20 | | - | |
| 30 | + | |
21 | 31 | | |
22 | 32 | | |
23 | 33 | | |
24 | | - | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
25 | 60 | | |
26 | 61 | | |
27 | 62 | | |
28 | 63 | | |
29 | 64 | | |
| 65 | + | |
30 | 66 | | |
31 | 67 | | |
32 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
33 | 89 | | |
34 | 90 | | |
35 | | - | |
| 91 | + | |
36 | 92 | | |
37 | 93 | | |
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments