2025.10.30
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
api_key = os.getenv("OPENAI_API_KEY")
|
||||
|
||||
|
||||
from langchain_core.tools import tool
|
||||
|
||||
@tool
|
||||
def get_weather(location):
|
||||
"""模拟获得天气信息"""
|
||||
return f"{location}当前天气:23℃,晴,风力2级"
|
||||
|
||||
@tool
|
||||
def get_user_name(user):
|
||||
"""模拟获得用户名字"""
|
||||
return f'用户名字是:{user}'
|
||||
|
||||
|
||||
# 封装好我们要用的工具
|
||||
tools = [get_weather,get_user_name]
|
||||
print('工具箱已封装完毕!')
|
||||
Reference in New Issue
Block a user