atharva98 commited on
Commit
248de3d
·
verified ·
1 Parent(s): 3d9cf29

Create app.py

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