deter3 commited on
Commit
610fc84
1 Parent(s): de07cea

Update chat_agent.py

Browse files
Files changed (1) hide show
  1. chat_agent.py +4 -3
chat_agent.py CHANGED
@@ -1,5 +1,5 @@
1
  from langchain.agents import Tool
2
- from langchain.memory import ConversationBufferMemory
3
  from langchain.chat_models import ChatOpenAI
4
  from langchain.agents import initialize_agent
5
  from llama_index import GPTSimpleVectorIndex
@@ -37,7 +37,7 @@ def create_chatbot(model_name, seed_memory=None):
37
  Tool(
38
  name="GPT Index",
39
  func=lambda q: str(index.query(q,vector_store_query_mode=query_mode)),
40
- description="useful for when you want to answer questions about Martin Seligman and psychonogy. The input to this tool should be a complete english sentence.",
41
  return_direct=True
42
  ),
43
  ]
@@ -46,7 +46,8 @@ def create_chatbot(model_name, seed_memory=None):
46
  # SystemMessage(content="You are Martin Seligman. You use a tone that is warm and kind.")
47
  # ]
48
  #memory = ConversationBufferMemory(memory_key="chat_history")
49
- memory = seed_memory if seed_memory is not None else ConversationBufferMemory(memory_key="chat_history")
 
50
  chat = ChatOpenAI(temperature=0, model_name=model_name)
51
  agent_chain = initialize_agent(tools, chat, agent="conversational-react-description", verbose=True, memory=memory)
52
 
 
1
  from langchain.agents import Tool
2
+ from langchain.memory import ConversationBufferMemory ,ConversationBufferWindowMemory
3
  from langchain.chat_models import ChatOpenAI
4
  from langchain.agents import initialize_agent
5
  from llama_index import GPTSimpleVectorIndex
 
37
  Tool(
38
  name="GPT Index",
39
  func=lambda q: str(index.query(q,vector_store_query_mode=query_mode)),
40
+ description="useful for when you want to answer questions about Martin Seligman and positive psychonogy related. The input to this tool should be a complete english sentence.",
41
  return_direct=True
42
  ),
43
  ]
 
46
  # SystemMessage(content="You are Martin Seligman. You use a tone that is warm and kind.")
47
  # ]
48
  #memory = ConversationBufferMemory(memory_key="chat_history")
49
+ memory = seed_memory if seed_memory is not None else ConversationBufferWindowMemory( k=4 ,memory_key="chat_history")
50
+ #memory = seed_memory if seed_memory is not None else ConversationBufferMemory(memory_key="chat_history")
51
  chat = ChatOpenAI(temperature=0, model_name=model_name)
52
  agent_chain = initialize_agent(tools, chat, agent="conversational-react-description", verbose=True, memory=memory)
53