Nymbo commited on
Commit
ecdc76d
·
verified ·
1 Parent(s): 9a0a8f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +151 -292
app.py CHANGED
@@ -1,292 +1,151 @@
1
- {
2
- "theme": {
3
- "_font": [
4
- {"__gradio_font__": true, "name": "Inter", "class": "google"},
5
- {"__gradio_font__": true, "name": "ui-sans-serif", "class": "font"},
6
- {"__gradio_font__": true, "name": "system-ui", "class": "font"},
7
- {"__gradio_font__": true, "name": "sans-serif", "class": "font"}
8
- ],
9
- "_font_mono": [
10
- {"__gradio_font__": true, "name": "JetBrains Mono", "class": "google"},
11
- {"__gradio_font__": true, "name": "ui-monospace", "class": "font"},
12
- {"__gradio_font__": true, "name": "Consolas", "class": "font"},
13
- {"__gradio_font__": true, "name": "monospace", "class": "font"}
14
- ],
15
- "_stylesheets": [
16
- "https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap",
17
- "https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600&display=swap"
18
- ],
19
- "background_fill_primary": "#0b0f19",
20
- "background_fill_primary_dark": "#0b0f19",
21
- "background_fill_secondary": "#161b22",
22
- "background_fill_secondary_dark": "#161b22",
23
- "block_background_fill": "*background_fill_primary",
24
- "block_background_fill_dark": "*background_fill_secondary",
25
- "block_border_color": "#30363d",
26
- "block_border_color_dark": "#30363d",
27
- "block_border_width": "1px",
28
- "block_border_width_dark": "1px",
29
- "block_info_text_color": "#8b949e",
30
- "block_info_text_color_dark": "#8b949e",
31
- "block_info_text_size": "*text_sm",
32
- "block_info_text_weight": "400",
33
- "block_label_background_fill": "*background_fill_primary",
34
- "block_label_background_fill_dark": "*background_fill_secondary",
35
- "block_label_border_color": "#30363d",
36
- "block_label_border_color_dark": "#30363d",
37
- "block_label_border_width": "1px",
38
- "block_label_border_width_dark": "1px",
39
- "block_label_margin": "0",
40
- "block_label_padding": "*spacing_sm *spacing_lg",
41
- "block_label_radius": "calc(*radius_lg - 1px) 0 calc(*radius_lg - 1px) 0",
42
- "block_label_right_radius": "0 calc(*radius_lg - 1px) 0 calc(*radius_lg - 1px)",
43
- "block_label_shadow": "none",
44
- "block_label_text_color": "#c9d1d9",
45
- "block_label_text_color_dark": "#c9d1d9",
46
- "block_label_text_size": "*text_sm",
47
- "block_label_text_weight": "600",
48
- "block_padding": "*spacing_md calc(*spacing_md + 2px)",
49
- "block_radius": "*radius_md",
50
- "block_shadow": "none",
51
- "block_shadow_dark": "none",
52
- "block_title_background_fill": "none",
53
- "block_title_background_fill_dark": "none",
54
- "block_title_border_color": "none",
55
- "block_title_border_color_dark": "none",
56
- "block_title_border_width": "0px",
57
- "block_title_border_width_dark": "0px",
58
- "block_title_padding": "0",
59
- "block_title_radius": "*radius_md",
60
- "block_title_text_color": "#c9d1d9",
61
- "block_title_text_color_dark": "#c9d1d9",
62
- "block_title_text_size": "*text_md",
63
- "block_title_text_weight": "600",
64
- "body_background_fill": "*background_fill_primary",
65
- "body_background_fill_dark": "*background_fill_primary",
66
- "body_text_color": "#c9d1d9",
67
- "body_text_color_dark": "#c9d1d9",
68
- "body_text_color_subdued": "#8b949e",
69
- "body_text_color_subdued_dark": "#8b949e",
70
- "body_text_size": "*text_md",
71
- "body_text_weight": "400",
72
- "border_color_accent": "#77f7d1",
73
- "border_color_accent_dark": "#77f7d1",
74
- "border_color_primary": "#30363d",
75
- "border_color_primary_dark": "#30363d",
76
- "button_border_width": "*input_border_width",
77
- "button_border_width_dark": "*input_border_width",
78
- "button_cancel_background_fill": "#21262d",
79
- "button_cancel_background_fill_dark": "#21262d",
80
- "button_cancel_background_fill_hover": "#30363d",
81
- "button_cancel_background_fill_hover_dark": "#30363d",
82
- "button_cancel_border_color": "#30363d",
83
- "button_cancel_border_color_dark": "#30363d",
84
- "button_cancel_border_color_hover": "#8b949e",
85
- "button_cancel_border_color_hover_dark": "#8b949e",
86
- "button_cancel_text_color": "#24292f",
87
- "button_cancel_text_color_dark": "#c9d1d9",
88
- "button_cancel_text_color_hover": "#c9d1d9",
89
- "button_cancel_text_color_hover_dark": "#c9d1d9",
90
- "button_large_padding": "*spacing_md calc(2 * *spacing_md)",
91
- "button_large_radius": "*radius_md",
92
- "button_large_text_size": "*text_lg",
93
- "button_large_text_weight": "600",
94
- "button_primary_background_fill": "#3dd49f",
95
- "button_primary_background_fill_dark": "#3dd49f",
96
- "button_primary_background_fill_hover": "#55fac0",
97
- "button_primary_background_fill_hover_dark": "#55fac0",
98
- "button_primary_border_color": "#77f7d1",
99
- "button_primary_border_color_dark": "#77f7d1",
100
- "button_primary_border_color_hover": "#77f7d1",
101
- "button_primary_border_color_hover_dark": "#77f7d1",
102
- "button_primary_text_color": "white",
103
- "button_primary_text_color_dark": "white",
104
- "button_primary_text_color_hover": "white",
105
- "button_primary_text_color_hover_dark": "white",
106
- "button_secondary_background_fill": "#21262d",
107
- "button_secondary_background_fill_dark": "#21262d",
108
- "button_secondary_background_fill_hover": "#30363d",
109
- "button_secondary_background_fill_hover_dark": "#30363d",
110
- "button_secondary_border_color": "#30363d",
111
- "button_secondary_border_color_dark": "#30363d",
112
- "button_secondary_border_color_hover": "#8b949e",
113
- "button_secondary_border_color_hover_dark": "#8b949e",
114
- "button_secondary_text_color": "#c9d1d9",
115
- "button_secondary_text_color_dark": "#c9d1d9",
116
- "button_secondary_text_color_hover": "#c9d1d9",
117
- "button_secondary_text_color_hover_dark": "#c9d1d9",
118
- "button_shadow": "none",
119
- "button_shadow_active": "none",
120
- "button_shadow_hover": "none",
121
- "button_small_padding": "*spacing_sm calc(2 * *spacing_sm)",
122
- "button_small_radius": "*radius_md",
123
- "button_small_text_size": "*text_md",
124
- "button_small_text_weight": "400",
125
- "button_transition": "none",
126
- "chatbot_code_background_color": "*background_fill_secondary",
127
- "chatbot_code_background_color_dark": "*background_fill_secondary",
128
- "checkbox_background_color": "*background_fill_primary",
129
- "checkbox_background_color_dark": "*background_fill_secondary",
130
- "checkbox_background_color_focus": "*checkbox_background_color",
131
- "checkbox_background_color_focus_dark": "*checkbox_background_color",
132
- "checkbox_background_color_hover": "*checkbox_background_color",
133
- "checkbox_background_color_hover_dark": "*checkbox_background_color",
134
- "checkbox_background_color_selected": "*border_color_accent",
135
- "checkbox_background_color_selected_dark": "*border_color_accent",
136
- "checkbox_border_color": "#30363d",
137
- "checkbox_border_color_dark": "#30363d",
138
- "checkbox_border_color_focus": "#41b883",
139
- "checkbox_border_color_focus_dark": "#41b883",
140
- "checkbox_border_color_hover": "#30363d",
141
- "checkbox_border_color_hover_dark": "#30363d",
142
- "checkbox_border_color_selected": "#41b883",
143
- "checkbox_border_color_selected_dark": "#41b883",
144
- "checkbox_border_radius": "*radius_md",
145
- "checkbox_border_width": "1px",
146
- "checkbox_border_width_dark": "1px",
147
- "checkbox_check": "url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='%230d1117' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e\")",
148
- "checkbox_label_background_fill": "*background_fill_primary",
149
- "checkbox_label_background_fill_dark": "*background_fill_secondary",
150
- "checkbox_label_background_fill_hover": "#1c2128",
151
- "checkbox_label_background_fill_hover_dark": "#1c2128",
152
- "checkbox_label_background_fill_selected": "*checkbox_label_background_fill",
153
- "checkbox_label_background_fill_selected_dark": "*checkbox_label_background_fill",
154
- "checkbox_label_border_color": "#30363d",
155
- "checkbox_label_border_color_dark": "#30363d",
156
- "checkbox_label_border_width": "1px",
157
- "checkbox_label_border_width_dark": "1px",
158
- "checkbox_label_gap": "*spacing_lg",
159
- "checkbox_label_padding": "*spacing_md calc(2 * *spacing_md)",
160
- "checkbox_label_shadow": "none",
161
- "checkbox_label_text_color": "#c9d1d9",
162
- "checkbox_label_text_color_dark": "#c9d1d9",
163
- "checkbox_label_text_color_selected": "#41b883",
164
- "checkbox_label_text_color_selected_dark": "#41b883",
165
- "checkbox_label_text_size": "*text_md",
166
- "checkbox_label_text_weight": "400",
167
- "checkbox_shadow": "none",
168
- "color_accent": "#11ba88",
169
- "color_accent_soft": "#2a4a42",
170
- "color_accent_soft_dark": "#2a4a42",
171
- "container_radius": "*radius_md",
172
- "embed_radius": "*radius_md",
173
- "error_background_fill": "#0d1117",
174
- "error_background_fill_dark": "#0d1117",
175
- "error_border_color": "#b31d28",
176
- "error_border_color_dark": "#b31d28",
177
- "error_border_width": "1px",
178
- "error_border_width_dark": "1px",
179
- "error_text_color": "#f97583",
180
- "error_text_color_dark": "#f97583",
181
- "font": "'Inter', 'ui-sans-serif', 'system-ui', sans-serif",
182
- "font_mono": "'JetBrains Mono', 'ui-monospace', 'Consolas', monospace",
183
- "form_gap_width": "1px",
184
- "input_background_fill": "#0d1117",
185
- "input_background_fill_dark": "#0d1117",
186
- "input_background_fill_focus": "#161b22",
187
- "input_background_fill_focus_dark": "#161b22",
188
- "input_background_fill_hover": "#0d1117",
189
- "input_background_fill_hover_dark": "#0d1117",
190
- "input_border_color": "#30363d",
191
- "input_border_color_dark": "#30363d",
192
- "input_border_color_focus": "#41b883",
193
- "input_border_color_focus_dark": "#41b883",
194
- "input_border_color_hover": "#30363d",
195
- "input_border_color_hover_dark": "#30363d",
196
- "input_border_width": "1px",
197
- "input_border_width_dark": "1px",
198
- "input_padding": "*spacing_md",
199
- "input_placeholder_color": "#8b949e",
200
- "input_placeholder_color_dark": "#8b949e",
201
- "input_radius": "*radius_md",
202
- "input_shadow": "none",
203
- "input_shadow_dark": "none",
204
- "input_shadow_focus": "none",
205
- "input_shadow_focus_dark": "none",
206
- "input_text_size": "*text_md",
207
- "input_text_weight": "400",
208
- "layout_gap": "*spacing_xl",
209
- "link_text_color": "#11ba88",
210
- "link_text_color_active": "#41b883",
211
- "link_text_color_active_dark": "#41b883",
212
- "link_text_color_dark": "#41b883",
213
- "link_text_color_hover": "#41b883",
214
- "link_text_color_hover_dark": "#41b883",
215
- "link_text_color_visited": "#41b883",
216
- "link_text_color_visited_dark": "#41b883",
217
- "loader_color": "*color_accent",
218
- "loader_color_dark": "*color_accent",
219
- "name": "Nymbo_Theme",
220
- "neutral_100": "#f0f3f6",
221
- "neutral_200": "#d0d7de",
222
- "neutral_300": "#d0d7de",
223
- "neutral_400": "#57606a",
224
- "neutral_50": "#f6f8fa",
225
- "neutral_500": "#24292f",
226
- "neutral_600": "#57606a",
227
- "neutral_700": "#57606a",
228
- "neutral_800": "#24292f",
229
- "neutral_900": "#0d1117",
230
- "neutral_950": "#0d1117",
231
- "panel_background_fill": "*background_fill_secondary",
232
- "panel_background_fill_dark": "*background_fill_secondary",
233
- "panel_border_color": "#30363d",
234
- "panel_border_color_dark": "#30363d",
235
- "panel_border_width": "0",
236
- "panel_border_width_dark": "0",
237
- "primary_100": "#11ba88",
238
- "primary_200": "#11ba88",
239
- "primary_300": "#11ba88",
240
- "primary_400": "#11ba88",
241
- "primary_50": "#f1f8ff",
242
- "primary_500": "#11ba88",
243
- "primary_600": "#11ba88",
244
- "primary_700": "#11ba88",
245
- "primary_800": "#11ba88",
246
- "primary_900": "#11ba88",
247
- "primary_950": "#11ba88",
248
- "prose_header_text_weight": "600",
249
- "prose_text_size": "*text_md",
250
- "prose_text_weight": "400",
251
- "radio_circle": "url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='%23ffffff' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e\")",
252
- "radius_lg": "10px",
253
- "radius_md": "6px",
254
- "radius_sm": "4px",
255
- "radius_xl": "12px",
256
- "radius_xs": "2px",
257
- "radius_xxl": "16px",
258
- "radius_xxs": "1px",
259
- "secondary_100": "#f0f6fc",
260
- "secondary_200": "#c9d1d9",
261
- "secondary_300": "#b1bac4",
262
- "secondary_400": "#8b949e",
263
- "secondary_50": "#f8fafd",
264
- "secondary_500": "#6e7681",
265
- "secondary_600": "#484f58",
266
- "secondary_700": "#30363d",
267
- "secondary_800": "#21262d",
268
- "secondary_900": "#161b22",
269
- "secondary_950": "#0d1117",
270
- "section_header_text_size": "*text_md",
271
- "section_header_text_weight": "600",
272
- "shadow_drop": "none",
273
- "shadow_drop_lg": "none",
274
- "shadow_inset": "none",
275
- "shadow_spread": "0",
276
- "shadow_spread_dark": "0",
277
- "slider_color": "#41b883",
278
- "slider_color_dark": "#41b883",
279
- "stat_background_fill": "*color_accent_soft",
280
- "stat_background_fill_dark": "*color_accent_soft",
281
- "table_border_color": "#30363d",
282
- "table_border_color_dark": "#30363d",
283
- "table_even_background_fill": "#0d1117",
284
- "table_even_background_fill_dark": "#0d1117",
285
- "table_odd_background_fill": "#161b22",
286
- "table_odd_background_fill_dark": "#161b22",
287
- "table_radius": "*radius_md",
288
- "table_row_focus": "*color_accent_soft",
289
- "table_row_focus_dark": "*color_accent_soft",
290
- "version": "1.0"
291
- }
292
- }
 
