George Sergia commited on
Commit
fd8c973
·
1 Parent(s): 9e44185

Initial commit

Browse files
Files changed (3) hide show
  1. .gitignore +2 -0
  2. app.py +38 -0
  3. requirements.txt +2 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ # Created by venv; see https://docs.python.org/3/library/venv.html
2
+ .env
app.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from smolagents.mcp_client import MCPClient
2
+ import gradio as gr
3
+ import os
4
+
5
+
6
+ with MCPClient(
7
+ {f"url" : "https://abidlabs-mcp-tools2.hf.space/gradio_api/mcp/sse"}
8
+ ) as tools:
9
+ print("\n".join(f"{t.name}: {t.description}" for t in tools))
10
+
11
+ from mcp import StdioServerParameters
12
+ from smolagents import InferenceClientModel, CodeAgent, ToolCollection, MCPClient
13
+
14
+ try:
15
+ mcp_client = MCPClient(
16
+ {f"url" : "https://kolkhi-mcp-sentiment.hf.space/gradio_api/mcp/sse"}
17
+ )
18
+
19
+ tools = mcp_client.get_tools()
20
+
21
+ model = InferenceClientModel(token=os.getenv("HF_TOKEN"))
22
+ agent = CodeAgent(tools=[*tools], model=model)
23
+
24
+ demo = gr.ChatInterface(
25
+ fn=lambda message, history: str(agent.run(message)),
26
+ type = "messages",
27
+ examples=["Prime factorization of 68"],
28
+ title="Agent with MCP Tools",
29
+ description="This is a simple agent that uses MCP tools to answer questions."
30
+ )
31
+
32
+ demo.launch()
33
+
34
+ finally:
35
+ mcp_client.disconnect()
36
+
37
+
38
+
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]
2
+ smolagents[mcp]