generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 16
feat: Orchestration image support #294
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
77b6637
Call Orchestration with image and multiString via executeRequestFromJ…
Jonas-Isr 026771b
Merge branch 'main' into orchestration-image-support
Jonas-Isr 09816d2
Work in Progress
Jonas-Isr 54a2c19
Align System- nad AssintantMessage with UserMessage
Jonas-Isr 98ba774
Improve exceptions
Jonas-Isr 75afed1
Improve tests
Jonas-Isr 38f3fd4
Prepare draft
Jonas-Isr f8ea4d0
- Restrict Multi- and ImageContent to appropriate classes;
Jonas-Isr cd20ca8
Rename addTextMessages() to addText()
Jonas-Isr a2fe90f
Remove or hide unneeded constructors, use Message.user() etc. instead
Jonas-Isr ec899a4
Add simple e2e tests
Jonas-Isr f173057
Prepare draft
Jonas-Isr c57bd1d
Small change
Jonas-Isr 0524fd7
Refactor newly introduced classes
Jonas-Isr 60e8120
WIP
Jonas-Isr 3754d9c
add test for base64 image
Jonas-Isr 8ab1514
Small cleanups, no more unnecessary Exceptions
Jonas-Isr e99d7b9
Small changes: ImageItem.DetailLevel is not mandatory by spec, refact…
Jonas-Isr 7c05d89
Delete MessageContent.toString()
Jonas-Isr 5a72a33
Bit of clean up
Jonas-Isr 6100502
Add/improve javadocs
Jonas-Isr 85d077f
Add/improve javadocs some more
Jonas-Isr 7113283
Add annotations
Jonas-Isr 60b97b0
Add explicit allArgs constructor to ImageItem
Jonas-Isr fa1add0
Fix codestyle etc.
Jonas-Isr 682794a
Fix order in add methods
Jonas-Isr b671bc7
Improve unit test
Jonas-Isr 3bd521c
Improve e2e test
Jonas-Isr a152c2f
Merge branch 'main' into orchestration-image-support
Jonas-Isr 0f928a8
Small fixes after merge
Jonas-Isr 6ee7290
Add unit test for message construction
Jonas-Isr 57330d4
Fix sample app after merge
Jonas-Isr 65d01c6
Simplify multiMessage unit test
Jonas-Isr 8a0c79d
Formatting
bot-sdk-js 13c0387
Add constructor for multiple strings for UserMessage and MessageContent
Jonas-Isr f95c4d3
Small changes
Jonas-Isr eaf2632
Merge remote-tracking branch 'origin/orchestration-image-support' int…
Jonas-Isr be70506
Add documentation and release notes
Jonas-Isr fb0a89f
Improve documentation
Jonas-Isr 8357b89
Update orchestration/src/main/java/com/sap/ai/sdk/orchestration/Messa…
Jonas-Isr 8d32086
Minor changes
Jonas-Isr dff4fb8
Make `.content()` @Beta
Jonas-Isr b0e6701
change method names from `addXYZ()` to `andXYZ()`
Jonas-Isr 29ceee1
Delete unnecessary @Nonnull from ImageItem constructor
Jonas-Isr d8fd060
Improve tests
Jonas-Isr bcf0d99
Merge branch 'main' into orchestration-image-support
Jonas-Isr 162cb6b
increase coverage
CharlesDuboisSAP adf81da
We hate Jacoco
CharlesDuboisSAP a099ee0
Update docs/release-notes/release_notes.md
Jonas-Isr 4899f36
Simplify logic
Jonas-Isr 837fd66
Small fixes
Jonas-Isr 3dd3085
Reduce and streamline amount of public API
Jonas-Isr d91ca3b
Rename convenience methods to `withXyz()`
Jonas-Isr e438330
Simplify code and adapt jacoco coverage
Jonas-Isr a87fa5d
Small change
Jonas-Isr 27a1033
Add release number to javadocs
Jonas-Isr b505272
Fit jacoco coverage
Jonas-Isr 72f66b5
Merge branch 'main' into orchestration-image-support
Jonas-Isr dc69ad1
Rename MessageContent.contentItemList to MessageContent.items
Jonas-Isr 3d8315e
Update docs
Jonas-Isr cd08312
Merge branch 'main' into orchestration-image-support
Jonas-Isr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
orchestration/src/main/java/com/sap/ai/sdk/orchestration/MessageContent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package com.sap.ai.sdk.orchestration; | ||
|
|
||
| public sealed interface MessageContent permits MessageContentSingle, MessageContentMulti { | ||
|
|
||
| static String toString(MessageContent content) { | ||
Jonas-Isr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (content instanceof MessageContentSingle mCSingle) { | ||
| return mCSingle.content(); | ||
| } else if (content instanceof MessageContentMulti mCMulti) { | ||
| var strBuilder = new StringBuilder(); | ||
| mCMulti | ||
| .multiContentList() | ||
| .forEach( | ||
| multiContent -> { | ||
| if (multiContent instanceof MultiMessageTextContent mMText) { | ||
| strBuilder.append(mMText.text()).append("; "); | ||
| } else if (multiContent instanceof MultiMessageImageContent mMImage) { | ||
| strBuilder.append(mMImage.imageUrl()); | ||
| } else { | ||
| throw new IllegalArgumentException( | ||
| "Unknown subtype of MultiChatMessageContent: " + multiContent.getClass()); | ||
| } | ||
| }); | ||
| return strBuilder.toString(); | ||
| } else { | ||
| throw new IllegalArgumentException( | ||
| "Unknown subtype of MessageContent: " + content.getClass()); | ||
| } | ||
| } | ||
| } | ||
36 changes: 36 additions & 0 deletions
36
orchestration/src/main/java/com/sap/ai/sdk/orchestration/MessageContentMulti.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.sap.ai.sdk.orchestration; | ||
|
|
||
| import static com.sap.ai.sdk.orchestration.MultiMessageImageContent.DetailLevel; | ||
|
|
||
| import com.sap.ai.sdk.orchestration.model.ImageContent; | ||
| import com.sap.ai.sdk.orchestration.model.MultiChatMessageContent; | ||
| import com.sap.ai.sdk.orchestration.model.TextContent; | ||
| import java.util.List; | ||
|
|
||
| public record MessageContentMulti(List<MultiMessageContent> multiContentList) | ||
| implements MessageContent { | ||
| public MessageContentMulti {} | ||
|
|
||
| public MessageContentMulti(MultiChatMessageContent... multiChatContents) { | ||
Jonas-Isr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| this(convertIntoMultiMessageList(multiChatContents)); | ||
| } | ||
|
|
||
| private static List<MultiMessageContent> convertIntoMultiMessageList( | ||
| MultiChatMessageContent... multiChatContents) { | ||
| List<MultiMessageContent> multiContentList = new java.util.ArrayList<>(List.of()); | ||
| for (MultiChatMessageContent multiChatContent : multiChatContents) { | ||
| if (multiChatContent instanceof TextContent textContent) { | ||
| multiContentList.add(new MultiMessageTextContent(textContent.getText())); | ||
| } else if (multiChatContent instanceof ImageContent imageContent) { | ||
| var imageUrl = imageContent.getImageUrl(); | ||
| multiContentList.add( | ||
| new MultiMessageImageContent( | ||
| imageUrl.getUrl(), DetailLevel.fromString(imageUrl.getDetail()))); | ||
| } else { | ||
| throw new IllegalArgumentException( | ||
| "Unknown subtype of MultiChatMessageContent: " + multiChatContent.getClass()); | ||
| } | ||
| } | ||
| return multiContentList; | ||
| } | ||
| } | ||
3 changes: 3 additions & 0 deletions
3
orchestration/src/main/java/com/sap/ai/sdk/orchestration/MessageContentSingle.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package com.sap.ai.sdk.orchestration; | ||
|
|
||
| public record MessageContentSingle(String content) implements MessageContent{} |
6 changes: 6 additions & 0 deletions
6
orchestration/src/main/java/com/sap/ai/sdk/orchestration/MultiMessageContent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package com.sap.ai.sdk.orchestration; | ||
|
|
||
| public sealed interface MultiMessageContent | ||
| permits MultiMessageTextContent, MultiMessageImageContent { | ||
| public String type(); | ||
| } |
24 changes: 24 additions & 0 deletions
24
orchestration/src/main/java/com/sap/ai/sdk/orchestration/MultiMessageImageContent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.sap.ai.sdk.orchestration; | ||
|
|
||
| public record MultiMessageImageContent(String imageUrl, DetailLevel detailLevel) | ||
| implements MultiMessageContent { | ||
| private static final String type = "image_url"; | ||
|
|
||
| public String type() { | ||
| return type; | ||
| } | ||
|
|
||
| public enum DetailLevel { | ||
| low, | ||
| high, | ||
| auto; | ||
|
|
||
| public static DetailLevel fromString(String str) { | ||
| try { | ||
| return DetailLevel.valueOf(str.toLowerCase()); | ||
| } catch (IllegalArgumentException e) { | ||
| return DetailLevel.low; | ||
| } | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
orchestration/src/main/java/com/sap/ai/sdk/orchestration/MultiMessageTextContent.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package com.sap.ai.sdk.orchestration; | ||
|
|
||
| public record MultiMessageTextContent(String text) implements MultiMessageContent { | ||
| private static final String type = "text"; | ||
|
|
||
| public String type() { | ||
| return type; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.