Spaces:
Build error
Build error
Commit
·
0f4ce60
1
Parent(s):
5b63bb8
Upload 5 files
Browse files
agent.py
CHANGED
@@ -66,4 +66,7 @@ class Agent:
|
|
66 |
agents.load_tools(["llm-math", "python_repl"], llm=llm) +
|
67 |
common_tools
|
68 |
)
|
69 |
-
agent_chain = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True, memory=memory)
|
|
|
|
|
|
|
|
66 |
agents.load_tools(["llm-math", "python_repl"], llm=llm) +
|
67 |
common_tools
|
68 |
)
|
69 |
+
self.agent_chain = initialize_agent(tools, llm, agent="zero-shot-react-description", verbose=True, memory=memory)
|
70 |
+
|
71 |
+
def run(self, query):
|
72 |
+
return self.agent_chain.run(input=query)
|
app.py
CHANGED
@@ -14,9 +14,9 @@ def agent_run(q, openai_api_key, mapi_api_key):
|
|
14 |
os.environ["MAPI_API_KEY"]=mapi_api_key
|
15 |
agent_chain = agent.Agent(openai_api_key, mapi_api_key)
|
16 |
try:
|
17 |
-
out = agent_chain.run(
|
18 |
-
except:
|
19 |
-
out = "Something went wrong, please try again"
|
20 |
return out
|
21 |
|
22 |
with gr.Blocks(css=css_style) as demo:
|
|
|
14 |
os.environ["MAPI_API_KEY"]=mapi_api_key
|
15 |
agent_chain = agent.Agent(openai_api_key, mapi_api_key)
|
16 |
try:
|
17 |
+
out = agent_chain.run(q)
|
18 |
+
except Exception as err:
|
19 |
+
out = f"Something went wrong, please try again.\nError: {err}"
|
20 |
return out
|
21 |
|
22 |
with gr.Blocks(css=css_style) as demo:
|