Sharathhebbar24 commited on
Commit
d75e1af
·
verified ·
1 Parent(s): 1d0f7e0

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +31 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ from mcp.client.stdio import StdioServerParameters
4
+ from smolagents import (
5
+ InferenceClientModel, CodeAgent, ToolCollection
6
+ )
7
+
8
+ from smolagents.mcp_client import MCPClient
9
+
10
+ try:
11
+ mcp_client = MCPClient(
12
+ {
13
+ "url": "https://sharathhebbar24-mcp-sentiment.hf.space/gradio_api/mcp/sse"
14
+ }
15
+ )
16
+ tools = mcp_client.get_tools()
17
+ model = InferenceClientModel()
18
+ agent = CodeAgent(tools=[*tools], model=model)
19
+
20
+ demo = gr.ChatInterface(
21
+ fn=lambda message, history: str(agent.run(message)),
22
+ type="messages",
23
+ examples=["Prime factorization of 68"],
24
+ title="Agents with MCP Tools",
25
+ description="This is a simple agent the uses MCP tools to answer questions",
26
+ )
27
+
28
+ demo.launch()
29
+
30
+ finally:
31
+ mcp_client.disconnect()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio[mcp]
2
+ smolagents[mcp]