Just looking at migrating `Toolset` based class to...
# koog-agentic-framework
j
Just looking at migrating
Toolset
based class to something that work work in KMP code ....🧵
This is what I have right now
Copy code
@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()
        }
    }
}
I think from a previous answer here I should use Class-based tools as described in https://docs.koog.ai/class-based-tools/
Is it correct that I'd need to create 2 separate implementations for the 2 tools in original code?
a
Hi, yes, each tool should be a separate class
👍 1
j
One of the above tools doesn't take any arguments.....have built out following so far but it's complaining that
argsSerializer
isn't provided. What should that be in case like this?
Copy code
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" }
    }
}
looks at least like using
override val argsSerializer = ToolArgs.Empty.serializer()
works