-
Notifications
You must be signed in to change notification settings - Fork 16
feat: [Orchestration] Spring AI integration #278
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
Changes from 29 commits
46f4ba4
ebc21ff
ed7c6e4
3cc0dd0
c5a43a0
d496c13
002f677
ccbcd64
605a51d
7155ad5
d45a397
8c751be
e7e5a9d
ab63181
529b37e
d064734
2d20234
15f4347
afa6f9f
bc0f64a
efe05e1
2133fc4
6cdd6a7
6c5a512
0fd5e10
5088e7d
6ade28f
da7d72e
be64b9e
5ffb8ec
5f6a163
ad2b83b
b94276d
6f549d9
46c84ca
6e49163
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,9 +15,9 @@ | |
| import lombok.NoArgsConstructor; | ||
| import lombok.val; | ||
|
|
||
| /** Factory to create all data objects from an orchestration configuration. */ | ||
| /** Internal factory to create all data objects from an orchestration configuration. */ | ||
| @NoArgsConstructor(access = AccessLevel.NONE) | ||
| final class ConfigToRequestTransformer { | ||
| public final class ConfigToRequestTransformer { | ||
CharlesDuboisSAP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Nonnull | ||
| static CompletionPostRequest toCompletionPostRequest( | ||
| @Nonnull final OrchestrationPrompt prompt, @Nonnull final OrchestrationModuleConfig config) { | ||
|
|
@@ -59,8 +59,9 @@ static TemplatingModuleConfig toTemplateModuleConfig( | |
| return Template.create().template(messagesWithPrompt); | ||
| } | ||
|
|
||
| /** Internal method to convert the convenience configuration to the data objec configuration. */ | ||
| @Nonnull | ||
| static ModuleConfigs toModuleConfigs(@Nonnull final OrchestrationModuleConfig config) { | ||
| public static ModuleConfigs toModuleConfigs(@Nonnull final OrchestrationModuleConfig config) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Major) (I expect static code checks to flag warnings for) incomplete JavaDoc on public API.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can see that we only need this for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But the config inside of |
||
| val llmConfig = | ||
| Option.of(config.getLlmConfig()) | ||
| .getOrElseThrow(() -> new IllegalStateException("LLM config is required.")); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package com.sap.ai.sdk.orchestration; | ||
|
|
||
| import static com.sap.ai.sdk.core.JacksonConfiguration.getDefaultObjectMapper; | ||
|
|
||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.module.SimpleModule; | ||
| import com.google.common.annotations.Beta; | ||
| import com.sap.ai.sdk.orchestration.model.ChatMessagesInner; | ||
| import com.sap.ai.sdk.orchestration.model.LLMModuleResult; | ||
| import com.sap.ai.sdk.orchestration.model.ModuleResultsOutputUnmaskingInner; | ||
| import javax.annotation.Nonnull; | ||
| import lombok.AccessLevel; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.val; | ||
|
|
||
| /** Internal utility class for getting a default object mapper with preset configuration. */ | ||
| @NoArgsConstructor(access = AccessLevel.NONE) | ||
| public class OrchestrationJacksonConfiguration { | ||
CharlesDuboisSAP marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Default object mapper used for JSON de-/serialization. <b>Only intended for internal usage | ||
| * within this SDK</b>. Largely follows the defaults set by Spring. | ||
| * | ||
| * @return A new object mapper with the default configuration. | ||
| * @see <a | ||
| * href="https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.html">Jackson2ObjectMapperBuilder</a> | ||
| */ | ||
| @Nonnull | ||
| @Beta | ||
| public static ObjectMapper getOrchestrationObjectMapper() { | ||
|
|
||
| val jackson = getDefaultObjectMapper(); | ||
|
|
||
| // Add mix-ins | ||
| jackson.addMixIn(LLMModuleResult.class, JacksonMixins.LLMModuleResultMixIn.class); | ||
| jackson.addMixIn( | ||
| ModuleResultsOutputUnmaskingInner.class, | ||
| JacksonMixins.ModuleResultsOutputUnmaskingInnerMixIn.class); | ||
|
|
||
| final var module = | ||
| new SimpleModule() | ||
| .addDeserializer( | ||
| ChatMessagesInner.class, | ||
| PolymorphicFallbackDeserializer.fromJsonSubTypes(ChatMessagesInner.class)) | ||
| .setMixInAnnotation(ChatMessagesInner.class, JacksonMixins.NoneTypeInfoMixin.class); | ||
| jackson.registerModule(module); | ||
| return jackson; | ||
| } | ||
| } | ||
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)
Why the drive-by changes 😅
Uh oh!
There was an error while loading. Please reload this page.
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.
this ## adds underlines which makes it more readable because the file is super long, it also aligns with the other files.
underline