betki commited on
Commit
cafc1fb
·
verified ·
1 Parent(s): 8591042

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -1,13 +1,20 @@
1
- import gradio as gr
 
 
 
 
 
2
  import os
 
 
3
 
4
- from mcp import StdioServerParameters
5
- from smolagents import InferenceClientModel, CodeAgent, ToolCollection, MCPClient
6
 
7
  try:
8
  mcp_client = MCPClient(
9
  {
10
- "url": "https://betki-mcp-sentiment.hf.space/gradio_api/mcp/sse",
11
  "transport": "sse"
12
  }
13
  )
@@ -21,9 +28,9 @@ try:
21
  fn=lambda message, history: str(agent.run(message)),
22
  type="messages",
23
  title="Agent with MCP Tools",
24
- description="Agent that uses MCP tools (sentiment analysis) to analyze input for sentiment.",
25
  )
26
 
27
  demo.launch()
28
  finally:
29
- mcp_client.disconnect()
 
1
+ """
2
+ This is a Gradio MCP client that connects to my MCP server (mcp-rag-workflow).
3
+ This script initializes a Gradio interface for an agent that uses tools from the MCP server.
4
+ It connects to the MCP server, retrieves available tools, and sets up a chat interface where users can interact with the agent.
5
+ """
6
+
7
  import os
8
+ from dotenv import load_dotenv
9
+ load_dotenv() # Load environment variables from .env file
10
 
11
+ import gradio as gr
12
+ from smolagents import InferenceClientModel, CodeAgent, MCPClient
13
 
14
  try:
15
  mcp_client = MCPClient(
16
  {
17
+ "url": "https://agents-mcp-hackathon-mcp-rag-workflow.hf.space/gradio_api/mcp/sse",
18
  "transport": "sse"
19
  }
20
  )
 
28
  fn=lambda message, history: str(agent.run(message)),
29
  type="messages",
30
  title="Agent with MCP Tools",
31
+ description="MCP Client build with Gradio to use (mcp-rag-workflow) MCP tools.",
32
  )
33
 
34
  demo.launch()
35
  finally:
36
+ mcp_client.disconnect()