Spaces:
Runtime error
Runtime error
Andrei
commited on
Commit
·
70a6082
1
Parent(s):
98d3887
Initial commit
Browse files- app.py +28 -0
- requirements.txt +3 -0
app.py
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from smolagents import CodeAgent
|
| 3 |
+
from smolagents.mcp_client import MCPClient
|
| 4 |
+
from smolagents import LiteLLMModel
|
| 5 |
+
|
| 6 |
+
|
| 7 |
+
try:
|
| 8 |
+
mcp_client = MCPClient(
|
| 9 |
+
## Try this working example on the hub:
|
| 10 |
+
{"url": "http://127.0.0.1:8000/sse"}
|
| 11 |
+
|
| 12 |
+
)
|
| 13 |
+
tools = mcp_client.get_tools()
|
| 14 |
+
|
| 15 |
+
model = LiteLLMModel(model_id="ollama/qwen2.5:7b", api_base="http://81.94.155.215:11434")
|
| 16 |
+
agent = CodeAgent(tools=[*tools], model=model)
|
| 17 |
+
|
| 18 |
+
demo = gr.ChatInterface(
|
| 19 |
+
fn=lambda message, history: str(agent.run(message)),
|
| 20 |
+
type="messages",
|
| 21 |
+
examples=["what is the weather like in Moscow now?"],
|
| 22 |
+
title="Agent with MCP Tools",
|
| 23 |
+
description="This is a simple agent that uses MCP tools to answer questions.",
|
| 24 |
+
)
|
| 25 |
+
|
| 26 |
+
demo.launch()
|
| 27 |
+
finally:
|
| 28 |
+
mcp_client.disconnect()
|
requirements.txt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio[mcp]
|
| 2 |
+
smolagents[mcp]
|
| 3 |
+
smolagents[litellm]
|