Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -25,28 +25,28 @@ if __name__ == "__main__":
|
|
25 |
.gr-button {
|
26 |
border-radius: 8px;
|
27 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
28 |
-
background-color: #FFA500;
|
29 |
color: white;
|
30 |
padding: 10px 20px;
|
31 |
font-size: 1.1em;
|
32 |
}
|
33 |
.gr-button:hover {
|
34 |
-
background-color: #FF8C00;
|
35 |
}
|
36 |
.gr-textbox {
|
37 |
border-radius: 8px;
|
38 |
padding: 10px;
|
39 |
}
|
40 |
-
/* Dark mode styles
|
41 |
.gradio-container.dark {
|
42 |
--tw-bg-opacity: 1;
|
43 |
background-color: rgb(24 24 27 / var(--tw-bg-opacity));
|
44 |
-
color: #d4d4d8;
|
45 |
}
|
46 |
.gradio-container.dark .gr-textbox {
|
47 |
background-color: rgb(39 39 42 / var(--tw-bg-opacity));
|
48 |
color: #d4d4d8;
|
49 |
-
border-color: #52525b;
|
50 |
}
|
51 |
.gradio-container.dark .gr-tab-item {
|
52 |
color: #d4d4d8;
|
@@ -67,150 +67,170 @@ if __name__ == "__main__":
|
|
67 |
)
|
68 |
|
69 |
with gr.Row(variant="panel"):
|
70 |
-
gr.Markdown("### Output Format")
|
71 |
output_format_radio = gr.Radio(
|
72 |
choices=["png", "svg"],
|
73 |
value="png",
|
74 |
-
label="
|
75 |
-
interactive=True
|
76 |
-
elem_id="output-format-selector"
|
77 |
)
|
78 |
|
79 |
-
gr.Markdown("<br>")
|
80 |
-
|
81 |
with gr.Tabs():
|
82 |
with gr.TabItem("Concept Map"):
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
submit_btn_cm.click(
|
97 |
fn=generate_concept_map,
|
98 |
inputs=[json_input_cm, output_format_radio],
|
99 |
outputs=output_cm
|
100 |
)
|
101 |
-
|
102 |
-
gr.Markdown("##
|
103 |
with gr.Row():
|
104 |
-
gr.Image(value="./images/cm1.svg", label="Sample 1", show_label=True, interactive=False, height=
|
105 |
-
gr.Image(value="./images/cm2.svg", label="Sample 2", show_label=True, interactive=False, height=
|
106 |
|
107 |
with gr.TabItem("Synoptic Chart"):
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
submit_btn_sc.click(
|
122 |
fn=generate_synoptic_chart,
|
123 |
inputs=[json_input_sc, output_format_radio],
|
124 |
outputs=output_sc
|
125 |
)
|
126 |
-
|
127 |
-
gr.Markdown("##
|
128 |
with gr.Row():
|
129 |
-
gr.Image(value="./images/sc1.svg", label="Sample 1", show_label=True, interactive=False, height=
|
130 |
-
gr.Image(value="./images/sc2.svg", label="Sample 2", show_label=True, interactive=False, height=
|
131 |
|
132 |
with gr.TabItem("Radial Diagram"):
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
145 |
|
146 |
submit_btn_rd.click(
|
147 |
fn=generate_radial_diagram,
|
148 |
inputs=[json_input_rd, output_format_radio],
|
149 |
outputs=output_rd
|
150 |
)
|
151 |
-
|
152 |
-
gr.Markdown("##
|
153 |
with gr.Row():
|
154 |
-
gr.Image(value="./images/rd1.svg", label="Sample 1", show_label=True, interactive=False, height=
|
155 |
-
gr.Image(value="./images/rd2.svg", label="Sample 2", show_label=True, interactive=False, height=
|
156 |
with gr.Row():
|
157 |
-
gr.Image(value="./images/rd3.svg", label="Sample
|
158 |
-
gr.Image(value="./images/rd4.svg", label="Sample
|
159 |
|
160 |
with gr.TabItem("Process Flow"):
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
|
|
|
|
173 |
|
174 |
submit_btn_pf.click(
|
175 |
fn=generate_process_flow_diagram,
|
176 |
inputs=[json_input_pf, output_format_radio],
|
177 |
outputs=output_pf
|
178 |
)
|
179 |
-
|
180 |
-
gr.Markdown("##
|
181 |
with gr.Row():
|
182 |
-
gr.Image(value="./images/pf1.svg", label="Sample 1", show_label=True, interactive=False, height=
|
183 |
-
gr.Image(value="./images/pf2.svg", label="Sample 2", show_label=True, interactive=False, height=
|
184 |
|
185 |
with gr.TabItem("WBS Diagram"):
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
|
|
|
|
|
|
|
|
|
|
198 |
|
199 |
submit_btn_wbs.click(
|
200 |
fn=generate_wbs_diagram,
|
201 |
inputs=[json_input_wbs, output_format_radio],
|
202 |
outputs=output_wbs
|
203 |
)
|
204 |
-
|
205 |
-
gr.Markdown("##
|
206 |
with gr.Row():
|
207 |
-
gr.Image(value="./images/wd1.svg", label="Sample 1", show_label=True, interactive=False, height=
|
208 |
-
gr.Image(value="./images/wd2.svg", label="Sample 2", show_label=True, interactive=False, height=
|
209 |
|
210 |
demo.launch(
|
211 |
mcp_server=True,
|
212 |
share=False,
|
213 |
server_port=7860,
|
214 |
server_name="0.0.0.0"
|
215 |
-
)
|
216 |
-
|
|
|
25 |
.gr-button {
|
26 |
border-radius: 8px;
|
27 |
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
28 |
+
background-color: #FFA500;
|
29 |
color: white;
|
30 |
padding: 10px 20px;
|
31 |
font-size: 1.1em;
|
32 |
}
|
33 |
.gr-button:hover {
|
34 |
+
background-color: #FF8C00;
|
35 |
}
|
36 |
.gr-textbox {
|
37 |
border-radius: 8px;
|
38 |
padding: 10px;
|
39 |
}
|
40 |
+
/* Dark mode styles */
|
41 |
.gradio-container.dark {
|
42 |
--tw-bg-opacity: 1;
|
43 |
background-color: rgb(24 24 27 / var(--tw-bg-opacity));
|
44 |
+
color: #d4d4d8;
|
45 |
}
|
46 |
.gradio-container.dark .gr-textbox {
|
47 |
background-color: rgb(39 39 42 / var(--tw-bg-opacity));
|
48 |
color: #d4d4d8;
|
49 |
+
border-color: #52525b;
|
50 |
}
|
51 |
.gradio-container.dark .gr-tab-item {
|
52 |
color: #d4d4d8;
|
|
|
67 |
)
|
68 |
|
69 |
with gr.Row(variant="panel"):
|
|
|
70 |
output_format_radio = gr.Radio(
|
71 |
choices=["png", "svg"],
|
72 |
value="png",
|
73 |
+
label="Output Format",
|
74 |
+
interactive=True
|
|
|
75 |
)
|
76 |
|
|
|
|
|
77 |
with gr.Tabs():
|
78 |
with gr.TabItem("Concept Map"):
|
79 |
+
with gr.Row():
|
80 |
+
with gr.Column(scale=1):
|
81 |
+
json_input_cm = gr.Textbox(
|
82 |
+
value=CONCEPT_MAP_JSON,
|
83 |
+
placeholder="Paste JSON following the documented format",
|
84 |
+
label="JSON Input",
|
85 |
+
lines=20
|
86 |
+
)
|
87 |
+
submit_btn_cm = gr.Button("Generate Concept Map", variant="primary")
|
88 |
+
|
89 |
+
with gr.Column(scale=2):
|
90 |
+
output_cm = gr.Image(
|
91 |
+
label="Generated Diagram",
|
92 |
+
type="filepath",
|
93 |
+
show_download_button=True,
|
94 |
+
height=500
|
95 |
+
)
|
96 |
|
97 |
submit_btn_cm.click(
|
98 |
fn=generate_concept_map,
|
99 |
inputs=[json_input_cm, output_format_radio],
|
100 |
outputs=output_cm
|
101 |
)
|
102 |
+
|
103 |
+
gr.Markdown("## Examples")
|
104 |
with gr.Row():
|
105 |
+
gr.Image(value="./images/cm1.svg", label="Sample 1", show_label=True, interactive=False, height=300)
|
106 |
+
gr.Image(value="./images/cm2.svg", label="Sample 2", show_label=True, interactive=False, height=300)
|
107 |
|
108 |
with gr.TabItem("Synoptic Chart"):
|
109 |
+
with gr.Row():
|
110 |
+
with gr.Column(scale=2):
|
111 |
+
json_input_sc = gr.Textbox(
|
112 |
+
value=SYNOPTIC_CHART_JSON,
|
113 |
+
placeholder="Paste JSON following the documented format",
|
114 |
+
label="JSON Input",
|
115 |
+
lines=20
|
116 |
+
)
|
117 |
+
submit_btn_sc = gr.Button("Generate Synoptic Chart", variant="primary")
|
118 |
+
|
119 |
+
with gr.Column(scale=2):
|
120 |
+
output_sc = gr.Image(
|
121 |
+
label="Generated Diagram",
|
122 |
+
type="filepath",
|
123 |
+
show_download_button=True,
|
124 |
+
height=500
|
125 |
+
)
|
126 |
|
127 |
submit_btn_sc.click(
|
128 |
fn=generate_synoptic_chart,
|
129 |
inputs=[json_input_sc, output_format_radio],
|
130 |
outputs=output_sc
|
131 |
)
|
132 |
+
|
133 |
+
gr.Markdown("## Examples")
|
134 |
with gr.Row():
|
135 |
+
gr.Image(value="./images/sc1.svg", label="Sample 1", show_label=True, interactive=False, height=300)
|
136 |
+
gr.Image(value="./images/sc2.svg", label="Sample 2", show_label=True, interactive=False, height=300)
|
137 |
|
138 |
with gr.TabItem("Radial Diagram"):
|
139 |
+
with gr.Row():
|
140 |
+
with gr.Column(scale=2):
|
141 |
+
json_input_rd = gr.Textbox(
|
142 |
+
value=RADIAL_DIAGRAM_JSON,
|
143 |
+
placeholder="Paste JSON following the documented format",
|
144 |
+
label="JSON Input",
|
145 |
+
lines=20
|
146 |
+
)
|
147 |
+
submit_btn_rd = gr.Button("Generate Radial Diagram", variant="primary")
|
148 |
+
|
149 |
+
with gr.Column(scale=2):
|
150 |
+
output_rd = gr.Image(
|
151 |
+
label="Generated Diagram",
|
152 |
+
type="filepath",
|
153 |
+
show_download_button=True,
|
154 |
+
height=500
|
155 |
+
)
|
156 |
|
157 |
submit_btn_rd.click(
|
158 |
fn=generate_radial_diagram,
|
159 |
inputs=[json_input_rd, output_format_radio],
|
160 |
outputs=output_rd
|
161 |
)
|
162 |
+
|
163 |
+
gr.Markdown("## Examples")
|
164 |
with gr.Row():
|
165 |
+
gr.Image(value="./images/rd1.svg", label="Sample 1", show_label=True, interactive=False, height=250)
|
166 |
+
gr.Image(value="./images/rd2.svg", label="Sample 2", show_label=True, interactive=False, height=250)
|
167 |
with gr.Row():
|
168 |
+
gr.Image(value="./images/rd3.svg", label="Sample 3", show_label=True, interactive=False, height=250)
|
169 |
+
gr.Image(value="./images/rd4.svg", label="Sample 4", show_label=True, interactive=False, height=250)
|
170 |
|
171 |
with gr.TabItem("Process Flow"):
|
172 |
+
with gr.Row():
|
173 |
+
with gr.Column(scale=2):
|
174 |
+
json_input_pf = gr.Textbox(
|
175 |
+
value=PROCESS_FLOW_JSON,
|
176 |
+
placeholder="Paste JSON following the documented format",
|
177 |
+
label="JSON Input",
|
178 |
+
lines=20
|
179 |
+
)
|
180 |
+
submit_btn_pf = gr.Button("Generate Process Flow", variant="primary")
|
181 |
+
|
182 |
+
with gr.Column(scale=2):
|
183 |
+
output_pf = gr.Image(
|
184 |
+
label="Generated Diagram",
|
185 |
+
type="filepath",
|
186 |
+
show_download_button=True,
|
187 |
+
height=500
|
188 |
+
)
|
189 |
|
190 |
submit_btn_pf.click(
|
191 |
fn=generate_process_flow_diagram,
|
192 |
inputs=[json_input_pf, output_format_radio],
|
193 |
outputs=output_pf
|
194 |
)
|
195 |
+
|
196 |
+
gr.Markdown("## Examples")
|
197 |
with gr.Row():
|
198 |
+
gr.Image(value="./images/pf1.svg", label="Sample 1", show_label=True, interactive=False, height=300)
|
199 |
+
gr.Image(value="./images/pf2.svg", label="Sample 2", show_label=True, interactive=False, height=300)
|
200 |
|
201 |
with gr.TabItem("WBS Diagram"):
|
202 |
+
with gr.Row():
|
203 |
+
with gr.Column(scale=2):
|
204 |
+
json_input_wbs = gr.Textbox(
|
205 |
+
value=WBS_DIAGRAM_JSON,
|
206 |
+
placeholder="Paste JSON following the documented format",
|
207 |
+
label="JSON Input",
|
208 |
+
lines=20
|
209 |
+
)
|
210 |
+
submit_btn_wbs = gr.Button("Generate WBS Diagram", variant="primary")
|
211 |
+
|
212 |
+
with gr.Column(scale=2):
|
213 |
+
output_wbs = gr.Image(
|
214 |
+
label="Generated Diagram",
|
215 |
+
type="filepath",
|
216 |
+
show_download_button=True,
|
217 |
+
height=500
|
218 |
+
)
|
219 |
|
220 |
submit_btn_wbs.click(
|
221 |
fn=generate_wbs_diagram,
|
222 |
inputs=[json_input_wbs, output_format_radio],
|
223 |
outputs=output_wbs
|
224 |
)
|
225 |
+
|
226 |
+
gr.Markdown("## Examples")
|
227 |
with gr.Row():
|
228 |
+
gr.Image(value="./images/wd1.svg", label="Sample 1", show_label=True, interactive=False, height=300)
|
229 |
+
gr.Image(value="./images/wd2.svg", label="Sample 2", show_label=True, interactive=False, height=300)
|
230 |
|
231 |
demo.launch(
|
232 |
mcp_server=True,
|
233 |
share=False,
|
234 |
server_port=7860,
|
235 |
server_name="0.0.0.0"
|
236 |
+
)
|
|