Spaces:
Runtime error
Runtime error
Commit
·
5747010
1
Parent(s):
38e525d
rewrite agent
Browse files
app.py
CHANGED
@@ -18,7 +18,8 @@ from langchain.utilities import WikipediaAPIWrapper
|
|
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 |
|
@@ -408,7 +409,7 @@ prompt = ZeroShotAgent.create_prompt(
|
|
408 |
|
409 |
input_variables=["input", "chat_history", "agent_scratchpad"]
|
410 |
|
411 |
-
|
412 |
# agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
413 |
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
414 |
verbose = True,
|
@@ -428,6 +429,10 @@ agent = initialize_agent(tools, llm,
|
|
428 |
|
429 |
)
|
430 |
|
|
|
|
|
|
|
|
|
431 |
print(agent.agent.llm_chain.prompt.template)
|
432 |
# print(agent.agent.llm_chain.prompt)
|
433 |
|
|
|
18 |
from langchain.python import PythonREPL
|
19 |
from langchain.chains import LLMMathChain
|
20 |
from langchain.memory import ConversationBufferMemory
|
21 |
+
from langchain.agents import ZeroShotAgent, AgentExecutor
|
22 |
+
from langchain import LLMChain
|
23 |
import azure.cognitiveservices.speech as speechsdk
|
24 |
import requests
|
25 |
|
|
|
409 |
|
410 |
input_variables=["input", "chat_history", "agent_scratchpad"]
|
411 |
|
412 |
+
agent2 = initialize_agent(tools, llm,
|
413 |
# agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
414 |
agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION,
|
415 |
verbose = True,
|
|
|
429 |
|
430 |
)
|
431 |
|
432 |
+
llm_chain = LLMChain(llm=llm, prompt=prompt)
|
433 |
+
agent_core = ZeroShotAgent(llm_chain=llm, tools=tools, verbose=True)
|
434 |
+
agent = AgentExecutor.from_agent_and_tools(agent=agent_core, tools=tools, verbose=True, memory=memory)
|
435 |
+
|
436 |
print(agent.agent.llm_chain.prompt.template)
|
437 |
# print(agent.agent.llm_chain.prompt)
|
438 |
|