theakshayrane commited on
Commit
7e52d93
·
verified ·
1 Parent(s): 072c6d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -22,15 +22,16 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
22
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
23
  class BasicAgent:
24
  def __init__(self):
25
- print("Initializing LangChain Agent...")
26
  self.agent = create_langchain_agent()
27
 
28
  def __call__(self, question: str) -> str:
29
  try:
30
- result = self.agent.invoke({"input": question})
31
- if isinstance(result, dict) and "output" in result:
32
- return result["output"]
33
- return result
 
34
  except Exception as e:
35
  return f"Agent error: {e}"
36
 
 
22
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
23
  class BasicAgent:
24
  def __init__(self):
25
+ print("Initializing LangGraph Agent...")
26
  self.agent = create_langchain_agent()
27
 
28
  def __call__(self, question: str) -> str:
29
  try:
30
+ # LangGraph uses a modern message-based format
31
+ result = self.agent.invoke({"messages": [("user", question)]})
32
+
33
+ # The final answer is the content of the very last message in the chain
34
+ return result["messages"][-1].content
35
  except Exception as e:
36
  return f"Agent error: {e}"
37