File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
orchestration/src/test/java/com/sap/ai/sdk/orchestration/spring
sample-code/spring-app/src/main/java/com/sap/ai/sdk/app/services Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change 88import static com .github .tomakehurst .wiremock .client .WireMock .stubFor ;
99import static com .github .tomakehurst .wiremock .client .WireMock .urlPathEqualTo ;
1010import static com .github .tomakehurst .wiremock .client .WireMock .verify ;
11+ import static com .github .tomakehurst .wiremock .stubbing .Scenario .STARTED ;
1112import static com .sap .ai .sdk .orchestration .OrchestrationAiModel .GPT_35_TURBO_16K ;
1213import static org .assertj .core .api .Assertions .assertThat ;
1314import 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" )
Original file line number Diff line number Diff 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 }
You can’t perform that action at this time.
0 commit comments