Skip to content

Commit

Permalink
Improve OllamaWithOpenAiChatModelIT stability
Browse files Browse the repository at this point in the history
  • Loading branch information
tzolov committed Dec 10, 2024
1 parent 16a9d89 commit ebc9168
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ void beanStreamOutputConverterRecords() {
}

@ParameterizedTest(name = "{0} : {displayName} ")
@ValueSource(strings = { "llama3.2:1b" })
@ValueSource(strings = { "llama3.1:latest", "llama3.2:latest" })
void functionCallTest(String modelName) {

UserMessage userMessage = new UserMessage(
Expand All @@ -268,6 +268,10 @@ void functionCallTest(String modelName) {
List<Message> messages = new ArrayList<>(List.of(userMessage));

var promptOptions = OpenAiChatOptions.builder()
.withModel(modelName)
// Note for Ollama you must set the tool choice to explicitly. Unlike OpenAI
// (which defaults to "auto") Ollama defaults to "nono"
.withToolChoice("auto")
.withFunctionCallbacks(List.of(FunctionCallback.builder()
.function("getCurrentWeather", new MockWeatherService())
.description("Get the weather in location")
Expand All @@ -282,15 +286,20 @@ void functionCallTest(String modelName) {
assertThat(response.getResult().getOutput().getText()).contains("30", "10", "15");
}

@Test
void streamFunctionCallTest() {
@ParameterizedTest(name = "{0} : {displayName} ")
@ValueSource(strings = { "llama3.1:latest", "llama3.2:latest" })
void streamFunctionCallTest(String modelName) {

UserMessage userMessage = new UserMessage(
"What's the weather like in San Francisco, Tokyo, and Paris? Return the temperature in Celsius.");

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

var promptOptions = OpenAiChatOptions.builder()
.withModel(modelName)
// Note for Ollama you must set the tool choice to explicitly. Unlike OpenAI
// (which defaults to "auto") Ollama defaults to "nono"
.withToolChoice("auto")
.withFunctionCallbacks(List.of(FunctionCallback.builder()
.function("getCurrentWeather", new MockWeatherService())
.description("Get the weather in location")
Expand Down

0 comments on commit ebc9168

Please sign in to comment.