NickKuijpers commited on
Commit
7d660e2
·
1 Parent(s): bc6cf13

fix requirements & launch

Browse files
Files changed (2) hide show
  1. app.py +18 -3
  2. requirements.txt +4 -2
app.py CHANGED
@@ -3,10 +3,12 @@ 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", "transport": "sse"}
 
10
  )
11
  tools = mcp_client.get_tools()
12
 
@@ -21,6 +23,19 @@ try:
21
  description="This is a simple agent that uses MCP tools to answer questions.",
22
  )
23
 
24
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
25
  finally:
26
- mcp_client.disconnect()
 
 
3
 
4
  from smolagents import InferenceClientModel, CodeAgent, MCPClient
5
 
6
+ mcp_client = None
7
 
8
  try:
9
  mcp_client = MCPClient(
10
+ {"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse", "transport": "sse"},
11
+ structured_output=False
12
  )
13
  tools = mcp_client.get_tools()
14
 
 
23
  description="This is a simple agent that uses MCP tools to answer questions.",
24
  )
25
 
26
+ if __name__ == "__main__":
27
+ demo.launch()
28
+ except Exception as e:
29
+ print(f"Error: {e}")
30
+ # Fallback demo without MCP tools
31
+ demo = gr.ChatInterface(
32
+ fn=lambda message, history: "MCP client connection failed. Please check the configuration.",
33
+ type="messages",
34
+ title="MCP Client (Connection Failed)",
35
+ description="Could not connect to MCP server.",
36
+ )
37
+ if __name__ == "__main__":
38
+ demo.launch()
39
  finally:
40
+ if mcp_client is not None:
41
+ mcp_client.disconnect()
requirements.txt CHANGED
@@ -1,2 +1,4 @@
1
- gradio[mcp]
2
- smolagents[mcp]
 
 
 
1
+ gradio>=4.44.1
2
+ smolagents[mcp]
3
+ websockets
4
+ mcp