Antoine101 commited on
Commit
c568a3c
·
verified ·
1 Parent(s): c96996b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -27,6 +27,7 @@ def assistant(state: AgentState):
27
  }
28
 
29
  class BasicAgent:
 
30
  def __init__(self, llm_checkpoint):
31
  llm = HuggingFaceEndpoint(repo_id=llm_checkpoint)
32
  chat = ChatHuggingFace(llm=llm, verbose=True)
@@ -35,14 +36,15 @@ class BasicAgent:
35
  ]
36
  chat_with_tools = chat.bind_tools(self.tools)
37
  self.graph = self._build_graph()
 
38
  print("BasicAgent initialized.")
39
  def __call__(self, question: str) -> str:
40
  print(f"Agent received question (first 50 chars): {question[:50]}...")
41
  messages = [HumanMessage(content="Tell me about our guest named 'Lady Ada Lovelace'.")]
42
  response = self.invoke({"messages": messages})
43
- response['messages'][-1].content
44
- fixed_answer = "This is a default answer."
45
  print(f"Agent returning answer: {response}")
 
46
 
47
  def _build_graph(self):
48
  self.builder = StateGraph(AgentState)
@@ -53,8 +55,9 @@ class BasicAgent:
53
  self.builder.add_edge("tools", "assistant")
54
  self.builder.compile()
55
 
56
- return fixed_answer
57
 
 
58
  def run_and_submit_all( profile: gr.OAuthProfile | None):
59
  """
60
  Fetches all questions, runs the BasicAgent on them, submits all answers,
 
27
  }
28
 
29
  class BasicAgent:
30
+
31
  def __init__(self, llm_checkpoint):
32
  llm = HuggingFaceEndpoint(repo_id=llm_checkpoint)
33
  chat = ChatHuggingFace(llm=llm, verbose=True)
 
36
  ]
37
  chat_with_tools = chat.bind_tools(self.tools)
38
  self.graph = self._build_graph()
39
+
40
  print("BasicAgent initialized.")
41
  def __call__(self, question: str) -> str:
42
  print(f"Agent received question (first 50 chars): {question[:50]}...")
43
  messages = [HumanMessage(content="Tell me about our guest named 'Lady Ada Lovelace'.")]
44
  response = self.invoke({"messages": messages})
45
+ response = response['messages'][-1].content
 
46
  print(f"Agent returning answer: {response}")
47
+ return response
48
 
49
  def _build_graph(self):
50
  self.builder = StateGraph(AgentState)
 
55
  self.builder.add_edge("tools", "assistant")
56
  self.builder.compile()
57
 
58
+
59
 
60
+
61
  def run_and_submit_all( profile: gr.OAuthProfile | None):
62
  """
63
  Fetches all questions, runs the BasicAgent on them, submits all answers,