Spaces:
Sleeping
Sleeping
Daniel Amendoeira
commited on
Update agent.py
Browse files
agent.py
CHANGED
@@ -116,7 +116,9 @@ class LangGraphAgent:
|
|
116 |
|
117 |
print(f"Running LangGraphAgent with input: {question[:200]}...")
|
118 |
result = gaia_agent.invoke(input_state, {"recursion_limit": 30}) # prevents infinite looping when the LLM keeps calling tools over and over
|
119 |
-
|
|
|
|
|
120 |
|
121 |
try:
|
122 |
return final_response.split("FINAL ANSWER:")[-1].strip() # parse out only what's after "FINAL ANSWER:"
|
|
|
116 |
|
117 |
print(f"Running LangGraphAgent with input: {question[:200]}...")
|
118 |
result = gaia_agent.invoke(input_state, {"recursion_limit": 30}) # prevents infinite looping when the LLM keeps calling tools over and over
|
119 |
+
content_list = result["messages"][-1]["content"] # extract content list from the last message
|
120 |
+
texts = [obj["text"] for obj in content_objs if obj.get("type") == "text"] # pull out all text fragments (required for gpt-4o-mini)
|
121 |
+
final_response = "\n".join(texts).strip()
|
122 |
|
123 |
try:
|
124 |
return final_response.split("FINAL ANSWER:")[-1].strip() # parse out only what's after "FINAL ANSWER:"
|