PradeepBodhi commited on
Commit
9eeedaf
·
verified ·
1 Parent(s): 27a3848

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -18,18 +18,18 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
18
 
19
 
20
  class BasicAgent:
 
21
  def __init__(self):
 
22
  self.graph = build_graph()
23
 
24
  def __call__(self, question: str) -> str:
 
 
25
  messages = [HumanMessage(content=question)]
26
- response = self.graph.invoke({"messages": messages})
27
- print(f"[DEBUG] Raw graph response: {response}")
28
- if not response.get("messages"):
29
- return "ERROR: No response from agent."
30
- final_msg = response["messages"][-1]
31
- print(f"[DEBUG] Final agent message: {final_msg}")
32
- return final_msg.content.strip() if hasattr(final_msg, 'content') else "ERROR: Malformed response."
33
 
34
 
35
  def run_and_submit_all( profile: gr.OAuthProfile | None):
 
18
 
19
 
20
  class BasicAgent:
21
+ """A langgraph agent."""
22
  def __init__(self):
23
+ print("BasicAgent initialized.")
24
  self.graph = build_graph()
25
 
26
  def __call__(self, question: str) -> str:
27
+ print(f"Agent received question (first 50 chars): {question[:50]}...")
28
+ # Wrap the question in a HumanMessage from langchain_core
29
  messages = [HumanMessage(content=question)]
30
+ messages = self.graph.invoke({"messages": messages})
31
+ answer = messages['messages'][-1].content
32
+ return answer[14:]
 
 
 
 
33
 
34
 
35
  def run_and_submit_all( profile: gr.OAuthProfile | None):