"""天气查询工具""" from langchain_core.tools import tool @tool def get_weather(city: str) -> str: """查询指定城市的天气信息""" weather_data = { "北京": "晴天,气温22°C,北风3级", "上海": "多云,气温25°C,东风2级", "深圳": "阵雨,气温28°C,南风4级", "黄庄": "晴转多云,气温23°C,微风", } return weather_data.get(city, f"暂无{city}的天气数据") # 暴露工具列表供自动扫描 TOOLS = [get_weather]