Kotlin examples update (#5)
* Update kotlin-function-callback Leverage Spring AI 1.0.0-M5 new Kotlin reflection capabilities. * Fix rag-with-kotlin Leverage Spring AI 1.0.0-M5 new Kotlin reflection capabilities.
This commit is contained in:
committed by
GitHub
parent
4ddd9135f0
commit
7f8bfbcecb
@@ -12,13 +12,6 @@ import org.springframework.context.annotation.Description
|
||||
@SpringBootApplication
|
||||
class KotlinFunctionCallbackApplication {
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<KotlinFunctionCallbackApplication>(*args)
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
fun init(chatClientBuilder: ChatClient.Builder) = CommandLineRunner {
|
||||
try {
|
||||
@@ -38,6 +31,7 @@ class KotlinFunctionCallbackApplication {
|
||||
|
||||
@Configuration
|
||||
class Config {
|
||||
|
||||
@Bean
|
||||
fun weatherFunctionInfo(currentWeather: (WeatherRequest) -> WeatherResponse): FunctionCallback {
|
||||
return FunctionCallback.builder()
|
||||
@@ -55,3 +49,7 @@ class Config {
|
||||
MockKotlinWeatherService().invoke(request)
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<KotlinFunctionCallbackApplication>(*args)
|
||||
}
|
||||
|
||||
@@ -45,21 +45,17 @@ enum class Unit(val unitName: String) {
|
||||
@JsonInclude(Include.NON_NULL)
|
||||
@JsonClassDescription("Weather API request")
|
||||
data class WeatherRequest(
|
||||
@get:JsonProperty(required = true, value = "location")
|
||||
@get:JsonPropertyDescription("The city and state e.g. San Francisco, CA")
|
||||
val location: String = "",
|
||||
val location: String,
|
||||
|
||||
@get:JsonProperty(required = true, value = "lat")
|
||||
@get:JsonPropertyDescription("The city latitude")
|
||||
val lat: Double = 0.0,
|
||||
val lat: Double,
|
||||
|
||||
@get:JsonProperty(required = true, value = "lon")
|
||||
@get:JsonPropertyDescription("The city longitude")
|
||||
val lon: Double = 0.0,
|
||||
val lon: Double,
|
||||
|
||||
@get:JsonProperty(required = true, value = "unit")
|
||||
@get:JsonPropertyDescription("Temperature unit")
|
||||
val unit: Unit = Unit.C
|
||||
val unit: Unit
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user