create_react_agent
Creates a graph that works with a chat model that utilizes tool calling
也就是返回一个Graph类型的智能体,作用和上篇的实现一样的目的:让llm可以匹配到tool并执行。
https://blog.csdn.net/weixin_45222582/article/details/143667468
现在用 create_react_agent 实现:llm在用户是萌兰时,调用tool---执行任务A
from langgraph.prebuilt import create_react_agent
from langchain_community.chat_models import ChatTongyi
from loguru import logger
from langgraph.prebuilt import ToolNode, tools_condition
from langchain_core.tools import tool
# 1. 定义tool
@tool('do_task_A')
def do_task_A() -> str:
"""用户是萌兰的时候调用"""
logger.info('好好好好好好好好吃')
# print(query)