OuroborosM commited on
Commit
fc18035
·
1 Parent(s): 5eb43d6

upgrade memory func

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -18,6 +18,7 @@ from langchain.utilities import WikipediaAPIWrapper
18
  from langchain.python import PythonREPL
19
  from langchain.chains import LLMMathChain
20
  from langchain.memory import ConversationBufferMemory
 
21
  import azure.cognitiveservices.speech as speechsdk
22
  import requests
23
 
@@ -386,9 +387,19 @@ Final Answer: the final answer to the original input question"""
386
 
387
  SUFFIX = """Begin!
388
 
 
389
  Question: {input}
390
  Thought:{agent_scratchpad}"""
391
 
 
 
 
 
 
 
 
 
 
392
  agent = initialize_agent(tools, llm,
393
  # agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
394
  agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
@@ -396,12 +407,12 @@ agent = initialize_agent(tools, llm,
396
  handle_parsing_errors = True,
397
  max_iterations = int(os.getenv("max_iterations")),
398
  early_stopping_method="generate",
399
- agent_kwargs={
400
- 'prefix': PREFIX,
401
- 'format_instructions': FORMAT_INSTRUCTIONS,
402
- 'suffix': SUFFIX
403
- },
404
- memory = memory,
405
  )
406
 
407
  print(agent.agent.llm_chain.prompt.template)
 
18
  from langchain.python import PythonREPL
19
  from langchain.chains import LLMMathChain
20
  from langchain.memory import ConversationBufferMemory
21
+ from langchain.agents import ZeroShotAgent
22
  import azure.cognitiveservices.speech as speechsdk
23
  import requests
24
 
 
387
 
388
  SUFFIX = """Begin!
389
 
390
+ {chat_history}
391
  Question: {input}
392
  Thought:{agent_scratchpad}"""
393
 
394
+ prompt = ZeroShotAgent.create_prompt(
395
+ tools,
396
+ prefix=PREFIX,
397
+ suffix=SUFFIX,
398
+ format_instructions=FORMAT_INSTRUCTIONS,
399
+ input_variables=["input", "chat_history", "agent_scratchpad"]
400
+ )
401
+
402
+
403
  agent = initialize_agent(tools, llm,
404
  # agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
405
  agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
 
407
  handle_parsing_errors = True,
408
  max_iterations = int(os.getenv("max_iterations")),
409
  early_stopping_method="generate",
410
+ # agent_kwargs={
411
+ # 'prefix': PREFIX,
412
+ # 'format_instructions': FORMAT_INSTRUCTIONS,
413
+ # 'suffix': SUFFIX
414
+ # },
415
+ prompt = prompt,
416
  )
417
 
418
  print(agent.agent.llm_chain.prompt.template)