1
+ import time
2
+
3
+ import gradio as gr
4
+ from gradio.themes.utils.theme_dropdown import create_theme_dropdown
5
+
6
+ dropdown, js = create_theme_dropdown()
7
+
8
+ with gr.Blocks() as demo:
9
+ with gr.Row(equal_height=True):
10
+ with gr.Column(scale=10):
11
+ gr.Markdown(
12
+ """
13
+ # Theme preview: `Nymbo_Theme`
14
+ To use this theme, set `theme='Nymbo/Nymbo_Theme'` in `gr.Blocks()` or `gr.Interface()`.
15
+ You can append an `@` and a semantic version expression, e.g. @>=1.0.0,<2.0.0 to pin to a given version
16
+ of this theme.
17
+ """
18
+ )
19
+ with gr.Column(scale=3):
20
+ with gr.Group():
21
+ dropdown.render()
22
+ toggle_dark = gr.Button(value="Toggle Dark")
23
+
24
+ dropdown.change(None, dropdown, None, js=js)
25
+ toggle_dark.click(
26
+ None,
27
+ js="""
28
+ () => {
29
+ document.body.classList.toggle('dark');
30
+ }
31
+ """,
32
+ )
33
+
34
+ name = gr.Textbox(
35
+ label="Name",
36
+ info="Full name, including middle name. No special characters.",
37
+ placeholder="John Doe",
38
+ value="John Doe",
39
+ interactive=True,
40
+ )
41
+
42
+ with gr.Row():
43
+ slider1 = gr.Slider(label="Slider 1")
44
+ slider2 = gr.Slider(label="Slider 2")
45
+ gr.CheckboxGroup(["A", "B", "C"], label="Checkbox Group")
46
+
47
+ with gr.Row():
48
+ with gr.Column(variant="panel", scale=1):
49
+ gr.Markdown("## Panel 1")
50
+ radio = gr.Radio(
51
+ ["A", "B", "C"],
52
+ label="Radio",
53
+ info="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",
54
+ )
55
+ drop = gr.Dropdown(["Option 1", "Option 2", "Option 3"], show_label=False)
56
+ drop_2 = gr.Dropdown(
57
+ ["Option A", "Option B", "Option C"],
58
+ multiselect=True,
59
+ value=["Option A"],
60
+ label="Dropdown",
61
+ interactive=True,
62
+ )
63
+ check = gr.Checkbox(label="Go")
64
+ with gr.Column(variant="panel", scale=2):
65
+ img = gr.Image(
66
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpg",
67
+ label="Image",
68
+ height=320,
69
+ )
70
+ with gr.Row():
71
+ go_btn = gr.Button("Go", variant="primary")
72
+ clear_btn = gr.Button("Clear", variant="secondary")
73
+
74
+ def go(*args):
75
+ time.sleep(3)
76
+ return "https://gradio-static-files.s3.us-west-2.amazonaws.com/header-image.jpgjpg"
77
+
78
+ go_btn.click(go, [radio, drop, drop_2, check, name], img, api_name="go")
79
+
80
+ def clear():
81
+ time.sleep(0.2)
82
+ return None
83
+
84
+ clear_btn.click(clear, None, img)
85
+
86
+ with gr.Row():
87
+ btn1 = gr.Button("Button 1", size="sm")
88
+ btn2 = gr.UploadButton(size="sm")
89
+ stop_btn = gr.Button("Stop", size="sm", variant="stop")
90
+
91
+ with gr.Row():
92
+ gr.Dataframe(value=[[1, 2, 3], [4, 5, 6], [7, 8, 9]], label="Dataframe")
93
+ gr.JSON(
94
+ value={"a": 1, "b": 2, "c": {"test": "a", "test2": [1, 2, 3]}}, label="JSON"
95
+ )
96
+ gr.Label(value={"cat": 0.7, "dog": 0.2, "fish": 0.1})
97
+ gr.File()
98
+ with gr.Row():
99
+ gr.ColorPicker()
100
+ gr.Video("https://gradio-static-files.s3.us-west-2.amazonaws.com/world.mp4")
101
+ gr.Gallery(
102
+ [
103
+ (
104
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/lion.jpg",
105
+ "lion",
106
+ ),
107
+ (
108
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/logo.png",
109
+ "logo",
110
+ ),
111
+ (
112
+ "https://gradio-static-files.s3.us-west-2.amazonaws.com/tower.jpg",
113
+ "tower",
114
+ ),
115
+ ],
116
+ height=200,
117
+ )
118
+
119
+ with gr.Row():
120
+ with gr.Column(scale=2):
121
+ chatbot = gr.Chatbot(
122
+ value=[
123
+ {"role": "user", "content": "Hello"},
124
+ {"role": "assistant", "content": "Hi"}
125
+ ],
126
+ label="Chatbot"
127
+ )
128
+ chat_btn = gr.Button("Add messages")
129
+
130
+ def chat(history):
131
+ time.sleep(2)
132
+ return history + [
133
+ {"role": "user", "content": "How are you?"},
134
+ {"role": "assistant", "content": "I am good."}
135
+ ]
136
+
137
+ chat_btn.click(
138
+ chat,
139
+ chatbot,
140
+ chatbot,
141
+ )
142
+ with gr.Column(scale=1):
143
+ with gr.Accordion("Advanced Settings"):
144
+ gr.Markdown("Hello")
145
+ gr.Number(label="Chatbot control 1")
146
+ gr.Number(label="Chatbot control 2")
147
+ gr.Number(label="Chatbot control 3")
148
+
149
+
150
+ if __name__ == "__main__":
151
+ demo.queue().launch(theme='Nymbo/Nymbo_Theme')