Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,16 +7,22 @@ load_dotenv()
|
|
| 7 |
|
| 8 |
try:
|
| 9 |
mcp_client = MCPClient(
|
| 10 |
-
{
|
|
|
|
|
|
|
|
|
|
| 11 |
)
|
| 12 |
tools = mcp_client.get_tools()
|
| 13 |
|
| 14 |
model = InferenceClientModel(token=os.getenv("HUGGINGFACE_API_TOKEN"))
|
| 15 |
-
agent = CodeAgent(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.",
|
|
|
|
| 7 |
|
| 8 |
try:
|
| 9 |
mcp_client = MCPClient(
|
| 10 |
+
server_parameters={
|
| 11 |
+
"url": "https://abidlabs-mcp-tool-http.hf.space/gradio_api/mcp/sse",
|
| 12 |
+
"transport": "sse" # 👈 avoid FutureWarning
|
| 13 |
+
}
|
| 14 |
)
|
| 15 |
tools = mcp_client.get_tools()
|
| 16 |
|
| 17 |
model = InferenceClientModel(token=os.getenv("HUGGINGFACE_API_TOKEN"))
|
| 18 |
+
agent = CodeAgent(
|
| 19 |
+
tools=[*tools],
|
| 20 |
+
model=model,
|
| 21 |
+
additional_authorized_imports=["json", "ast", "urllib", "base64"]
|
| 22 |
+
)
|
| 23 |
|
| 24 |
demo = gr.ChatInterface(
|
| 25 |
fn=lambda message, history: str(agent.run(message)),
|
|
|
|
| 26 |
examples=["Analyze the sentiment of the following text 'This is awesome'"],
|
| 27 |
title="Agent with MCP Tools",
|
| 28 |
description="This is a simple agent that uses MCP tools to answer questions.",
|