Nick088 commited on
Commit
88b3dee
1 Parent(s): 42fddbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +289 -0
app.py CHANGED
@@ -1,8 +1,16 @@
 
1
  import os
2
  import random
3
  import gradio as gr
4
  from groq import Groq
5
 
 
 
 
 
 
 
 
6
  client = Groq(
7
  api_key = os.environ.get("Groq_Api_Key")
8
  )
@@ -50,7 +58,288 @@ additional_inputs = [
50
  gr.Number(precision=0, value=42, label="Seed", info="A starting point to initiate generation, use 0 for random")
51
  ]
52
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  gr.ChatInterface(
 
54
  fn=generate_response,
55
  chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
56
  additional_inputs=additional_inputs,
 
1
+ # imports
2
  import os
3
  import random
4
  import gradio as gr
5
  from groq import Groq
6
 
7
+
8
+ # applio theme imports
9
+ from gradio.themes.base import Base
10
+ from gradio.themes.utils import colors, fonts, sizes
11
+ from typing import Iterable
12
+
13
+
14
  client = Groq(
15
  api_key = os.environ.get("Groq_Api_Key")
16
  )
 
58
  gr.Number(precision=0, value=42, label="Seed", info="A starting point to initiate generation, use 0 for random")
59
  ]
60
 
