mgbam commited on
Commit
2e76b4c
·
verified ·
1 Parent(s): d2c5450

Update mcp_server

Browse files
Files changed (1) hide show
  1. mcp_server +6 -4
mcp_server CHANGED
@@ -4,24 +4,24 @@ from smolagents import MCPClient, CodeAgent
4
 
5
 
6
  def respond(message, history):
7
- """Send the message to the MCPpowered agent and return its reply."""
8
  params = StdioServerParameters(command="python", args=["mcp_server.py"])
9
  with MCPClient(params) as tools:
10
- agent = CodeAgent(tools=tools, model="gpt-4") # replace with your model or OpenAI wrapper
11
  answer = agent.run(message)
12
  history.append((message, answer))
13
  return history, history
14
 
15
 
16
  with gr.Blocks() as demo:
17
- state = gr.State([])
18
  chatbot = gr.Chatbot(label="Enterprise SQL Agent")
19
 
20
  textbox = gr.Textbox(
21
  show_label=False,
22
  placeholder="Ask: Who are my inactive Northeast customers?",
23
  )
24
- textbox.submit(respond, [textbox, state], [chatbot, state])
25
 
26
  gr.Markdown(
27
  """
@@ -32,4 +32,6 @@ with gr.Blocks() as demo:
32
  """
33
  )
34
 
 
 
35
  demo.launch()
 
4
 
5
 
6
  def respond(message, history):
7
+ """Send the message to the MCP-powered agent and return its answer."""
8
  params = StdioServerParameters(command="python", args=["mcp_server.py"])
9
  with MCPClient(params) as tools:
10
+ agent = CodeAgent(tools=tools, model="gpt-4") # swap for your model
11
  answer = agent.run(message)
12
  history.append((message, answer))
13
  return history, history
14
 
15
 
16
  with gr.Blocks() as demo:
17
+ chat_state = gr.State([])
18
  chatbot = gr.Chatbot(label="Enterprise SQL Agent")
19
 
20
  textbox = gr.Textbox(
21
  show_label=False,
22
  placeholder="Ask: Who are my inactive Northeast customers?",
23
  )
24
+ textbox.submit(respond, [textbox, chat_state], [chatbot, chat_state])
25
 
26
  gr.Markdown(
27
  """
 
32
  """
33
  )
34
 
35
+ gr.Markdown("Built with MCP, smolagents, and Gradio")
36
+
37
  demo.launch()