Skip to content

Commit a05b598

Browse files
committed
Initial
1 parent 0b6bc03 commit a05b598

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.sap.ai.sdk.app.services;
22

33
import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.GEMINI_1_5_FLASH;
4+
import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.GPT_4O;
45
import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.GPT_4O_MINI;
56
import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.Parameter.TEMPERATURE;
67

@@ -40,6 +41,21 @@
4041
public class OrchestrationService {
4142
private final OrchestrationClient client = new OrchestrationClient();
4243

44+
/**
45+
* Demo operation to serve chatbot responses to payment questions.
46+
*
47+
* @param msg_user The user message.
48+
* @return A response from our chatbot.
49+
*/
50+
public String queryPayments(String msg_user) {
51+
var msg_system = "You are a helpful chat bot to answer questions on company payments.";
52+
53+
var config = new OrchestrationModuleConfig().withLlmConfig(GPT_4O.withParam(TEMPERATURE, 0.5));
54+
var prompt = new OrchestrationPrompt(Message.system(msg_system), Message.user(msg_user));
55+
var result = client.chatCompletion(prompt, config);
56+
return result.getContent();
57+
}
58+
4359
@Getter
4460
private final OrchestrationModuleConfig config =
4561
new OrchestrationModuleConfig().withLlmConfig(GEMINI_1_5_FLASH.withParam(TEMPERATURE, 0.0));

sample-code/spring-app/src/test/java/com/sap/ai/sdk/app/controllers/OrchestrationTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.List;
2121
import java.util.Map;
2222
import java.util.concurrent.atomic.AtomicInteger;
23+
import java.util.function.Function;
2324
import lombok.extern.slf4j.Slf4j;
2425
import org.junit.jupiter.api.BeforeEach;
2526
import org.junit.jupiter.api.Test;
@@ -40,6 +41,9 @@ void testCompletion() {
4041

4142
assertThat(result).isNotNull();
4243
assertThat(result.getContent()).isNotEmpty();
44+
45+
Function<String, String> op = service::queryPayments;
46+
assertThat(op).isNotNull();
4347
}
4448

4549
@Test

0 commit comments

Comments
 (0)