File size: 848 Bytes
933d7ff
 
 
 
 
 
 
 
91c0c5a
 
 
 
933d7ff
dade101
 
 
 
 
 
eb9cf92
dade101
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import gradio as gr

from mcp.client.stdio import StdioServerParameters
from smolagents import ToolCollection, CodeAgent
from smolagents import CodeAgent, InferenceClientModel
from smolagents.mcp_client import MCPClient


with MCPClient(
    # {"url": "https://abidlabs-mcp-tools.hf.space/gradio_api/mcp/sse"}
    {"url": "https://techno-1-mcp-sentiment.hf.space/gradio_api/mcp/sse", "transport": "streamable-http"}
) as tools:

    model = InferenceClientModel()
    agent = CodeAgent(tools=[*tools], model=model)
    
    demo = gr.ChatInterface(
        fn=lambda message, history: str(agent.run(message)),
        type="messages",
        examples=["Analyse the sentiment of: I Love Cats"],
        title="Agent with MCP Tools",
        description="This is a simple agent that uses MCP tools to answer questions.",
    )
    
    demo.launch()