Fix FunctionCallbackKotlinIT.kt
- Update to use ToolCallingChatOptions as functionOptions
This commit is contained in:
@@ -20,19 +20,18 @@ 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.autoconfigure.ollama.BaseOllamaIT
|
||||
import org.springframework.ai.autoconfigure.ollama.OllamaAutoConfiguration
|
||||
import org.springframework.ai.chat.messages.UserMessage
|
||||
import org.springframework.ai.chat.prompt.Prompt
|
||||
import org.springframework.ai.model.function.FunctionCallback
|
||||
import org.springframework.ai.model.function.FunctionCallingOptions
|
||||
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
|
||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.context.annotation.Description
|
||||
|
||||
|
||||
class FunctionCallbackKotlinIT : BaseOllamaIT() {
|
||||
|
||||
@@ -68,8 +67,10 @@ class FunctionCallbackKotlinIT : 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 = ToolCallingChatOptions.builder().toolNames("weatherInfo").build()
|
||||
|
||||
val response = chatModel
|
||||
.call(Prompt(listOf(userMessage), OllamaOptions.builder().function("WeatherInfo").build()))
|
||||
.call(Prompt(listOf(userMessage), functionOptions))
|
||||
|
||||
logger.info("Response: $response")
|
||||
|
||||
@@ -87,9 +88,7 @@ class FunctionCallbackKotlinIT : 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")
|
||||
.build()
|
||||
val functionOptions = ToolCallingChatOptions.builder().toolNames("weatherInfo").build()
|
||||
|
||||
val response = chatModel.call(Prompt(listOf(userMessage), functionOptions));
|
||||
val output = response.getResult().output.text
|
||||
@@ -103,14 +102,9 @@ class FunctionCallbackKotlinIT : BaseOllamaIT() {
|
||||
open class Config {
|
||||
|
||||
@Bean
|
||||
open fun weatherFunctionInfo(): FunctionCallback {
|
||||
return FunctionCallback.builder()
|
||||
.function("WeatherInfo", MockKotlinWeatherService())
|
||||
.description(
|
||||
"Find the weather conditions, forecasts, and temperatures for a location, like a city or state."
|
||||
)
|
||||
.inputType(KotlinRequest::class.java)
|
||||
.build()
|
||||
@Description("Find the weather conditions, forecasts, and temperatures for a location, like a city or state.")
|
||||
open fun weatherInfo(): Function1<KotlinRequest, KotlinResponse> {
|
||||
return MockKotlinWeatherService()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user