mchinea commited on
Commit
6063bbe
·
1 Parent(s): bf34bda

update agent class

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -4,6 +4,8 @@ import requests
4
  import inspect
5
  import pandas as pd
6
 
 
 
7
  from agent import build_agent_graph
8
  # (Keep Constants as is)
9
  # --- Constants ---
@@ -17,9 +19,13 @@ class MyAgent:
17
  self.graph = build_agent_graph()
18
  def __call__(self, question: str) -> str:
19
  print(f"Agent received question (first 50 chars): {question[:50]}...")
20
- fixed_answer = "This is a default answer."
21
- print(f"Agent returning fixed answer: {fixed_answer}")
22
- return fixed_answer
 
 
 
 
23
 
24
  def run_and_submit_all( profile: gr.OAuthProfile | None):
25
  """
 
4
  import inspect
5
  import pandas as pd
6
 
7
+ from langchain_core.messages import HumanMessage
8
+
9
  from agent import build_agent_graph
10
  # (Keep Constants as is)
11
  # --- Constants ---
 
19
  self.graph = build_agent_graph()
20
  def __call__(self, question: str) -> str:
21
  print(f"Agent received question (first 50 chars): {question[:50]}...")
22
+ print(f"Agent received question (first 50 chars): {question[:50]}...")
23
+ # Wrap the question in a HumanMessage from langchain_core
24
+ messages = [HumanMessage(content=question)]
25
+ messages = self.graph.invoke({"messages": messages})
26
+ answer = messages['messages'][-1].content
27
+ print(f"Agent returning fixed answer: {answer}")
28
+ return answer
29
 
30
  def run_and_submit_all( profile: gr.OAuthProfile | None):
31
  """