Spaces:
Running
Running
Daniel Amendoeira
commited on
Update agent.py
Browse files
agent.py
CHANGED
@@ -118,8 +118,13 @@ class LangGraphAgent:
|
|
118 |
result = gaia_agent.invoke(input_state, {"recursion_limit": 30}) # prevents infinite looping when the LLM keeps calling tools over and over
|
119 |
|
120 |
content_list = result["messages"][-1].content # extract content list from the last message
|
121 |
-
|
122 |
-
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
try:
|
125 |
return final_response.split("FINAL ANSWER:")[-1].strip() # parse out only what's after "FINAL ANSWER:"
|
|
|
118 |
result = gaia_agent.invoke(input_state, {"recursion_limit": 30}) # prevents infinite looping when the LLM keeps calling tools over and over
|
119 |
|
120 |
content_list = result["messages"][-1].content # extract content list from the last message
|
121 |
+
if isinstance(content, list):
|
122 |
+
# multimodal list: pull only the text parts
|
123 |
+
texts = [obj["text"] for obj in content if isinstance(obj, dict) and obj.get("type") == "text"]
|
124 |
+
final_response = "\n".join(texts).strip()
|
125 |
+
else:
|
126 |
+
# plain string fallback
|
127 |
+
final_response = str(content).strip()
|
128 |
|
129 |
try:
|
130 |
return final_response.split("FINAL ANSWER:")[-1].strip() # parse out only what's after "FINAL ANSWER:"
|