Skip to content

Commit ebc21ff

Browse files
WiP 2
1 parent 46f4ba4 commit ebc21ff

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatModel.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
@RequiredArgsConstructor
2626
public class OrchestrationChatModel implements ChatModel {
2727
@Nonnull private final OrchestrationClient client = new OrchestrationClient();
28-
@Nonnull private final OrchestrationModuleConfig config;
2928

3029
@Override
3130
public ChatResponse call(Prompt prompt) {
3231
val orchestrationPrompt = toOrchestrationPrompt(prompt);
33-
val response = client.chatCompletion(orchestrationPrompt, config);
32+
val response = client.chatCompletion(orchestrationPrompt, ((OrchestrationChatOptions) prompt.getOptions()).getConfig());
3433
return OrchestrationChatResponse.fromOrchestrationResponse(response.getOriginalResponse());
3534
}
3635

orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatOptions.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public class OrchestrationChatOptions implements ChatOptions {
2828
@Getter(AccessLevel.PUBLIC)
2929
@Setter(AccessLevel.PUBLIC)
3030
@Nonnull
31-
OrchestrationModuleConfig config = new OrchestrationModuleConfig();
31+
OrchestrationModuleConfig config;
3232

3333
// region satisfy the ChatOptions interface, delegating to the LLM config
3434
@Nullable
@@ -87,8 +87,7 @@ public Double getTopP() {
8787

8888
@Override
8989
public OrchestrationChatOptions copy() {
90-
var copy = new OrchestrationChatOptions();
91-
copy.config = this.config;
90+
var copy = new OrchestrationChatOptions(config);
9291
copy.templateParameters.putAll(this.templateParameters);
9392
return copy;
9493
}

sample-code/spring-ai-app/src/main/java/com/sap/ai/sdk/app/controllers/OrchestrationController.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@
2424
@RequestMapping("/orchestration")
2525
class OrchestrationController {
2626

27-
ChatModel client = new OrchestrationChatModel(new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO));
27+
ChatModel client = new OrchestrationChatModel();
28+
private final OrchestrationModuleConfig config =
29+
new OrchestrationModuleConfig().withLlmConfig(GPT_35_TURBO);
2830

2931
@GetMapping("/completion")
3032
ChatResponse completion() {
31-
var prompt = new Prompt("What is the capital of France?");
33+
var opts = new OrchestrationChatOptions(config);
34+
var prompt = new Prompt("What is the capital of France?", opts);
3235

3336
return client.call(prompt);
3437
}
@@ -59,8 +62,7 @@ ChatResponse masking() {
5962
DpiMasking.anonymization()
6063
.withEntities(DPIEntities.EMAIL, DPIEntities.ADDRESS, DPIEntities.LOCATION);
6164

62-
var opts = new OrchestrationChatOptions();
63-
opts.setConfig(new OrchestrationModuleConfig().withMaskingConfig(masking));
65+
var opts = new OrchestrationChatOptions(config.withMaskingConfig(masking));
6466
var prompt =
6567
new Prompt(
6668
"Please write 'Hello World!' to me via email. My email address is [email protected]",

0 commit comments

Comments
 (0)