当前位置:   article > 正文

Langchain ZERO_SHOT_REACT_DESCRIPTION的使用

Langchain ZERO_SHOT_REACT_DESCRIPTION的使用

ZERO_SHOT_REACT_DESCRIPTION 不能记住历史对话:

import ChatGLM
from langchain_core.output_parsers import StrOutputParser
from langchain_core.prompts import ChatPromptTemplate
from langchain_community.tools.tavily_search import TavilySearchResults
from langchain.tools import Tool 
from langchain_community.tools import DuckDuckGoSearchRun
from langchain_community.tools import WikipediaQueryRun
from langchain_community.utilities import WikipediaAPIWrapper
from langchain_community.tools import ArxivQueryRun
from langchain.memory import ConversationBufferMemory
from langchain.agents import initialize_agent 
from langchain.agents import AgentType 
from langchain.chains import LLMChain 
from langchain.prompts import PromptTemplate
from langchain.chains.conversation.memory import ConversationBufferWindowMemory
from langchain.pydantic_v1 import BaseModel, Field
from langchain.tools import BaseTool, StructuredTool, tool
from langchain.tools import BaseTool
from langchain.agents import load_tools
from math import pi
from typing import Union
from typing import Optional, Type
from langchain.callbacks.manager import (
    AsyncCallbackManagerForToolRun,
    CallbackManagerForToolRun,
)
from langchain.tools import BaseTool
from math import pi
from typing import Union
from typing import Optional
from math import sqrt, cos, sin
from langchain.chains import LLMMathChain
from langchain.agents import Tool
from dotenv import load_dotenv
import os
    
llm = ChatGLM.ChatGLM_LLM()
tools = load_tools(["llm-math"], llm=llm)
agent = initialize_agent(tools , llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)

print(agent.invoke("你是谁"))
print(agent.invoke("openai是什么"))  
print(agent.invoke("我的第一个问题是什么")) 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/65813
推荐阅读
相关标签
  

闽ICP备14008679号