root commited on
Commit
a6e221b
·
1 Parent(s): 1b158bc

Initial commit

Browse files
Files changed (2) hide show
  1. app.py +29 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+
3
+ import gradio as gr
4
+ from mcp import StdioServerParameters
5
+ from smolagents import InferenceClientModel, CodeAgent, ToolCollection, MCPClient
6
+
7
+
8
+ try:
9
+ server_parameters = {
10
+ "url": "https://abidlabs-mcp-tools2.hf.space/gradio_api/mcp/sse", # https://jonnhan-mcp-sentiment.hf.space/gradio_api/mcp/sse
11
+ "transport": "sse",
12
+ }
13
+ mcp_client = MCPClient(server_parameters)
14
+ tools = mcp_client.get_tools()
15
+
16
+ model = InferenceClientModel(token=os.getenv("HF_TOKEN"))
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 Tools",
24
+ description = "This is a simple agent that uses MCP tools to answer questions."
25
+ )
26
+
27
+ demo.launch()
28
+ finally:
29
+ mcp_client.disconnect()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]
2
+ textblob