Fix Ollam test configuration

- Add missing jackson-module-kotlin for the kotlin tests
  - Fix Function calling options to use ToolCallingChatOptions

Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
This commit is contained in:
Ilayaperumal Gopinathan
2025-03-24 16:57:58 +00:00
committed by Mark Pollack
parent 3fa0f2078d
commit 2f3683cb4a
4 changed files with 16 additions and 11 deletions

View File

@@ -96,6 +96,12 @@
<artifactId>ollama</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.module</groupId>
<artifactId>jackson-module-kotlin</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@@ -114,8 +114,8 @@ public class OllamaChatAutoConfigurationIT extends BaseOllamaIT {
@Test
void chatActivation() {
this.contextRunner.withPropertyValues("spring.ai.ollama.chat.enabled=false").run(context -> {
assertThat(context.getBeansOfType(OllamaChatProperties.class)).isNotEmpty();
this.contextRunner.withPropertyValues("spring.ai.model.chat=none").run(context -> {
assertThat(context.getBeansOfType(OllamaChatProperties.class)).isEmpty();
assertThat(context.getBeansOfType(OllamaChatModel.class)).isEmpty();
});
@@ -124,7 +124,7 @@ public class OllamaChatAutoConfigurationIT extends BaseOllamaIT {
assertThat(context.getBeansOfType(OllamaChatModel.class)).isNotEmpty();
});
this.contextRunner.withPropertyValues("spring.ai.ollama.chat.enabled=true").run(context -> {
this.contextRunner.withPropertyValues("spring.ai.model.chat=ollama").run(context -> {
assertThat(context.getBeansOfType(OllamaChatProperties.class)).isNotEmpty();
assertThat(context.getBeansOfType(OllamaChatModel.class)).isNotEmpty();
});

View File

@@ -84,8 +84,8 @@ public class OllamaEmbeddingAutoConfigurationIT extends BaseOllamaIT {
@Test
void embeddingActivation() {
this.contextRunner.withPropertyValues("spring.ai.ollama.embedding.enabled=false").run(context -> {
assertThat(context.getBeansOfType(OllamaEmbeddingProperties.class)).isNotEmpty();
this.contextRunner.withPropertyValues("spring.ai.model.embedding=none").run(context -> {
assertThat(context.getBeansOfType(OllamaEmbeddingProperties.class)).isEmpty();
assertThat(context.getBeansOfType(OllamaEmbeddingModel.class)).isEmpty();
});

View File

@@ -20,12 +20,11 @@ import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import org.slf4j.LoggerFactory
import org.springframework.ai.model.ollama.autoconfigure.BaseOllamaIT
import org.springframework.ai.model.ollama.autoconfigure.OllamaChatAutoConfiguration
import org.springframework.ai.chat.messages.UserMessage
import org.springframework.ai.chat.prompt.Prompt
import org.springframework.ai.model.function.FunctionCallingOptions
import org.springframework.ai.model.ollama.autoconfigure.BaseOllamaIT
import org.springframework.ai.model.ollama.autoconfigure.OllamaChatAutoConfiguration
import org.springframework.ai.model.tool.ToolCallingChatOptions
import org.springframework.ai.ollama.OllamaChatModel
import org.springframework.ai.ollama.api.OllamaOptions
import org.springframework.boot.autoconfigure.AutoConfigurations
@@ -87,8 +86,8 @@ class FunctionCallbackResolverKotlinIT : BaseOllamaIT() {
val userMessage = UserMessage(
"What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations.")
val functionOptions = FunctionCallingOptions.builder()
.function("weatherInfo")
val functionOptions = ToolCallingChatOptions.builder()
.toolNames("weatherInfo")
.build()
val response = chatModel.call(Prompt(listOf(userMessage), functionOptions));