Spaces:
Sleeping
Sleeping
Create township_gradio_demo.py
Browse files- township_gradio_demo.py +42 -0
township_gradio_demo.py
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from app import mcp_server # Imports your main backend JSON-RPC handler
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
demo = gr.Interface(
|
5 |
+
fn=mcp_server,
|
6 |
+
inputs=gr.Textbox(label="JSON-RPC Input", lines=20, info="Paste your JSON-RPC request here."),
|
7 |
+
outputs=gr.Textbox(label="Chatbot Response", lines=20),
|
8 |
+
title="Township Business Chatbot UI",
|
9 |
+
description="This demo UI connects to the Township Directory backend. Use it to register businesses or get nearby listings using JSON-RPC payloads.",
|
10 |
+
examples=[
|
11 |
+
[
|
12 |
+
"""{
|
13 |
+
"jsonrpc": "2.0",
|
14 |
+
"method": "registerBusiness",
|
15 |
+
"params": {
|
16 |
+
"name": "Kasi Kitchen",
|
17 |
+
"description": "Delicious township meals",
|
18 |
+
"address": "999 Spaza Road",
|
19 |
+
"phone": "0721234567",
|
20 |
+
"latitude": "-26.2041",
|
21 |
+
"longitude": "28.0473"
|
22 |
+
},
|
23 |
+
"id": 1
|
24 |
+
}"""
|
25 |
+
],
|
26 |
+
[
|
27 |
+
"""{
|
28 |
+
"jsonrpc": "2.0",
|
29 |
+
"method": "getNearbyBusinesses",
|
30 |
+
"params": {
|
31 |
+
"latitude": "-26.2041",
|
32 |
+
"longitude": "28.0473",
|
33 |
+
"radius_km": 5
|
34 |
+
},
|
35 |
+
"id": 2
|
36 |
+
}"""
|
37 |
+
]
|
38 |
+
],
|
39 |
+
theme="soft", # Optional aesthetic
|
40 |
+
)
|
41 |
+
|
42 |
+
demo.launch(share=True)
|