61
+
62
+ # Applio Theme
63
+ class Applio(Base):
64
+ def __init__(
65
+ self,
66
+ *,
67
+ primary_hue: colors.Color | str = colors.neutral,
68
+ secondary_hue: colors.Color | str = colors.neutral,
69
+ neutral_hue: colors.Color | str = colors.neutral,
70
+ spacing_size: sizes.Size | str = sizes.spacing_md,
71
+ radius_size: sizes.Size | str = sizes.radius_md,
72
+ text_size: sizes.Size | str = sizes.text_lg,
73
+ font: fonts.Font | str | Iterable[fonts.Font | str] = (
74
+ "Syne V",
75
+ fonts.GoogleFont("Syne"),
76
+ "ui-sans-serif",
77
+ "system-ui",
78
+ ),
79
+ font_mono: fonts.Font | str | Iterable[fonts.Font | str] = (
80
+ "ui-monospace",
81
+ fonts.GoogleFont("Nunito Sans"),
82
+ ),
83
+ ):
84
+ super().__init__(
85
+ primary_hue=primary_hue,
86
+ secondary_hue=secondary_hue,
87
+ neutral_hue=neutral_hue,
88
+ spacing_size=spacing_size,
89
+ radius_size=radius_size,
90
+ text_size=text_size,
91
+ font=font,
92
+ font_mono=font_mono,
93
+ )
94
+ self.name = ("Applio",)
95
+ self.secondary_100 = ("#dbeafe",)
96
+ self.secondary_200 = ("#bfdbfe",)
97
+ self.secondary_300 = ("#93c5fd",)
98
+ self.secondary_400 = ("#60a5fa",)
99
+ self.secondary_50 = ("#eff6ff",)
100
+ self.secondary_500 = ("#3b82f6",)
101
+ self.secondary_600 = ("#2563eb",)
102
+ self.secondary_700 = ("#1d4ed8",)
103
+ self.secondary_800 = ("#1e40af",)
104
+ self.secondary_900 = ("#1e3a8a",)
105
+ self.secondary_950 = ("#1d3660",)
106
+
107
+ super().set(
108
+ # Blaise
109
+ background_fill_primary="#110F0F",
110
+ background_fill_primary_dark="#110F0F",
111
+ background_fill_secondary="#110F0F",
112
+ background_fill_secondary_dark="#110F0F",
113
+ block_background_fill="*neutral_800",
114
+ block_background_fill_dark="*neutral_800",
115
+ block_border_color="*border_color_primary",
116
+ block_border_color_dark="*border_color_primary",
117
+ block_border_width="1px",
118
+ block_border_width_dark="1px",
119
+ block_info_text_color="*body_text_color_subdued",
120
+ block_info_text_color_dark="*body_text_color_subdued",
121
+ block_info_text_size="*text_sm",
122
+ block_info_text_weight="400",
123
+ block_label_background_fill="*background_fill_primary",
124
+ block_label_background_fill_dark="*background_fill_secondary",
125
+ block_label_border_color="*border_color_primary",
126
+ block_label_border_color_dark="*border_color_primary",
127
+ block_label_border_width="1px",
128
+ block_label_border_width_dark="1px",
129
+ block_label_margin="0",
130
+ block_label_padding="*spacing_sm *spacing_lg",
131
+ block_label_radius="calc(*radius_lg - 1px) 0 calc(*radius_lg - 1px) 0",
132
+ block_label_right_radius="0 calc(*radius_lg - 1px) 0 calc(*radius_lg - 1px)",
133
+ block_label_shadow="*block_shadow",
134
+ block_label_text_color="*#110F0F",
135
+ block_label_text_color_dark="*#110F0F",
136
+ block_label_text_weight="400",
137
+ block_padding="*spacing_xl",
138
+ block_radius="*radius_md",
139
+ block_shadow="none",
140
+ block_shadow_dark="none",
141
+ block_title_background_fill="rgb(255,255,255)",
142
+ block_title_background_fill_dark="rgb(255,255,255)",
143
+ block_title_border_color="none",
144
+ block_title_border_color_dark="none",
145
+ block_title_border_width="0px",
146
+ block_title_padding="*block_label_padding",
147
+ block_title_radius="*block_label_radius",
148
+ block_title_text_color="#110F0F",
149
+ block_title_text_color_dark="#110F0F",
150
+ block_title_text_size="*text_md",
151
+ block_title_text_weight="600",
152
+ body_background_fill="#110F0F",
153
+ body_background_fill_dark="#110F0F",
154
+ body_text_color="white",
155
+ body_text_color_dark="white",
156
+ body_text_color_subdued="*neutral_400",
157
+ body_text_color_subdued_dark="*neutral_400",
158
+ body_text_size="*text_md",
159
+ body_text_weight="400",
160
+ border_color_accent="*neutral_600",
161
+ border_color_accent_dark="*neutral_600",
162
+ border_color_primary="*neutral_800",
163
+ border_color_primary_dark="*neutral_800",
164
+ button_border_width="*input_border_width",
165
+ button_border_width_dark="*input_border_width",
166
+ button_cancel_background_fill="*button_secondary_background_fill",
167
+ button_cancel_background_fill_dark="*button_secondary_background_fill",
168
+ button_cancel_background_fill_hover="*button_cancel_background_fill",
169
+ button_cancel_background_fill_hover_dark="*button_cancel_background_fill",
170
+ button_cancel_border_color="*button_secondary_border_color",
171
+ button_cancel_border_color_dark="*button_secondary_border_color",
172
+ button_cancel_border_color_hover="*button_cancel_border_color",
173
+ button_cancel_border_color_hover_dark="*button_cancel_border_color",
174
+ button_cancel_text_color="#110F0F",
175
+ button_cancel_text_color_dark="#110F0F",
176
+ button_cancel_text_color_hover="#110F0F",
177
+ button_cancel_text_color_hover_dark="#110F0F",
178
+ button_large_padding="*spacing_lg calc(2 * *spacing_lg)",
179
+ button_large_radius="*radius_lg",
180
+ button_large_text_size="*text_lg",
181
+ button_large_text_weight="600",
182
+ button_primary_background_fill="*primary_600",
183
+ button_primary_background_fill_dark="*primary_600",
184
+ button_primary_background_fill_hover="*primary_500",
185
+ button_primary_background_fill_hover_dark="*primary_500",
186
+ button_primary_border_color="*primary_500",
187
+ button_primary_border_color_dark="*primary_500",
188
+ button_primary_border_color_hover="*primary_400",
189
+ button_primary_border_color_hover_dark="*primary_400",
190
+ button_primary_text_color="white",
191
+ button_primary_text_color_dark="white",
192
+ button_primary_text_color_hover="#110F0F",
193
+ button_primary_text_color_hover_dark="#110F0F",
194
+ button_secondary_background_fill="transparent",
195
+ button_secondary_background_fill_dark="transparent",
196
+ button_secondary_background_fill_hover="*neutral_800",
197
+ button_secondary_background_fill_hover_dark="*neutral_800",
198
+ button_secondary_border_color="*neutral_700",
199
+ button_secondary_border_color_dark="*neutral_700",
200
+ button_secondary_border_color_hover="*neutral_600",
201
+ button_secondary_border_color_hover_dark="*neutral_600",
202
+ button_secondary_text_color="white",
203
+ button_secondary_text_color_dark="white",
204
+ button_secondary_text_color_hover="*button_secondary_text_color",
205
+ button_secondary_text_color_hover_dark="*button_secondary_text_color",
206
+ button_shadow="none",
207
+ button_shadow_active="*shadow_inset",
208
+ button_shadow_hover="none",
209
+ button_small_padding="*spacing_sm calc(2 * *spacing_sm)",
210
+ button_small_radius="*radius_lg",
211
+ button_small_text_size="*text_md",
212
+ button_small_text_weight="400",
213
+ button_transition="0.3s ease all",
214
+ checkbox_background_color="*neutral_700",
215
+ checkbox_background_color_dark="*neutral_700",
216
+ checkbox_background_color_focus="*checkbox_background_color",
217
+ checkbox_background_color_focus_dark="*checkbox_background_color",
218
+ checkbox_background_color_hover="*checkbox_background_color",
219
+ checkbox_background_color_hover_dark="*checkbox_background_color",
220
+ checkbox_background_color_selected="*secondary_600",
221
+ checkbox_background_color_selected_dark="*secondary_600",
222
+ checkbox_border_color="*neutral_700",
223
+ checkbox_border_color_dark="*neutral_700",
224
+ checkbox_border_color_focus="*secondary_500",
225
+ checkbox_border_color_focus_dark="*secondary_500",
226
+ checkbox_border_color_hover="*neutral_600",
227
+ checkbox_border_color_hover_dark="*neutral_600",
228
+ checkbox_border_color_selected="*secondary_600",
229
+ checkbox_border_color_selected_dark="*secondary_600",
230
+ checkbox_border_radius="*radius_sm",
231
+ checkbox_border_width="*input_border_width",
232
+ checkbox_border_width_dark="*input_border_width",
233
+ checkbox_check="url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' 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\")",
234
+ checkbox_label_background_fill="transparent",
235
+ checkbox_label_background_fill_dark="transparent",
236
+ checkbox_label_background_fill_hover="transparent",
237
+ checkbox_label_background_fill_hover_dark="transparent",
238
+ checkbox_label_background_fill_selected="transparent",
239
+ checkbox_label_background_fill_selected_dark="transparent",
240
+ checkbox_label_border_color="transparent",
241
+ checkbox_label_border_color_dark="transparent",
242
+ checkbox_label_border_color_hover="transparent",
243
+ checkbox_label_border_color_hover_dark="transparent",
244
+ checkbox_label_border_width="transparent",
245
+ checkbox_label_border_width_dark="transparent",
246
+ checkbox_label_gap="*spacing_lg",
247
+ checkbox_label_padding="*spacing_md calc(2 * *spacing_md)",
248
+ checkbox_label_shadow="none",
249
+ checkbox_label_text_color="*body_text_color",
250
+ checkbox_label_text_color_dark="*body_text_color",
251
+ checkbox_label_text_color_selected="*checkbox_label_text_color",
252
+ checkbox_label_text_color_selected_dark="*checkbox_label_text_color",
253
+ checkbox_label_text_size="*text_md",
254
+ checkbox_label_text_weight="400",
255
+ checkbox_shadow="*input_shadow",
256
+ color_accent="*primary_500",
257
+ color_accent_soft="*primary_50",
258
+ color_accent_soft_dark="*neutral_700",
259
+ container_radius="*radius_xl",
260
+ embed_radius="*radius_lg",
261
+ error_background_fill="*background_fill_primary",
262
+ error_background_fill_dark="*background_fill_primary",
263
+ error_border_color="*border_color_primary",
264
+ error_border_color_dark="*border_color_primary",
265
+ error_border_width="1px",
266
+ error_border_width_dark="1px",
267
+ error_text_color="#ef4444",
268
+ error_text_color_dark="#ef4444",
269
+ form_gap_width="0px",
270
+ input_background_fill="*neutral_900",
271
+ input_background_fill_dark="*neutral_900",
272
+ input_background_fill_focus="*secondary_600",
273
+ input_background_fill_focus_dark="*secondary_600",
274
+ input_background_fill_hover="*input_background_fill",
275
+ input_background_fill_hover_dark="*input_background_fill",
276
+ input_border_color="*neutral_700",
277
+ input_border_color_dark="*neutral_700",
278
+ input_border_color_focus="*secondary_600",
279
+ input_border_color_focus_dark="*primary_600",
280
+ input_border_color_hover="*input_border_color",
281
+ input_border_color_hover_dark="*input_border_color",
282
+ input_border_width="1px",
283
+ input_border_width_dark="1px",
284
+ input_padding="*spacing_xl",
285
+ input_placeholder_color="*neutral_500",
286
+ input_placeholder_color_dark="*neutral_500",
287
+ input_radius="*radius_lg",
288
+ input_shadow="none",
289
+ input_shadow_dark="none",
290
+ input_shadow_focus="*input_shadow",
291
+ input_shadow_focus_dark="*input_shadow",
292
+ input_text_size="*text_md",
293
+ input_text_weight="400",
294
+ layout_gap="*spacing_xxl",
295
+ link_text_color="*secondary_500",
296
+ link_text_color_active="*secondary_500",
297
+ link_text_color_active_dark="*secondary_500",
298
+ link_text_color_dark="*secondary_500",
299
+ link_text_color_hover="*secondary_400",
300
+ link_text_color_hover_dark="*secondary_400",
301
+ link_text_color_visited="*secondary_600",
302
+ link_text_color_visited_dark="*secondary_600",
303
+ loader_color="*color_accent",
304
+ loader_color_dark="*color_accent",
305
+ panel_background_fill="*background_fill_secondary",
306
+ panel_background_fill_dark="*background_fill_secondary",
307
+ panel_border_color="*border_color_primary",
308
+ panel_border_color_dark="*border_color_primary",
309
+ panel_border_width="1px",
310
+ panel_border_width_dark="1px",
311
+ prose_header_text_weight="600",
312
+ prose_text_size="*text_md",
313
+ prose_text_weight="400",
314
+ radio_circle="url(\"data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='8' cy='8' r='3'/%3e%3c/svg%3e\")",
315
+ section_header_text_size="*text_md",
316
+ section_header_text_weight="400",
317
+ shadow_drop="rgba(0,0,0,0.05) 0px 1px 2px 0px",
318
+ shadow_drop_lg="0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)",
319
+ shadow_inset="rgba(0,0,0,0.05) 0px 2px 4px 0px inset",
320
+ shadow_spread="3px",
321
+ shadow_spread_dark="1px",
322
+ slider_color="#9E9E9E",
323
+ slider_color_dark="#9E9E9E",
324
+ stat_background_fill="*primary_500",
325
+ stat_background_fill_dark="*primary_500",
326
+ table_border_color="*neutral_700",
327
+ table_border_color_dark="*neutral_700",
328
+ table_even_background_fill="*neutral_950",
329
+ table_even_background_fill_dark="*neutral_950",
330
+ table_odd_background_fill="*neutral_900",
331
+ table_odd_background_fill_dark="*neutral_900",
332
+ table_radius="*radius_lg",
333
+ table_row_focus="*color_accent_soft",
334
+ table_row_focus_dark="*color_accent_soft",
335
+ )
336
+
337
+
338
+ applio = Applio()
339
+
340
+
341
  gr.ChatInterface(
342
+ theme=applio,
343
  fn=generate_response,
344
  chatbot=gr.Chatbot(show_label=False, show_share_button=False, show_copy_button=True, likeable=True, layout="panel"),
345
  additional_inputs=additional_inputs,