Skip to content

Commit b956afb

Browse files
committed
Merging changes from main
1 parent bea4d49 commit b956afb

34 files changed

+107
-74
lines changed

orchestration/src/main/java/com/sap/ai/sdk/orchestration/ConfigToRequestTransformer.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.sap.ai.sdk.orchestration.client.model.CompletionPostRequest;
44
import com.sap.ai.sdk.orchestration.client.model.ModuleConfigs;
55
import com.sap.ai.sdk.orchestration.client.model.OrchestrationConfig;
6+
import com.sap.ai.sdk.orchestration.client.model.Template;
67
import com.sap.ai.sdk.orchestration.client.model.TemplatingModuleConfig;
78
import io.vavr.control.Option;
89
import java.util.ArrayList;
@@ -25,9 +26,9 @@ static CompletionPostRequest toCompletionPostRequest(
2526
// subsequent requests
2627
val configCopy = config.withTemplateConfig(template);
2728

28-
return CompletionPostRequest.create()
29+
return new CompletionPostRequest()
2930
.orchestrationConfig(
30-
OrchestrationConfig.create().moduleConfigurations(toModuleConfigs(configCopy)))
31+
new OrchestrationConfig().moduleConfigurations(toModuleConfigs(configCopy)))
3132
.inputParams(prompt.getTemplateParameters())
3233
.messagesHistory(prompt.getMessagesHistory());
3334
}
@@ -42,14 +43,14 @@ static TemplatingModuleConfig toTemplateModuleConfig(
4243
* In this case, the request will fail, since the templating module will try to resolve the parameter.
4344
* To be fixed with https://github.tools.sap/AI/llm-orchestration/issues/662
4445
*/
45-
val messages = Option.of(template).map(TemplatingModuleConfig::getTemplate).getOrElse(List::of);
46+
val messages = Option.of(template).map(t -> ((Template) t).getTemplate()).getOrElse(List::of);
4647
val messagesWithPrompt = new ArrayList<>(messages);
4748
messagesWithPrompt.addAll(prompt.getMessages());
4849
if (messagesWithPrompt.isEmpty()) {
4950
throw new IllegalStateException(
5051
"A prompt is required. Pass at least one message or configure a template with messages or a template reference.");
5152
}
52-
return TemplatingModuleConfig.create().template(messagesWithPrompt);
53+
return new Template().template(messagesWithPrompt);
5354
}
5455

