mirror of
https://github.com/google/adk-docs.git
synced 2026-09-14 16:16:59 +08:00
27e1303857
* Migrating from Map to typed data classes in FuncTool and LongRunningTool kotlin examples * lint cleanup of kotlin snippets * adding gradle wrapper for kotlin snippets * cleaning up build file for kotlin * fixing ktlint_code_style, added focus on included Gradle Wrapper --------- Co-authored-by: Kristopher Overholt <koverholt@google.com>
26 lines
777 B
Kotlin
26 lines
777 B
Kotlin
package com.google.adk.kt.examples.tools
|
|
|
|
import com.google.adk.kt.annotations.Param
|
|
import com.google.adk.kt.annotations.Tool
|
|
|
|
// --8<-- [start:optional_params]
|
|
class FlightService {
|
|
/**
|
|
* Searches for flights.
|
|
*/
|
|
@Tool
|
|
fun searchFlights(
|
|
@Param("The destination city.") destination: String,
|
|
@Param("The desired departure date.") departureDate: String,
|
|
@Param("Number of flexible days for the search. Defaults to 0.") flexibleDays: Int? = 0,
|
|
): String {
|
|
// ... function logic ...
|
|
val days = flexibleDays ?: 0
|
|
if (days > 0) {
|
|
return "Found flexible flights to $destination."
|
|
}
|
|
return "Found flights to $destination on $departureDate."
|
|
}
|
|
}
|
|
// --8<-- [end:optional_params]
|