Spaces:
Runtime error
Runtime error
Reverting try due to unavailability of client.close()
Browse files
app.py
CHANGED
@@ -8,25 +8,25 @@ from smolagents.mcp_client import MCPClient
|
|
8 |
mcp_client = MCPClient(
|
9 |
{"url": "https://abidlabs-mcp-tools.hf.space/gradio_api/mcp/sse"}
|
10 |
)
|
11 |
-
try:
|
12 |
-
|
13 |
|
14 |
-
|
15 |
-
|
16 |
|
17 |
-
|
18 |
-
|
19 |
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
|
31 |
-
finally:
|
32 |
-
|
|
|
8 |
mcp_client = MCPClient(
|
9 |
{"url": "https://abidlabs-mcp-tools.hf.space/gradio_api/mcp/sse"}
|
10 |
)
|
11 |
+
# try:
|
12 |
+
tools = mcp_client.get_tools()
|
13 |
|
14 |
+
model = InferenceClientModel()
|
15 |
+
agent = CodeAgent(tools=[*tools], model=model)
|
16 |
|
17 |
+
def call_agent(message, history):
|
18 |
+
return str(agent.run(message))
|
19 |
|
20 |
|
21 |
+
demo = gr.ChatInterface(
|
22 |
+
fn=lambda message, history: str(agent.run(message)),
|
23 |
+
type="messages",
|
24 |
+
examples=["Prime factorization of 68"],
|
25 |
+
title="Agent with MCP Tools",
|
26 |
+
description="This is a simple agent that uses MCP tools to answer questions.",
|
27 |
+
messages=[],
|
28 |
+
)
|
29 |
|
30 |
+
demo.launch()
|
31 |
+
# finally:
|
32 |
+
# mcp_client.close()
|