Spaces:
Runtime error
Runtime error
Mohammad Haghir commited on
Commit ·
fac8710
1
Parent(s): 85fdcb7
server
Browse files
app.py
CHANGED
|
@@ -5,24 +5,9 @@ from smolagents import InferenceClientModel, CodeAgent, ToolCollection
|
|
| 5 |
from smolagents.mcp_client import MCPClient
|
| 6 |
|
| 7 |
|
| 8 |
-
try:
|
| 9 |
-
mcp_client = MCPClient(
|
| 10 |
-
## Try this working example on the hub:
|
| 11 |
-
{"url": "https://mhea-mcp-sentiment.hf.space/gradio_api/mcp/sse"}
|
| 12 |
-
)
|
| 13 |
-
tools = mcp_client.get_tools()
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
type="messages",
|
| 21 |
-
examples=["Prime factorization of 68"],
|
| 22 |
-
title="Agent with MCP Tools",
|
| 23 |
-
description="This is a simple agent that uses MCP tools to answer questions.",
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
demo.launch()
|
| 27 |
-
finally:
|
| 28 |
-
mcp_client.disconnect()
|
|
|
|
| 5 |
from smolagents.mcp_client import MCPClient
|
| 6 |
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
with MCPClient(
|
| 10 |
+
## Try this working example on the hub:
|
| 11 |
+
{"url": "https://mhea-mcp-sentiment.hf.space/gradio_api/mcp/sse"}
|
| 12 |
+
) as tools:
|
| 13 |
+
print("\n".join(f"{t.name}: {t.description}" for t in tools))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|