betki commited on
Commit
bbc5870
·
verified ·
1 Parent(s): c542c6c
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -5,29 +5,27 @@ from smolagents import ToolCollection, CodeAgent
5
  from smolagents import CodeAgent, InferenceClientModel
6
  from smolagents.mcp_client import MCPClient
7
 
 
8
 
9
  try:
10
- mcp_client = MCPClient(
11
- {"url": "http://localhost:7860/gradio_api/mcp/sse"}
12
  )
13
- tools = mcp_client.get_tools()
14
 
15
- model = InferenceClientModel()
16
  agent = CodeAgent(tools=[*tools], model=model)
17
 
18
  def call_agent(message, history):
19
  return str(agent.run(message))
20
 
21
-
22
  demo = gr.ChatInterface(
23
- fn=lambda message, history: str(agent.run(message)),
24
  type="messages",
25
  examples=["Prime factorization of 68"],
26
  title="Agent with MCP Tools",
27
  description="This is a simple agent that uses MCP tools to answer questions.",
28
- messages=[],
29
  )
30
 
31
- demo.launch(share=True)
32
  finally:
33
- mcp_client.close()
 
5
  from smolagents import CodeAgent, InferenceClientModel
6
  from smolagents.mcp_client import MCPClient
7
 
8
+ model = InferenceClientModel()
9
 
10
  try:
11
+ mcp_client = MCPClient(
12
+ {"url": "https://betki.hf.space/gradio_api/mcp/sse"}
13
  )
 
14
 
15
+ tools = mcp_client.get_tools()
16
  agent = CodeAgent(tools=[*tools], model=model)
17
 
18
  def call_agent(message, history):
19
  return str(agent.run(message))
20
 
 
21
  demo = gr.ChatInterface(
22
+ fn=call_agent,
23
  type="messages",
24
  examples=["Prime factorization of 68"],
25
  title="Agent with MCP Tools",
26
  description="This is a simple agent that uses MCP tools to answer questions.",
 
27
  )
28
 
29
+ demo.launch()
30
  finally:
31
+ mcp_client.stop()