Spaces:
Runtime error
Runtime error
Commit
·
b36e127
1
Parent(s):
14e9c7e
change key
Browse files- mcp_client.py +0 -27
mcp_client.py
DELETED
@@ -1,27 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import os
|
3 |
-
|
4 |
-
from smolagents import InferenceClientModel, CodeAgent, MCPClient
|
5 |
-
|
6 |
-
|
7 |
-
try:
|
8 |
-
|
9 |
-
mcp_client = MCPClient(
|
10 |
-
{"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse"}
|
11 |
-
)
|
12 |
-
tools = mcp_client.get_tools()
|
13 |
-
|
14 |
-
model = InferenceClientModel(token=os.getenv("HUGGINGFACE_API_TOKEN"))
|
15 |
-
agent = CodeAgent(tools=[*tools], model=model, additional_authorized_imports=["json", "ast", "urllib", "base64"])
|
16 |
-
|
17 |
-
demo = gr.ChatInterface(
|
18 |
-
fn=lambda message, history: str(agent.run(message)),
|
19 |
-
type="messages",
|
20 |
-
examples=["Analyze the sentiment of the following text 'This is awesome'"],
|
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 |
-
finally:
|
27 |
-
mcp_client.disconnect()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|