Toolkit.OpenWeatherMap

A collection of prebuilt tools for interacting with the OpenWeatherMap API.

# USAGE:
# Tool list to initialize the client
tools = [geocoding.tool, current_weather.tool]
# Tool handler map is passed to Tools.handle_tool_calls!
tool_handler_map = Dict.from_list([
    (geocoding.name, geocoding.handler),
    (currentWeather.name, currentWeather.handler),
])
client = Client.new { apiKey, model: "tool-capable/model", tools }
#...
messages = Chat.add_user_message(client, newMessage, {})
response = Http.send!(Chat.build_http_request(client, {}))?
with_tool_results = 
     Chat.update_messages(response, messages)?
    |> Tools.handle_tool_calls!(client toolHandlerMap, { max_model_calls: 5 })

geocoding : { name : Str, handler! : Str => Result Str , tool : Tool }

Expose name, handler and tool for geocoding.

This tool will allow the model to get the correct latitude and longitude for a location, for use with the currentWeather tool.

current_weather : { name : Str, handler! : Str => Result Str , tool : Tool }

Expose name, handler and tool for currentWeather

This tool will allow the model to get the current weather for a location.