Update mcp_server
Browse files- 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 MCP
|
| 8 |
params = StdioServerParameters(command="python", args=["mcp_server.py"])
|
| 9 |
with MCPClient(params) as tools:
|
| 10 |
-
agent = CodeAgent(tools=tools, model="gpt-4") #
|
| 11 |
answer = agent.run(message)
|
| 12 |
history.append((message, answer))
|
| 13 |
return history, history
|
| 14 |
|
| 15 |
|
| 16 |
with gr.Blocks() as demo:
|
| 17 |
-
|
| 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,
|
| 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()
|