赞
踩
参考:https://zhuanlan.zhihu.com/p/643868934?utm_id=0
from langchain.agents.agent_toolkits import create_python_agent from langchain.agents import load_tools, initialize_agent from langchain.agents import AgentType from langchain.tools.python.tool import PythonREPLTool from langchain.python import PythonREPL from langchain.chat_models import ChatOpenAI #创建llm;llm调用本地模型 api_base_url = "http://localhost:10860/v1" api_key= "EMPTY" LLM_MODEL = "/mnt/data/loong/AquilaChat2-7B" llm = ChatOpenAI( streaming=True, verbose=True, # callbacks=[callback], openai_api_key=api_key, openai_api_base=api_base_url, model_name=LLM_MODEL )
#定义工具
tools = load_tools(["llm-math"], llm=llm)
#创建代理; ReAct框架默认
agent= initialize_agent(
tools,
llm,
agent=A
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。