Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from langchain.vectorstores import Chroma
|
|
3 |
from langchain.agents import AgentExecutor, Tool
|
4 |
from langchain.chains import RetrievalQAWithSourcesChain
|
5 |
from langchain.chat_models import ChatOpenAI
|
6 |
-
from langchain.memory import ConversationBufferMemory
|
7 |
from langchain.utilities import WikipediaAPIWrapper
|
8 |
from langchain.agents import initialize_agent, AgentType
|
9 |
|
@@ -55,10 +55,10 @@ tools = [
|
|
55 |
)
|
56 |
]
|
57 |
|
58 |
-
# Create Buffer Memory
|
59 |
-
memory = ConversationBufferMemory(memory_key="chat_history", input_key='input', output_key="output", return_messages=True)
|
60 |
-
|
61 |
-
|
62 |
|
63 |
# Initialize Re-Act agent and create Agent Executor Chain
|
64 |
react = initialize_agent(tools, llm, agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION, verbose=True, max_iterations=3, early_stopping_method='generate', memory=memory)
|
|
|
3 |
from langchain.agents import AgentExecutor, Tool
|
4 |
from langchain.chains import RetrievalQAWithSourcesChain
|
5 |
from langchain.chat_models import ChatOpenAI
|
6 |
+
from langchain.memory import ConversationBufferMemory, ConversationSummaryBufferMemory
|
7 |
from langchain.utilities import WikipediaAPIWrapper
|
8 |
from langchain.agents import initialize_agent, AgentType
|
9 |
|
|
|
55 |
)
|
56 |
]
|
57 |
|
58 |
+
# Create Conversational Buffer Memory
|
59 |
+
#memory = ConversationBufferMemory(memory_key="chat_history", input_key='input', output_key="output", return_messages=True)
|
60 |
+
# Create Conversational Summary Buffer Memory
|
61 |
+
memory = ConversationSummaryBufferMemory(llm=llm, memory_key="chat_history", input_key='input', output_key="output", return_messages=True)
|
62 |
|
63 |
# Initialize Re-Act agent and create Agent Executor Chain
|
64 |
react = initialize_agent(tools, llm, agent=AgentType.CHAT_CONVERSATIONAL_REACT_DESCRIPTION, verbose=True, max_iterations=3, early_stopping_method='generate', memory=memory)
|