forked from wanxingai/LightAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02.tools_agent.py
More file actions
25 lines (21 loc) · 792 Bytes
/
02.tools_agent.py
File metadata and controls
25 lines (21 loc) · 792 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from LightAgent import LightAgent
# Define Tool
def get_weather(city_name: str) -> str:
"""
Get the current weather for `city_name`
"""
return f"Query result: {city_name} is sunny."
# Define tool information inside the function
get_weather.tool_info = {
"tool_name": "get_weather",
"tool_description": "Get current weather information for the specified city.",
"tool_params": [
{"name": "city_name", "description": "The name of the city to query", "type": "string", "required": True},
]
}
tools = [get_weather]
# Initialize Agent
agent = LightAgent(model="qwen-turbo-2024-11-01", api_key="sk-uXx0H0BalE****999F17778F0", base_url="http://url/v1", tools=tools)
# Run Agent
response = agent.run("Please check the weather in Shanghai.")
print(response)