John O'Reilly
09/19/2025, 5:31 PMToolset based class to something that work work in KMP code ....🧵John O'Reilly
09/19/2025, 5:31 PM@LLMDescription("Tools for getting climate emission information")
class ClimateTraceTool(val climateTraceRepository: ClimateTraceRepository) : ToolSet {
@Tool
@LLMDescription("Get the list of countries")
suspend fun getCountries(): List<String> {
val countries = climateTraceRepository.fetchCountries()
return countries.map { "${it.name}, ${it.alpha3}" }
}
@Tool(customName = "getEmissions")
@LLMDescription("Get the emission data for a country for a particular year.")
suspend fun getEmissions(
@LLMDescription("country code") countryCode: String,
@LLMDescription("year") year: String
): List<String> {
return climateTraceRepository.fetchCountryEmissionsInfo(countryCode, year).map {
it.emissions.co2.toString()
}
}
}John O'Reilly
09/19/2025, 5:32 PMJohn O'Reilly
09/19/2025, 5:32 PMAndrey Bragin
09/20/2025, 11:15 AMJohn O'Reilly
09/20/2025, 1:39 PMargsSerializer isn't provided. What should that be in case like this?
class GetCountriesTool(val climateTraceRepository: ClimateTraceRepository) : SimpleTool<ToolArgs.Empty>() {
// Tool descriptor
override val descriptor = ToolDescriptor(
name = "get_countries",
description = "Get the list of countries",
)
override suspend fun doExecute(args: ToolArgs.Empty): String {
val countries = climateTraceRepository.fetchCountries()
return countries.joinToString { "${it.name}, ${it.alpha3}\n" }
}
}John O'Reilly
09/20/2025, 2:40 PMoverride val argsSerializer = ToolArgs.Empty.serializer() works