Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -17,19 +17,15 @@ class BasicAgent:
|
|
17 |
# graph factory lives here
|
18 |
self.agent = build_graph()
|
19 |
|
20 |
-
def __call__(self,
|
21 |
print(f"Agent received question: {question[:50]}...")
|
22 |
-
#
|
23 |
-
|
24 |
-
#
|
25 |
-
#
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
answer = getattr(final_msg, "content", str(final_msg))
|
30 |
-
# strip off any "FINAL ANSWER:" prefix if present
|
31 |
-
return answer.replace("FINAL ANSWER:","",1).strip()
|
32 |
-
|
33 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
34 |
"""
|
35 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|
|
|
17 |
# graph factory lives here
|
18 |
self.agent = build_graph()
|
19 |
|
20 |
+
def __call__(self,question: str) -> str:
|
21 |
print(f"Agent received question: {question[:50]}...")
|
22 |
+
#invoke the ccompiled graph runner with just the question
|
23 |
+
result = self.agent.invoke(question)
|
24 |
+
# because the graph now ends in answer_node, result is a dict {id:answer}
|
25 |
+
# extract that single answer string:
|
26 |
+
answer = list(result.values())[0]
|
27 |
+
return answer.strip()
|
28 |
+
|
|
|
|
|
|
|
|
|
29 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
30 |
"""
|
31 |
Fetches all questions, runs the BasicAgent on them, submits all answers,
|