langchain 版本 1.0
create_agent方法中详解:
model: 只要继承BaseChatModel并实现其中一些关键类都可以, 所以对于一些无法使用ChatOpenAI的大模型厂商,就可以使用自定义模型

tools: AIMessage(content='',additional_kwargs={},response_metadata={'finish_reason':'tool_calls','model_name':'qwen-plus','model_provider':'openai'},id='lc_run--3370d481-0ac9-4b4c-a99b-ca96fbe8ad53',tool_calls=[{'name':'save_user_info','args':{'user_info':{'user_id':1,'username':'小红'}},'id':'call_57a51b429d734d69b2fae5','type':'tool_call'}]) 这是大模型调用工具的信息, 工具的自定义参数 是大模型产生的, agent信息在ToolRuntime中,ToolRuntime中的信息 包含messages(对话信息),context(上下文信息),config(运行的配置),stream_writer,tool_call_id(当前调用工具id),store

system_prompt: 系统提示词,信息发送给模型的时候会添加,运行时是看不到的,无论是工具还是中间件,都不会有

middleware:
中间件参数 AgentState , Runtime

中间件执行顺序
①before_agent
②before_model
③after_model
④after_agent

response_format: 响应格式

state_schema: 主要是messages消息列表,可在AgentState中获取

context_schema: 运行时上下文, 自定义信息, 可在Runtime中获取

checkpointer: 用于持久化代理的单线程执行状态(如对话历史、工具调用记录、中间结果等), 要区别多用户,需在使用时设置config

store: 在工具tools中调用,key-value结构在Runtime中获取

Logo

Agent 垂直技术社区,欢迎活跃、内容共建。

更多推荐