Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,15 +1,17 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
from
|
4 |
-
from
|
5 |
from radial_diagram_generator import generate_radial_diagram
|
|
|
6 |
from process_flow_generator import generate_process_flow_diagram
|
7 |
-
from wbs_diagram_generator import generate_wbs_diagram
|
8 |
from timeline_generator import generate_timeline_diagram
|
9 |
-
from binary_tree_generator import generate_binary_tree_diagram
|
10 |
from network_graph_generator import generate_network_graph
|
|
|
|
|
|
|
11 |
|
12 |
-
from sample_data import
|
13 |
|
14 |
if __name__ == "__main__":
|
15 |
DEFAULT_BASE_COLOR = '#19191a'
|
@@ -84,65 +86,65 @@ if __name__ == "__main__":
|
|
84 |
)
|
85 |
|
86 |
with gr.Tabs():
|
87 |
-
with gr.TabItem("
|
88 |
with gr.Row():
|
89 |
with gr.Column(scale=1):
|
90 |
-
|
91 |
-
value=
|
92 |
placeholder="Paste JSON following the documented format",
|
93 |
label="JSON Input",
|
94 |
lines=20
|
95 |
)
|
96 |
-
|
97 |
|
98 |
with gr.Column(scale=2):
|
99 |
-
|
100 |
label="Generated Diagram",
|
101 |
type="filepath",
|
102 |
show_download_button=True,
|
103 |
height=500
|
104 |
)
|
105 |
|
106 |
-
|
107 |
-
fn=
|
108 |
-
inputs=[
|
109 |
-
outputs=
|
110 |
)
|
111 |
|
112 |
gr.Markdown("## Examples")
|
113 |
with gr.Row(elem_classes=["example-images"]):
|
114 |
-
gr.Image(value="./images/
|
115 |
-
gr.Image(value="./images/
|
116 |
|
117 |
-
with gr.TabItem("
|
118 |
with gr.Row():
|
119 |
with gr.Column(scale=1):
|
120 |
-
|
121 |
-
value=
|
122 |
placeholder="Paste JSON following the documented format",
|
123 |
label="JSON Input",
|
124 |
lines=20
|
125 |
)
|
126 |
-
|
127 |
|
128 |
with gr.Column(scale=2):
|
129 |
-
|
130 |
label="Generated Diagram",
|
131 |
type="filepath",
|
132 |
show_download_button=True,
|
133 |
height=500
|
134 |
)
|
135 |
|
136 |
-
|
137 |
-
fn=
|
138 |
-
inputs=[
|
139 |
-
outputs=
|
140 |
)
|
141 |
|
142 |
gr.Markdown("## Examples")
|
143 |
with gr.Row(elem_classes=["example-images"]):
|
144 |
-
gr.Image(value="./images/
|
145 |
-
gr.Image(value="./images/
|
146 |
|
147 |
with gr.TabItem("Radial Diagram"):
|
148 |
with gr.Row():
|
@@ -176,65 +178,65 @@ if __name__ == "__main__":
|
|
176 |
gr.Image(value="./images/rd3.svg", label="Sample 3", show_label=True, interactive=False, height="auto", width="100%")
|
177 |
gr.Image(value="./images/rd4.svg", label="Sample 4", show_label=True, interactive=False, height="auto", width="100%")
|
178 |
|
179 |
-
with gr.TabItem("
|
180 |
with gr.Row():
|
181 |
with gr.Column(scale=1):
|
182 |
-
|
183 |
-
value=
|
184 |
placeholder="Paste JSON following the documented format",
|
185 |
label="JSON Input",
|
186 |
lines=20
|
187 |
)
|
188 |
-
|
189 |
|
190 |
with gr.Column(scale=2):
|
191 |
-
|
192 |
label="Generated Diagram",
|
193 |
type="filepath",
|
194 |
show_download_button=True,
|
195 |
height=500
|
196 |
)
|
197 |
|
198 |
-
|
199 |
-
fn=
|
200 |
-
inputs=[
|
201 |
-
outputs=
|
202 |
)
|
203 |
|
204 |
gr.Markdown("## Examples")
|
205 |
with gr.Row(elem_classes=["example-images"]):
|
206 |
-
gr.Image(value="./images/
|
207 |
-
gr.Image(value="./images/
|
208 |
|
209 |
-
with gr.TabItem("
|
210 |
with gr.Row():
|
211 |
with gr.Column(scale=1):
|
212 |
-
|
213 |
-
value=
|
214 |
placeholder="Paste JSON following the documented format",
|
215 |
label="JSON Input",
|
216 |
lines=20
|
217 |
)
|
218 |
-
|
219 |
|
220 |
with gr.Column(scale=2):
|
221 |
-
|
222 |
label="Generated Diagram",
|
223 |
type="filepath",
|
224 |
show_download_button=True,
|
225 |
height=500
|
226 |
)
|
227 |
|
228 |
-
|
229 |
-
fn=
|
230 |
-
inputs=[
|
231 |
-
outputs=
|
232 |
)
|
233 |
|
234 |
gr.Markdown("## Examples")
|
235 |
with gr.Row(elem_classes=["example-images"]):
|
236 |
-
gr.Image(value="./images/
|
237 |
-
gr.Image(value="./images/
|
238 |
|
239 |
with gr.TabItem("Timeline"):
|
240 |
with gr.Row():
|
@@ -266,6 +268,36 @@ if __name__ == "__main__":
|
|
266 |
gr.Image(value="./images/tl1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
267 |
gr.Image(value="./images/tl2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
268 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
269 |
with gr.TabItem("Binary Tree"):
|
270 |
with gr.Row():
|
271 |
with gr.Column(scale=1):
|
@@ -296,35 +328,65 @@ if __name__ == "__main__":
|
|
296 |
gr.Image(value="./images/bt1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
297 |
gr.Image(value="./images/bt2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
298 |
|
299 |
-
with gr.TabItem("
|
300 |
with gr.Row():
|
301 |
with gr.Column(scale=1):
|
302 |
-
|
303 |
-
value=
|
304 |
placeholder="Paste JSON following the documented format",
|
305 |
label="JSON Input",
|
306 |
lines=20
|
307 |
)
|
308 |
-
|
309 |
|
310 |
with gr.Column(scale=2):
|
311 |
-
|
312 |
label="Generated Diagram",
|
313 |
type="filepath",
|
314 |
show_download_button=True,
|
315 |
height=500
|
316 |
)
|
317 |
|
318 |
-
|
319 |
-
fn=
|
320 |
-
inputs=[
|
321 |
-
outputs=
|
322 |
)
|
323 |
|
324 |
gr.Markdown("## Examples")
|
325 |
with gr.Row(elem_classes=["example-images"]):
|
326 |
-
gr.Image(value="./images/
|
327 |
-
gr.Image(value="./images/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
328 |
|
329 |
demo.launch(
|
330 |
mcp_server=True,
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
from class_diagram_generator import generate_class_diagram
|
4 |
+
from entity_relationship_generator import generate_entity_relationship_diagram
|
5 |
from radial_diagram_generator import generate_radial_diagram
|
6 |
+
from concept_map_generator import generate_concept_map
|
7 |
from process_flow_generator import generate_process_flow_diagram
|
|
|
8 |
from timeline_generator import generate_timeline_diagram
|
|
|
9 |
from network_graph_generator import generate_network_graph
|
10 |
+
from binary_tree_generator import generate_binary_tree_diagram
|
11 |
+
from wbs_diagram_generator import generate_wbs_diagram
|
12 |
+
from synoptic_chart_generator import generate_synoptic_chart
|
13 |
|
14 |
+
from sample_data import CLASS_DIAGRAM_JSON, ENTITY_RELATIONSHIP_JSON, RADIAL_DIAGRAM_JSON, CONCEPT_MAP_JSON, PROCESS_FLOW_JSON, TIMELINE_JSON, NETWORK_GRAPH_JSON, BINARY_TREE_JSON, WBS_DIAGRAM_JSON, SYNOPTIC_CHART_JSON
|
15 |
|
16 |
if __name__ == "__main__":
|
17 |
DEFAULT_BASE_COLOR = '#19191a'
|
|
|
86 |
)
|
87 |
|
88 |
with gr.Tabs():
|
89 |
+
with gr.TabItem("Class Diagram"):
|
90 |
with gr.Row():
|
91 |
with gr.Column(scale=1):
|
92 |
+
json_input_cd = gr.Textbox(
|
93 |
+
value=CLASS_DIAGRAM_JSON,
|
94 |
placeholder="Paste JSON following the documented format",
|
95 |
label="JSON Input",
|
96 |
lines=20
|
97 |
)
|
98 |
+
submit_btn_cd = gr.Button("Generate Class Diagram", variant="primary")
|
99 |
|
100 |
with gr.Column(scale=2):
|
101 |
+
output_cd = gr.Image(
|
102 |
label="Generated Diagram",
|
103 |
type="filepath",
|
104 |
show_download_button=True,
|
105 |
height=500
|
106 |
)
|
107 |
|
108 |
+
submit_btn_cd.click(
|
109 |
+
fn=generate_class_diagram,
|
110 |
+
inputs=[json_input_cd, output_format_radio],
|
111 |
+
outputs=output_cd
|
112 |
)
|
113 |
|
114 |
gr.Markdown("## Examples")
|
115 |
with gr.Row(elem_classes=["example-images"]):
|
116 |
+
gr.Image(value="./images/cd1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
117 |
+
gr.Image(value="./images/cd2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
118 |
|
119 |
+
with gr.TabItem("Entity Relationship"):
|
120 |
with gr.Row():
|
121 |
with gr.Column(scale=1):
|
122 |
+
json_input_er = gr.Textbox(
|
123 |
+
value=ENTITY_RELATIONSHIP_JSON,
|
124 |
placeholder="Paste JSON following the documented format",
|
125 |
label="JSON Input",
|
126 |
lines=20
|
127 |
)
|
128 |
+
submit_btn_er = gr.Button("Generate ER Diagram", variant="primary")
|
129 |
|
130 |
with gr.Column(scale=2):
|
131 |
+
output_er = gr.Image(
|
132 |
label="Generated Diagram",
|
133 |
type="filepath",
|
134 |
show_download_button=True,
|
135 |
height=500
|
136 |
)
|
137 |
|
138 |
+
submit_btn_er.click(
|
139 |
+
fn=generate_entity_relationship_diagram,
|
140 |
+
inputs=[json_input_er, output_format_radio],
|
141 |
+
outputs=output_er
|
142 |
)
|
143 |
|
144 |
gr.Markdown("## Examples")
|
145 |
with gr.Row(elem_classes=["example-images"]):
|
146 |
+
gr.Image(value="./images/er1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
147 |
+
gr.Image(value="./images/er2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
148 |
|
149 |
with gr.TabItem("Radial Diagram"):
|
150 |
with gr.Row():
|
|
|
178 |
gr.Image(value="./images/rd3.svg", label="Sample 3", show_label=True, interactive=False, height="auto", width="100%")
|
179 |
gr.Image(value="./images/rd4.svg", label="Sample 4", show_label=True, interactive=False, height="auto", width="100%")
|
180 |
|
181 |
+
with gr.TabItem("Concept Map"):
|
182 |
with gr.Row():
|
183 |
with gr.Column(scale=1):
|
184 |
+
json_input_cm = gr.Textbox(
|
185 |
+
value=CONCEPT_MAP_JSON,
|
186 |
placeholder="Paste JSON following the documented format",
|
187 |
label="JSON Input",
|
188 |
lines=20
|
189 |
)
|
190 |
+
submit_btn_cm = gr.Button("Generate Concept Map", variant="primary")
|
191 |
|
192 |
with gr.Column(scale=2):
|
193 |
+
output_cm = gr.Image(
|
194 |
label="Generated Diagram",
|
195 |
type="filepath",
|
196 |
show_download_button=True,
|
197 |
height=500
|
198 |
)
|
199 |
|
200 |
+
submit_btn_cm.click(
|
201 |
+
fn=generate_concept_map,
|
202 |
+
inputs=[json_input_cm, output_format_radio],
|
203 |
+
outputs=output_cm
|
204 |
)
|
205 |
|
206 |
gr.Markdown("## Examples")
|
207 |
with gr.Row(elem_classes=["example-images"]):
|
208 |
+
gr.Image(value="./images/cm1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
209 |
+
gr.Image(value="./images/cm2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
210 |
|
211 |
+
with gr.TabItem("Process Flow"):
|
212 |
with gr.Row():
|
213 |
with gr.Column(scale=1):
|
214 |
+
json_input_pf = gr.Textbox(
|
215 |
+
value=PROCESS_FLOW_JSON,
|
216 |
placeholder="Paste JSON following the documented format",
|
217 |
label="JSON Input",
|
218 |
lines=20
|
219 |
)
|
220 |
+
submit_btn_pf = gr.Button("Generate Process Flow", variant="primary")
|
221 |
|
222 |
with gr.Column(scale=2):
|
223 |
+
output_pf = gr.Image(
|
224 |
label="Generated Diagram",
|
225 |
type="filepath",
|
226 |
show_download_button=True,
|
227 |
height=500
|
228 |
)
|
229 |
|
230 |
+
submit_btn_pf.click(
|
231 |
+
fn=generate_process_flow_diagram,
|
232 |
+
inputs=[json_input_pf, output_format_radio],
|
233 |
+
outputs=output_pf
|
234 |
)
|
235 |
|
236 |
gr.Markdown("## Examples")
|
237 |
with gr.Row(elem_classes=["example-images"]):
|
238 |
+
gr.Image(value="./images/pf1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
239 |
+
gr.Image(value="./images/pf2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
240 |
|
241 |
with gr.TabItem("Timeline"):
|
242 |
with gr.Row():
|
|
|
268 |
gr.Image(value="./images/tl1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
269 |
gr.Image(value="./images/tl2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
270 |
|
271 |
+
with gr.TabItem("Network Graph"):
|
272 |
+
with gr.Row():
|
273 |
+
with gr.Column(scale=1):
|
274 |
+
json_input_ng = gr.Textbox(
|
275 |
+
value=NETWORK_GRAPH_JSON,
|
276 |
+
placeholder="Paste JSON following the documented format",
|
277 |
+
label="JSON Input",
|
278 |
+
lines=20
|
279 |
+
)
|
280 |
+
submit_btn_ng = gr.Button("Generate Network Graph", variant="primary")
|
281 |
+
|
282 |
+
with gr.Column(scale=2):
|
283 |
+
output_ng = gr.Image(
|
284 |
+
label="Generated Diagram",
|
285 |
+
type="filepath",
|
286 |
+
show_download_button=True,
|
287 |
+
height=500
|
288 |
+
)
|
289 |
+
|
290 |
+
submit_btn_ng.click(
|
291 |
+
fn=generate_network_graph,
|
292 |
+
inputs=[json_input_ng, output_format_radio],
|
293 |
+
outputs=output_ng
|
294 |
+
)
|
295 |
+
|
296 |
+
gr.Markdown("## Examples")
|
297 |
+
with gr.Row(elem_classes=["example-images"]):
|
298 |
+
gr.Image(value="./images/ng1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
299 |
+
gr.Image(value="./images/ng2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
300 |
+
|
301 |
with gr.TabItem("Binary Tree"):
|
302 |
with gr.Row():
|
303 |
with gr.Column(scale=1):
|
|
|
328 |
gr.Image(value="./images/bt1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
329 |
gr.Image(value="./images/bt2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
330 |
|
331 |
+
with gr.TabItem("WBS Diagram"):
|
332 |
with gr.Row():
|
333 |
with gr.Column(scale=1):
|
334 |
+
json_input_wbs = gr.Textbox(
|
335 |
+
value=WBS_DIAGRAM_JSON,
|
336 |
placeholder="Paste JSON following the documented format",
|
337 |
label="JSON Input",
|
338 |
lines=20
|
339 |
)
|
340 |
+
submit_btn_wbs = gr.Button("Generate WBS Diagram", variant="primary")
|
341 |
|
342 |
with gr.Column(scale=2):
|
343 |
+
output_wbs = gr.Image(
|
344 |
label="Generated Diagram",
|
345 |
type="filepath",
|
346 |
show_download_button=True,
|
347 |
height=500
|
348 |
)
|
349 |
|
350 |
+
submit_btn_wbs.click(
|
351 |
+
fn=generate_wbs_diagram,
|
352 |
+
inputs=[json_input_wbs, output_format_radio],
|
353 |
+
outputs=output_wbs
|
354 |
)
|
355 |
|
356 |
gr.Markdown("## Examples")
|
357 |
with gr.Row(elem_classes=["example-images"]):
|
358 |
+
gr.Image(value="./images/wd1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
359 |
+
gr.Image(value="./images/wd2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
360 |
+
|
361 |
+
with gr.TabItem("Synoptic Chart"):
|
362 |
+
with gr.Row():
|
363 |
+
with gr.Column(scale=1):
|
364 |
+
json_input_sc = gr.Textbox(
|
365 |
+
value=SYNOPTIC_CHART_JSON,
|
366 |
+
placeholder="Paste JSON following the documented format",
|
367 |
+
label="JSON Input",
|
368 |
+
lines=20
|
369 |
+
)
|
370 |
+
submit_btn_sc = gr.Button("Generate Synoptic Chart", variant="primary")
|
371 |
+
|
372 |
+
with gr.Column(scale=2):
|
373 |
+
output_sc = gr.Image(
|
374 |
+
label="Generated Diagram",
|
375 |
+
type="filepath",
|
376 |
+
show_download_button=True,
|
377 |
+
height=500
|
378 |
+
)
|
379 |
+
|
380 |
+
submit_btn_sc.click(
|
381 |
+
fn=generate_synoptic_chart,
|
382 |
+
inputs=[json_input_sc, output_format_radio],
|
383 |
+
outputs=output_sc
|
384 |
+
)
|
385 |
+
|
386 |
+
gr.Markdown("## Examples")
|
387 |
+
with gr.Row(elem_classes=["example-images"]):
|
388 |
+
gr.Image(value="./images/sc1.svg", label="Sample 1", show_label=True, interactive=False, height="auto", width="100%")
|
389 |
+
gr.Image(value="./images/sc2.svg", label="Sample 2", show_label=True, interactive=False, height="auto", width="100%")
|
390 |
|
391 |
demo.launch(
|
392 |
mcp_server=True,
|