AI创想
标题:
langchain deepseek 实现shellTool
[打印本页]
作者:
捡得灿
时间:
7 小时前
标题:
langchain deepseek 实现shellTool
作者:极客-杀生丸
在langchain使用openai接口,但模型使用国内deepseek,但是要先cq,API-key才能用
代码如下:
import os
import langchain
from langchain.chat_models import ChatOpenAI
from langchain.agents import AgentType, initialize_agent
from langchain.tools import ShellTool
def main():
# 如果没有从环境变量中读取,则可以手动写入
#os.environ["OPENAI_API_KEY"] = "your_openai_api_key"
# 1. 构建 LLM(这里使用 OpenAI 的 ChatGPT)
llm = ChatOpenAI(
model_name="deepseek-chat", # 如 "gpt-3.5-turbo" 或其他
openai_api_base="https://api.deepseek.com",
openai_api_key="xxxxx",
temperature=0.7
)
# 2. 准备 Shell 工具
shell_tool = ShellTool()
# 3. 初始化 Agent
# - 这里我们使用 ZERO_SHOT_REACT_DESCRIPTION 类型的 Agent
# - tools 参数里放入一个列表,包含我们所需的工具
tools = [shell_tool]
agent = initiali
复制代码
原文地址:https://blog.csdn.net/weixin_44772948/article/details/144874115
欢迎光临 AI创想 (https://www.llms-ai.com/)
Powered by Discuz! X3.4