Shaukat39 commited on
Commit
ce23fec
·
verified ·
1 Parent(s): dca7345

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +4 -2
agent.py CHANGED
@@ -13,6 +13,7 @@ from langchain_core.messages import SystemMessage, HumanMessage
13
  from langchain_core.tools import tool
14
  from langchain.tools.retriever import create_retriever_tool
15
  from supabase.client import create_client
 
16
  import re
17
  import traceback
18
 
@@ -234,9 +235,10 @@ def build_graph(provider: str = "groq"):
234
  final_output = f"FINAL ANSWER: {match.group(1).strip()}"
235
  else:
236
  print("⚠️ 'FINAL ANSWER:' not found. Raw content will be used as fallback.")
237
- final_output = f"FINAL ANSWER: {raw_output or 'Unable to determine answer'}"
 
238
 
239
- return {"messages": [HumanMessage(content=final_output)]}
240
 
241
  except Exception as e:
242
  print(f"🔥 Exception: {e}")
 
13
  from langchain_core.tools import tool
14
  from langchain.tools.retriever import create_retriever_tool
15
  from supabase.client import create_client
16
+ from langchain_core.messages import AIMessage
17
  import re
18
  import traceback
19
 
 
235
  final_output = f"FINAL ANSWER: {match.group(1).strip()}"
236
  else:
237
  print("⚠️ 'FINAL ANSWER:' not found. Raw content will be used as fallback.")
238
+
239
+ final_output = "FINAL ANSWER: Unable to determine answer" if not raw_output else f"FINAL ANSWER: {raw_output}"
240
 
241
+ return {"messages": [AIMessage(content=final_output)]}
242
 
243
  except Exception as e:
244
  print(f"🔥 Exception: {e}")