<java.version>21</java.version>
<spring-ai.version>1.1.0</spring-ai.version>
<spring-boot.version>3.3.0</spring-boot.version>
<dependency>
<groupId>group.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
<version>${spring-ai.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@GetMapping("function1")
public String function1() {
// Test weatherFunction
UserMessage userMessage = new UserMessage(
"What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations.");
FunctionCallingOptionsBuilder.PortableFunctionCallingOptions functionOptions = FunctionCallingOptions
.builder()
.withFunction("WeatherInfo").build();
ChatResponse response = chatModel.call(new Prompt(userMessage, functionOptions));
return response.getResult().getOutput().getContent();
}
@GetMapping("function")
public String function() {
UserMessage userMessage = new UserMessage("What's the weather like in San Francisco, Tokyo, and Paris?");
String currentWeather = chatClient.prompt()
.function("currentWeather",
"Find the weather conditions, forecasts, and temperatures for a location, like a city or state.",
new MockWeatherService())
.messages(userMessage)
.call()
.content();
return currentWeather;
}
The Ollama Function Calling does not work.
I checked the following information
https://docs.spring.io/spring-ai/reference/api/chat/functions/ollama-chat-functions.html
https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/api/tool/OllamaApiToolFunctionCallIT.java
https://github.com/spring-projects/spring-ai/blob/main/models/spring-ai-ollama/src/test/java/org/springframework/ai/ollama/OllamaChatModelFunctionCallingIT.java
None of them works. I am using the 1.1.0 version. I checked the source code.
There is no Function in OllamaOptions, or in inputRequest.getAdvisorParams(). Can anyone help me please, the code in the document and 1.1.0
<groupId>group.springframework.ai</groupId>
<artifactId>spring-ai-bom</artifactId>
Should I use this