kvquezada commited on
Commit
66820aa
·
1 Parent(s): ac5f25b

Initial commit

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