Spaces:
Runtime error
Runtime error
Commit
·
b206714
1
Parent(s):
dc5dca4
Auto connect MCP
Browse filesSigned-off-by: Aivin V. Solatorio <avsolatorio@gmail.com>
- mcp_client.py +7 -3
mcp_client.py
CHANGED
|
@@ -329,10 +329,9 @@ class MCPClientWrapper:
|
|
| 329 |
contents.extend(next_response.content)
|
| 330 |
|
| 331 |
|
| 332 |
-
client = MCPClientWrapper()
|
| 333 |
-
|
| 334 |
-
|
| 335 |
def gradio_interface():
|
|
|
|
|
|
|
| 336 |
with gr.Blocks(title="MCP WDI Client") as demo:
|
| 337 |
gr.Markdown("# WDI MCP Client")
|
| 338 |
# gr.Markdown("Connect to the WDI MCP server and chat with the assistant")
|
|
@@ -358,6 +357,7 @@ def gradio_interface():
|
|
| 358 |
type="messages",
|
| 359 |
show_copy_button=True,
|
| 360 |
avatar_images=("img/small-user.png", "img/small-robot.png"),
|
|
|
|
| 361 |
)
|
| 362 |
|
| 363 |
with gr.Row(equal_height=True):
|
|
@@ -369,6 +369,10 @@ def gradio_interface():
|
|
| 369 |
clear_btn = gr.Button("Clear Chat", scale=1)
|
| 370 |
|
| 371 |
connect_btn.click(client.connect, inputs=server_path, outputs=status)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
msg.submit(client.process_message, [msg, chatbot], [chatbot, msg])
|
| 373 |
clear_btn.click(lambda: [], None, chatbot)
|
| 374 |
|
|
|
|
| 329 |
contents.extend(next_response.content)
|
| 330 |
|
| 331 |
|
|
|
|
|
|
|
|
|
|
| 332 |
def gradio_interface():
|
| 333 |
+
client = MCPClientWrapper()
|
| 334 |
+
|
| 335 |
with gr.Blocks(title="MCP WDI Client") as demo:
|
| 336 |
gr.Markdown("# WDI MCP Client")
|
| 337 |
# gr.Markdown("Connect to the WDI MCP server and chat with the assistant")
|
|
|
|
| 357 |
type="messages",
|
| 358 |
show_copy_button=True,
|
| 359 |
avatar_images=("img/small-user.png", "img/small-robot.png"),
|
| 360 |
+
autoscroll=True,
|
| 361 |
)
|
| 362 |
|
| 363 |
with gr.Row(equal_height=True):
|
|
|
|
| 369 |
clear_btn = gr.Button("Clear Chat", scale=1)
|
| 370 |
|
| 371 |
connect_btn.click(client.connect, inputs=server_path, outputs=status)
|
| 372 |
+
|
| 373 |
+
# Automatically call client.connect(...) as soon as the interface loads
|
| 374 |
+
demo.load(fn=client.connect, inputs=server_path, outputs=status)
|
| 375 |
+
|
| 376 |
msg.submit(client.process_message, [msg, chatbot], [chatbot, msg])
|
| 377 |
clear_btn.click(lambda: [], None, chatbot)
|
| 378 |
|