Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -24,16 +24,16 @@ class BasicAgent:
|
|
| 24 |
print("BasicAgent initialized.")
|
| 25 |
self.graph = build_graph()
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
|
| 38 |
|
| 39 |
|
|
|
|
| 24 |
print("BasicAgent initialized.")
|
| 25 |
self.graph = build_graph()
|
| 26 |
|
| 27 |
+
def __call__(self, question: str) -> str:
|
| 28 |
+
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 29 |
+
try:
|
| 30 |
+
messages = [HumanMessage(content=question)]
|
| 31 |
+
response = self.graph.invoke({"messages": messages})
|
| 32 |
+
final_msg = response['messages'][-1].content
|
| 33 |
+
return final_msg[14:] if len(final_msg) > 14 else final_msg
|
| 34 |
+
except Exception as e:
|
| 35 |
+
print(f"Error during invocation: {e}")
|
| 36 |
+
return "Sorry, I encountered an error while processing your question."
|
| 37 |
|
| 38 |
|
| 39 |
|