Skip to content

Commit 774ca42

Browse files
small fixes (#369)
Co-authored-by: Jonas Israel <[email protected]> Co-authored-by: Charles Dubois <[email protected]>
1 parent de7bf3c commit 774ca42

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

docs/guides/ORCHESTRATION_CHAT_COMPLETION.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@ Use a prepared template and execute requests with by passing only the input para
108108

109109
```java
110110
var template = Message.user("Reply with 'Orchestration Service is working!' in {{?language}}");
111-
var templatingConfig = TemplatingModuleConfig.create().template(template);
111+
var templatingConfig =
112+
TemplateConfig.create().withTemplate(List.of(template.createChatMessage()));
112113
var configWithTemplate = config.withTemplateConfig(templatingConfig);
113114

114115
var inputParams = Map.of("language", "German");

sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services/OrchestrationService.java

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import com.sap.ai.sdk.orchestration.model.DocumentGroundingFilter;
2626
import com.sap.ai.sdk.orchestration.model.GroundingFilterSearchConfiguration;
2727
import com.sap.ai.sdk.orchestration.model.LlamaGuard38b;
28-
import com.sap.ai.sdk.orchestration.model.ResponseFormatJsonObject;
2928
import com.sap.ai.sdk.orchestration.model.ResponseFormatText;
3029
import com.sap.ai.sdk.orchestration.model.SearchDocumentKeyValueListPair;
3130
import com.sap.ai.sdk.orchestration.model.SearchSelectOptionEnum;
@@ -112,7 +111,8 @@ public Stream<String> streamChatCompletion(@Nonnull final String topic) {
112111
@Nonnull
113112
public OrchestrationChatResponse template(@Nonnull final String language) {
114113
val template = Message.user("Reply with 'Orchestration Service is working!' in {{?language}}");
115-
val templatingConfig = Template.create().template(List.of(template.createChatMessage()));
114+
val templatingConfig =
115+
TemplateConfig.create().withTemplate(List.of(template.createChatMessage()));
116116
val configWithTemplate = config.withTemplateConfig(templatingConfig);
117117

118118
val inputParams = Map.of("language", language);
@@ -351,8 +351,6 @@ public OrchestrationChatResponse grounding(@Nonnull final String userMessage) {
351351
*/
352352
@Nonnull
353353
public OrchestrationChatResponse responseFormatJsonSchema(@Nonnull final String word) {
354-
val config = new OrchestrationModuleConfig().withLlmConfig(GPT_4O_MINI);
355-
356354
// Example class
357355
class Translation {
358356
@JsonProperty(required = true)
@@ -388,17 +386,12 @@ class Translation {
388386
*/
389387
@Nonnull
390388
public OrchestrationChatResponse responseFormatJsonObject(@Nonnull final String word) {
391-
final var llmWithImageSupportConfig =
392-
new OrchestrationModuleConfig().withLlmConfig(GPT_4O_MINI);
393-
394389
val template = Message.user("What is '%s' in German?".formatted(word));
395390
val templatingConfig =
396-
Template.create()
397-
.template(List.of(template.createChatMessage()))
398-
.responseFormat(
399-
ResponseFormatJsonObject.create()
400-
.type(ResponseFormatJsonObject.TypeEnum.JSON_OBJECT));
401-
val configWithTemplate = llmWithImageSupportConfig.withTemplateConfig(templatingConfig);
391+
TemplateConfig.create()
392+
.withTemplate(List.of(template.createChatMessage()))
393+
.withJsonResponse();
394+
val configWithTemplate = config.withTemplateConfig(templatingConfig);
402395

403396
val prompt =
404397
new OrchestrationPrompt(
@@ -419,15 +412,12 @@ public OrchestrationChatResponse responseFormatJsonObject(@Nonnull final String
419412
*/
420413
@Nonnull
421414
public OrchestrationChatResponse responseFormatText(@Nonnull final String word) {
422-
final var llmWithImageSupportConfig =
423-
new OrchestrationModuleConfig().withLlmConfig(GPT_4O_MINI);
424-
425415
val template = Message.user("Whats '%s' in German?".formatted(word));
426416
val templatingConfig =
427417
Template.create()
428418
.template(List.of(template.createChatMessage()))
429419
.responseFormat(ResponseFormatText.create().type(ResponseFormatText.TypeEnum.TEXT));
430-
val configWithTemplate = llmWithImageSupportConfig.withTemplateConfig(templatingConfig);
420+
val configWithTemplate = config.withTemplateConfig(templatingConfig);
431421

432422
val prompt =
433423
new OrchestrationPrompt(

0 commit comments

Comments
 (0)