26 lines
877 B
Python
26 lines
877 B
Python
|
|
# tools/weather_tool.py
|
||
|
|
from .base_tool import BaseTool
|
||
|
|
|
||
|
|
class WeatherTool(BaseTool):
|
||
|
|
def get_functions(self):
|
||
|
|
return [{
|
||
|
|
"name": "get_weather",
|
||
|
|
"description": "Get the current weather for a location",
|
||
|
|
"parameters": {
|
||
|
|
"type": "object",
|
||
|
|
"properties": {
|
||
|
|
"location": {
|
||
|
|
"type": "string",
|
||
|
|
"description": "The city and state, e.g. San Francisco, CA"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"required": ["location"]
|
||
|
|
}
|
||
|
|
}]
|
||
|
|
|
||
|
|
def execute(self, function_name, **kwargs):
|
||
|
|
if function_name == "get_weather":
|
||
|
|
location = kwargs.get("location")
|
||
|
|
# In a real implementation, you would call a weather API here
|
||
|
|
return f"The weather in {location} is sunny and 72°F"
|