ameglei-external commited on
Commit
038763c
·
verified ·
1 Parent(s): a0ad7df

Replace assistant calling with graph invoke

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -59,10 +59,10 @@ class BasicAgent:
59
  def __call__(self, question: str) -> Tuple[str, TypedDict]:
60
  print(f"Agent received question (first 50 chars): {question[:50]}...")
61
  state = State(question=question, messages=[HumanMessage(content=question)])
62
- fixed_answer = self.assistant(state)["messages"][0].content
63
- print(f"Last message: {self.assistant(state)['messages'][0]}")
64
- print(f"Agent returning fixed answer: {fixed_answer}")
65
- return fixed_answer, state["messages"]
66
 
67
  def assistant(self, state: State):
68
  # System message
 
59
  def __call__(self, question: str) -> Tuple[str, TypedDict]:
60
  print(f"Agent received question (first 50 chars): {question[:50]}...")
61
  state = State(question=question, messages=[HumanMessage(content=question)])
62
+ result = self.compiled_graph.invoke(state)
63
+ final_answer = result["messages"][-1].content
64
+ print(f"Agent returning fixed answer: {final_answer}")
65
+ return final_answer, result["messages"]
66
 
67
  def assistant(self, state: State):
68
  # System message