@@ -20,19 +20,18 @@ import org.assertj.core.api.Assertions.assertThat
2020import org.junit.jupiter.api.BeforeAll
2121import org.junit.jupiter.api.Test
2222import org.slf4j.LoggerFactory
23-
2423import org.springframework.ai.autoconfigure.ollama.BaseOllamaIT
2524import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration
2625import org.springframework.ai.chat.messages.UserMessage
2726import org.springframework.ai.chat.prompt.Prompt
28- import org.springframework.ai.model.function.FunctionCallback
29- import org.springframework.ai.model.function.FunctionCallingOptions
27+ import org.springframework.ai.model.tool.ToolCallingChatOptions
3028import org.springframework.ai.ollama.OllamaChatModel
31- import org.springframework.ai.ollama.api.OllamaOptions
3229import org.springframework.boot.autoconfigure.AutoConfigurations
3330import org.springframework.boot.test.context.runner.ApplicationContextRunner
3431import org.springframework.context.annotation.Bean
3532import org.springframework.context.annotation.Configuration
33+ import org.springframework.context.annotation.Description
34+
3635
3736class FunctionCallbackKotlinIT : BaseOllamaIT () {
3837
@@ -68,8 +67,10 @@ class FunctionCallbackKotlinIT : BaseOllamaIT() {
6867 val userMessage = UserMessage (
6968 " What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations." )
7069
70+ val functionOptions = ToolCallingChatOptions .builder().toolNames(" weatherInfo" ).build()
71+
7172 val response = chatModel
72- .call(Prompt (listOf (userMessage), OllamaOptions .builder().function( " WeatherInfo " ).build() ))
73+ .call(Prompt (listOf (userMessage), functionOptions ))
7374
7475 logger.info(" Response: $response " )
7576
@@ -87,9 +88,7 @@ class FunctionCallbackKotlinIT : BaseOllamaIT() {
8788 val userMessage = UserMessage (
8889 " What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations." )
8990
90- val functionOptions = FunctionCallingOptions .builder()
91- .function(" WeatherInfo" )
92- .build()
91+ val functionOptions = ToolCallingChatOptions .builder().toolNames(" weatherInfo" ).build()
9392
9493 val response = chatModel.call(Prompt (listOf (userMessage), functionOptions));
9594 val output = response.getResult().output.text
@@ -103,14 +102,9 @@ class FunctionCallbackKotlinIT : BaseOllamaIT() {
103102 open class Config {
104103
105104 @Bean
106- open fun weatherFunctionInfo (): FunctionCallback {
107- return FunctionCallback .builder()
108- .function(" WeatherInfo" , MockKotlinWeatherService ())
109- .description(
110- " Find the weather conditions, forecasts, and temperatures for a location, like a city or state."
111- )
112- .inputType(KotlinRequest ::class .java)
113- .build()
105+ @Description(" Find the weather conditions, forecasts, and temperatures for a location, like a city or state." )
106+ open fun weatherInfo (): Function1 <KotlinRequest , KotlinResponse > {
107+ return MockKotlinWeatherService ()
114108 }
115109
116110 }
0 commit comments