File tree Expand file tree Collapse file tree 3 files changed +9
-9
lines changed
orchestration/src/main/java/com/sap/ai/sdk/orchestration/spring
sample-code/spring-ai-app/src/main/java/com/sap/ai/sdk/app/controllers Expand file tree Collapse file tree 3 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 2525@ RequiredArgsConstructor
2626public 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
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 2424@ RequestMapping ("/orchestration" )
2525class 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 foo.bar@baz.ai" ,
You can’t perform that action at this time.
0 commit comments