Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,27 +35,25 @@ class BasicAgent:
|
|
| 35 |
search_tool
|
| 36 |
]
|
| 37 |
chat_with_tools = chat.bind_tools(self.tools)
|
| 38 |
-
self.
|
| 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.
|
| 51 |
-
self.
|
| 52 |
-
self.
|
| 53 |
-
self.
|
| 54 |
-
self.
|
| 55 |
-
self.
|
| 56 |
-
self.
|
| 57 |
-
|
| 58 |
-
|
| 59 |
|
| 60 |
|
| 61 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|
|
|
|
| 35 |
search_tool
|
| 36 |
]
|
| 37 |
chat_with_tools = chat.bind_tools(self.tools)
|
| 38 |
+
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.graph.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.graph = StateGraph(AgentState)
|
| 51 |
+
self.graph.add_node("assistant", assistant)
|
| 52 |
+
self.graph.add_node("tools", ToolNode(self.tools))
|
| 53 |
+
self.graph.add_edge(START, "assistant")
|
| 54 |
+
self.graph.add_conditional_edges("assistant", tools_condition)
|
| 55 |
+
self.graph.add_edge("tools", "assistant")
|
| 56 |
+
self.graph.compile()
|
|
|
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
def run_and_submit_all( profile: gr.OAuthProfile | None):
|