Spaces:
Sleeping
Sleeping
JCentercreation
commited on
Commit
·
2c98d8b
1
Parent(s):
1b93a9b
Initial commit with app.py and requirements.txt
Browse files- app.py +30 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import os
|
3 |
+
|
4 |
+
from mcp import StdioServerParameters
|
5 |
+
from smolagents import InferenceClientModel, CodeAgent, ToolCollection, MCPClient
|
6 |
+
|
7 |
+
mcp_client = MCPClient(
|
8 |
+
{
|
9 |
+
"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse"
|
10 |
+
}
|
11 |
+
)
|
12 |
+
|
13 |
+
tools = mcp_client.get_tools()
|
14 |
+
|
15 |
+
model = InferenceClientModel(token=os.getenv("HF_TOKEN"))
|
16 |
+
|
17 |
+
agent = CodeAgent(tools=[*tools], model=model)
|
18 |
+
|
19 |
+
demo = gr.ChatInterface(
|
20 |
+
fn= lambda message, history: str(agent.run(message)),
|
21 |
+
type="messages",
|
22 |
+
examples=["Prime factorization of 68"],
|
23 |
+
title="Agent with MCP tool",
|
24 |
+
description="This agent can use the MCP tool to answer questions.",
|
25 |
+
)
|
26 |
+
|
27 |
+
demo.launch()
|
28 |
+
|
29 |
+
finally:
|
30 |
+
mcp_client.disconnect()
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
gradio[mcp]
|
2 |
+
smolagents[mcp]
|