diff --git a/src/tools/getTime.jl b/src/tools/getTime.jl index 0d6a467..b58a752 100644 --- a/src/tools/getTime.jl +++ b/src/tools/getTime.jl @@ -36,6 +36,25 @@ function validateRequiredArgs(args::Dict{String,Any})::Union{Nothing,String} return nothing end +""" +Execute the getTime tool. + +Returns mock time data for the given timezone or city. +""" +function executeTool(toolCallId::String, args::Dict{String,Any}, signal::Union{Nothing,abortSignal}, onPartialResult::Function)::agentToolResult + tz = get(args, "timezone", nothing) + city = get(args, "city", "") + if tz !== nothing + result = "Current time in $(tz): $(now())" + else + result = "Current time in $(city): $(now())" + end + return agentToolResult( + [textContent(result)], + Dict{Any,Any}(), nothing, false + ) +end + """ Define and return the getTime agentTool. """ @@ -52,19 +71,7 @@ function getTool()::agentTool ), "required" => [] ), - execute = (toolCallId, args, signal, onPartialResult) -> begin - tz = get(args, "timezone", nothing) - city = get(args, "city", "") - if tz !== nothing - result = "Current time in $(tz): $(now())" - else - result = "Current time in $(city): $(now())" - end - return agentToolResult( - [textContent(result)], - Dict{Any,Any}(), nothing, false - ) - end, + execute = executeTool, prepareArguments = nothing, validateRequiredArgs = validateRequiredArgs, parallelToolExecute = false diff --git a/src/tools/getWeather.jl b/src/tools/getWeather.jl index 61a17f5..e98d6a9 100644 --- a/src/tools/getWeather.jl +++ b/src/tools/getWeather.jl @@ -1,3 +1,19 @@ +""" +Execute the getWeather tool. + +Returns mock weather data for the given city and temperature units. +""" +function executeTool(toolCallId::String, args::Dict{String,Any}, signal::Union{Nothing,abortSignal}, onPartialResult::Function)::agentToolResult + city = get(args, "city", "") + units = get(args, "units", "celsius") + temp = units == "fahrenheit" ? "72" : "22" + unit_symbol = units == "celsius" ? "°C" : "°F" + return agentToolResult( + [textContent("Weather in $(city): Sunny, $(temp)$(unit_symbol)")], + Dict{Any,Any}(), nothing, false + ) +end + """ Define and return the getWeather agentTool. """ @@ -14,16 +30,7 @@ function getTool()::agentTool ), "required" => ["city"] ), - execute = (toolCallId, args, signal, onPartialResult) -> begin - city = get(args, "city", "") - units = get(args, "units", "celsius") - temp = units == "fahrenheit" ? "72" : "22" - unit_symbol = units == "celsius" ? "°C" : "°F" - return agentToolResult( - [textContent("Weather in $(city): Sunny, $(temp)$(unit_symbol)")], - Dict{Any,Any}(), nothing, false - ) - end, + execute = executeTool, prepareArguments = nothing, validateRequiredArgs = nothing, parallelToolExecute = false