-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy path1_function_call.py
More file actions
39 lines (32 loc) · 954 Bytes
/
1_function_call.py
File metadata and controls
39 lines (32 loc) · 954 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 函数调用
import logging
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s",
handlers=[logging.StreamHandler()],
)
from GeneralAgent import Agent
from dotenv import load_dotenv
load_dotenv()
# 函数: 获取天气信息
def get_weather(city: str) -> str:
"""
get weather information
@city: str, city name
@return: str, weather information
"""
# return f"{city} weather: sunny"
weather = "sunny"
print(f"{city} weather: {weather}")
return weather
# agent = Agent('你是一个天气小助手', functions=[get_weather], model='deepseek-chat')
agent = Agent("你是一个天气小助手", functions=[get_weather])
agent.user_input("成都天气怎么样?")
# 输出
# ```python
# city = "成都"
# weather_info = get_weather(city)
# weather_info
# ```
# 成都的天气是晴天。
# 请问还有什么我可以帮忙的吗?