hemantgaikwad commited on
Commit
2881c03
·
verified ·
1 Parent(s): 81917a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -13,11 +13,22 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
13
  class BasicAgent:
14
  def __init__(self):
15
  print("BasicAgent initialized.")
 
 
16
  def __call__(self, question: str) -> str:
17
  print(f"Agent received question (first 50 chars): {question[:50]}...")
18
- fixed_answer = "This is a default answer."
19
- print(f"Agent returning fixed answer: {fixed_answer}")
20
- return fixed_answer
 
 
 
 
 
 
 
 
 
21
 
22
  def run_and_submit_all( profile: gr.OAuthProfile | None):
23
  """
 
13
  class BasicAgent:
14
  def __init__(self):
15
  print("BasicAgent initialized.")
16
+ self.graph = build_graph()
17
+
18
  def __call__(self, question: str) -> str:
19
  print(f"Agent received question (first 50 chars): {question[:50]}...")
20
+ # Wrap the question in a HumanMessage from langchain_core
21
+ messages = [HumanMessage(content=question)]
22
+ messages = self.graph.invoke({"messages": messages})
23
+ answer = messages['messages'][-1].content
24
+ return answer[14:]
25
+ # def __init__(self):
26
+ # print("BasicAgent initialized.")
27
+ # def __call__(self, question: str) -> str:
28
+ # print(f"Agent received question (first 50 chars): {question[:50]}...")
29
+ # fixed_answer = "This is a default answer."
30
+ # print(f"Agent returning fixed answer: {fixed_answer}")
31
+ # return fixed_answer
32
 
33
  def run_and_submit_all( profile: gr.OAuthProfile | None):
34
  """