🔹 1. Tool(注册可调用函数)
| 功能 | 将 Python 函数包装成 LLM 可调用的工具 |
| 用途 | 让 LLM 能做 API 请求、数据库查询、计算等 |
示例:
python 复制编辑 from langchain.tools import tool @tool def get_stock_price(symbol: str) -> str: # 示例逻辑 return f"The current price of {symbol} is $120." tools = [get_stock_price]