5556
@Nonnull
@@ -60,7 +61,7 @@ static ModuleConfigs toModuleConfigs(@Nonnull final OrchestrationModuleConfig co
6061

6162
//noinspection DataFlowIssue the template is always non-null here
6263
val moduleConfig =
63-
ModuleConfigs.create()
64+
new ModuleConfigs()
6465
.llmModuleConfig(llmConfig)
6566
.templatingModuleConfig(config.getTemplateConfig());
6667

orchestration/src/main/java/com/sap/ai/sdk/orchestration/GeneralizedFallbackDeserializer.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,41 @@
66
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
77
import java.io.IOException;
88

9+
/**
10+
* A deserializer that attempts to deserialize a JSON object into one of the subtypes of a base
11+
* type.
12+
*
13+
* <p>This deserializer is useful when the exact subtype of an object is not known in advance, but
14+
* the possible subtypes are known and annotated with {@link JsonSubTypes}.
15+
*
16+
* <p>When deserializing, this deserializer will attempt to deserialize the JSON object into each of
17+
* the possible subtypes in turn. The first successful deserialization will be returned. If none of
18+
* the deserializations are successful, a {@link JsonMappingException} will be thrown.
19+
*
20+
* @param <T> The base type to deserialize into.
21+
*/
922
public class GeneralizedFallbackDeserializer<T> extends StdDeserializer<T> {
1023

1124
private final Class<T> baseType;
1225

26+
/**
27+
* Create a new deserializer for the given base type.
28+
*
29+
* @param baseClass The base type to deserialize into.
30+
*/
1331
public GeneralizedFallbackDeserializer(Class<T> baseClass) {
1432
super(baseClass);
1533
this.baseType = baseClass;
1634
}
1735

36+
/**
37+
* Deserialize the JSON object into one of the subtypes of the base type.
38+
*
39+
* @param p The JSON parser.
40+
* @param ctxt The deserialization context.
41+
* @return The deserialized object.
42+
* @throws IOException If an I/O error occurs.
43+
*/
1844
@Override
1945
public T deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
2046
ObjectMapper mapper = (ObjectMapper) p.getCodec();

orchestration/src/main/java/com/sap/ai/sdk/orchestration/LLMModuleResultDeserializer.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,24 @@
88
import com.sap.ai.sdk.orchestration.client.model.LLMModuleResultSynchronous;
99
import java.io.IOException;
1010

11+
/**
12+
* A deserializer for {@link LLMModuleResult} that determines the concrete implementation based on
13+
* the structure of the JSON object.
14+
*/
1115
public class LLMModuleResultDeserializer extends StdDeserializer<LLMModuleResult> {
1216

1317
public LLMModuleResultDeserializer() {
1418
super(LLMModuleResult.class);
1519
}
1620

21+
/**
22+
* Deserialize the JSON object into one of the subtypes of the base type.
23+
*
24+
* @param p The JSON parser.
25+
* @param ctxt The deserialization context.
26+
* @return The deserialized object.
27+
* @throws IOException If an I/O error occurs.
28+
*/
1729
@Override
1830
public LLMModuleResult deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
1931

orchestration/src/main/java/com/sap/ai/sdk/orchestration/OrchestrationPrompt.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public class OrchestrationPrompt {
3232
* @param message A user message.
3333
*/
3434
public OrchestrationPrompt(@Nonnull final String message) {
35-
messages.add(ChatMessage.create().role("user").content(message));
35+
messages.add(new ChatMessage().role("user").content(message));
3636
}
3737

3838
/**

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/AzureContentSafety.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
})
2727
@javax.annotation.Generated(
2828
value = "org.openapitools.codegen.languages.JavaClientCodegen",
29-
date = "2024-11-08T17:17:51.177015+01:00[Europe/Berlin]",
29+
date = "2024-11-08T18:02:22.585601+01:00[Europe/Berlin]",
3030
comments = "Generator version: 7.9.0")
3131
public class AzureContentSafety {
3232
public static final String JSON_PROPERTY_HATE = "Hate";

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/AzureContentSafetyFilterConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
})
2727
@javax.annotation.Generated(
2828
value = "org.openapitools.codegen.languages.JavaClientCodegen",
29-
date = "2024-11-08T17:17:51.177015+01:00[Europe/Berlin]",
29+
date = "2024-11-08T18:02:22.585601+01:00[Europe/Berlin]",
3030
comments = "Generator version: 7.9.0")
3131
public class AzureContentSafetyFilterConfig implements FilterConfig {
3232
/** String represents name of the filter provider */

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/ChatDelta.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@JsonPropertyOrder({ChatDelta.JSON_PROPERTY_ROLE, ChatDelta.JSON_PROPERTY_CONTENT})
2222
@javax.annotation.Generated(
2323
value = "org.openapitools.codegen.languages.JavaClientCodegen",
24-
date = "2024-11-08T17:17:51.177015+01:00[Europe/Berlin]",
24+
date = "2024-11-08T18:02:22.585601+01:00[Europe/Berlin]",
2525
comments = "Generator version: 7.9.0")
2626
public class ChatDelta {
2727
public static final String JSON_PROPERTY_ROLE = "role";

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/ChatMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
@JsonPropertyOrder({ChatMessage.JSON_PROPERTY_ROLE, ChatMessage.JSON_PROPERTY_CONTENT})
2222
@javax.annotation.Generated(
2323
value = "org.openapitools.codegen.languages.JavaClientCodegen",
24-
date = "2024-11-08T17:17:51.177015+01:00[Europe/Berlin]",
24+
date = "2024-11-08T18:02:22.585601+01:00[Europe/Berlin]",
2525
comments = "Generator version: 7.9.0")
2626
public class ChatMessage {
2727
public static final String JSON_PROPERTY_ROLE = "role";

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/CompletionPostRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
})
3030
@javax.annotation.Generated(
3131
value = "org.openapitools.codegen.languages.JavaClientCodegen",
32-
date = "2024-11-08T17:17:51.177015+01:00[Europe/Berlin]",
32+
date = "2024-11-08T18:02:22.585601+01:00[Europe/Berlin]",
3333
comments = "Generator version: 7.9.0")
3434
public class CompletionPostRequest {
3535
public static final String JSON_PROPERTY_ORCHESTRATION_CONFIG = "orchestration_config";

orchestration/src/main/java/com/sap/ai/sdk/orchestration/client/model/CompletionPostResponse.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
})
2626
@javax.annotation.Generated(
2727
value = "org.openapitools.codegen.languages.JavaClientCodegen",
28-
date = "2024-11-08T17:17:51.177015+01:00[Europe/Berlin]",
28+
date = "2024-11-08T18:02:22.585601+01:00[Europe/Berlin]",
2929
comments = "Generator version: 7.9.0")
3030
public class CompletionPostResponse {
3131
public static final String JSON_PROPERTY_REQUEST_ID = "request_id";

0 commit comments

Comments
 (0)