Skip to content

Commit 83491e4

Browse files
Unit test finished
1 parent 2979bb0 commit 83491e4

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring/OrchestrationChatModelTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
99
import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo;
1010
import static com.github.tomakehurst.wiremock.client.WireMock.verify;
11+
import static com.github.tomakehurst.wiremock.stubbing.Scenario.STARTED;
1112
import static com.sap.ai.sdk.orchestration.OrchestrationAiModel.GPT_35_TURBO_16K;
1213
import static org.assertj.core.api.Assertions.assertThat;
1314
import static org.assertj.core.api.Assertions.assertThatThrownBy;
@@ -145,10 +146,18 @@ void testStreamCompletion() throws IOException {
145146
void testToolCalls() throws IOException {
146147
stubFor(
147148
post(urlPathEqualTo("/completion"))
149+
.inScenario("Tool Calls")
150+
.whenScenarioStateIs(STARTED)
148151
.willReturn(
149152
aResponse()
150153
.withBodyFile("toolCallsResponse.json")
151154
.withHeader("Content-Type", "application/json"))
155+
.willSetStateTo("Second Call"));
156+
157+
stubFor(
158+
post(urlPathEqualTo("/completion"))
159+
.inScenario("Tool Calls")
160+
.whenScenarioStateIs("Second Call")
152161
.willReturn(
153162
aResponse()
154163
.withBodyFile("toolCallsResponse2.json")

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@ public class SpringAiOrchestrationService {
3434
*/
3535
@Nonnull
3636
public ChatResponse completion() {
37-
defaultOptions.setFunctionCallbacks(
37+
final OrchestrationChatOptions options = new OrchestrationChatOptions(config);
38+
options.setFunctionCallbacks(
3839
List.of(
3940
FunctionCallback.builder()
4041
.function(
4142
"CurrentWeather", new MockWeatherService()) // (1) function name and instance
4243
.description("Get the weather in location") // (2) function description
4344
.inputType(MockWeatherService.Request.class) // (3) function input type
4445
.build()));
45-
val prompt = new Prompt("What is the weather in Potsdam and in Toulouse?", defaultOptions);
46+
val prompt = new Prompt("What is the weather in Potsdam and in Toulouse?", options);
4647

4748
return client.call(prompt);
4849
}

0 commit comments

Comments
 (0)