Skip to content

Commit

Permalink
fix sequential calling for azure
Browse files Browse the repository at this point in the history
  • Loading branch information
starkt committed Jul 12, 2024
1 parent fac38c5 commit 764a85f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@ private ChatCompletionsOptions merge(ChatCompletionsOptions fromOptions, ChatCom
if (fromOptions.getResponseFormat() != null) {
mergedOptions.setResponseFormat(fromOptions.getResponseFormat());
}
if (fromOptions.getTools() != null) {
mergedOptions.setTools(fromOptions.getTools());
}

return mergedOptions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,32 @@ void functionCallTest() {
assertThat(response.getResult().getOutput().getContent()).containsAnyOf("15.0", "15");
}


@Test
void functionCallSequentialTest() {

UserMessage userMessage = new UserMessage("What's the weather like in San Francisco? If the weather is above 25 degrees, please check the weather in Tokyo and Paris.");

List<Message> messages = new ArrayList<>(List.of(userMessage));

var promptOptions = AzureOpenAiChatOptions.builder()
.withDeploymentName(selectedModel)
.withFunctionCallbacks(List.of(FunctionCallbackWrapper.builder(new MockWeatherService())
.withName("getCurrentWeather")
.withDescription("Get the current weather in a given location")
.withResponseConverter((response) -> "" + response.temp() + response.unit())
.build()))
.build();

ChatResponse response = chatModel.call(new Prompt(messages, promptOptions));

logger.info("Response: {}", response);

assertThat(response.getResult().getOutput().getContent()).containsAnyOf("30.0", "30");
assertThat(response.getResult().getOutput().getContent()).containsAnyOf("10.0", "10");
assertThat(response.getResult().getOutput().getContent()).containsAnyOf("15.0", "15");
}

@Test
void streamFunctionCallTest() {
UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?");
Expand Down

0 comments on commit 764a85f

Please sign in to comment.