Spaces:
Running
Running
Add themes
Browse files
app.py
CHANGED
@@ -3,6 +3,7 @@ import datetime
|
|
3 |
from openai import OpenAI
|
4 |
import gradio as gr
|
5 |
|
|
|
6 |
from utils import COMMUNITY_POSTFIX_URL, get_model_config, log_message, check_format, models_config
|
7 |
|
8 |
MODEL_TEMPERATURE = 0.8
|
@@ -154,7 +155,13 @@ def chat_fn(message, history):
|
|
154 |
title = None
|
155 |
description = None
|
156 |
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
gr.HTML("""
|
159 |
<style>
|
160 |
.html-container:has(.css-styles) {
|
|
|
3 |
from openai import OpenAI
|
4 |
import gradio as gr
|
5 |
|
6 |
+
from theme import apriel
|
7 |
from utils import COMMUNITY_POSTFIX_URL, get_model_config, log_message, check_format, models_config
|
8 |
|
9 |
MODEL_TEMPERATURE = 0.8
|
|
|
155 |
title = None
|
156 |
description = None
|
157 |
|
158 |
+
# theme = gr.themes.Default(primary_hue="green")
|
159 |
+
# theme = gr.themes.Soft(primary_hue="gray", secondary_hue="slate", neutral_hue="slate",
|
160 |
+
# text_size=gr.themes.sizes.text_lg, font=[gr.themes.GoogleFont("Inconsolata"), "Arial", "sans-serif"])
|
161 |
+
# theme = gr.Theme.from_hub("earneleh/paris")
|
162 |
+
theme = apriel
|
163 |
+
|
164 |
+
with gr.Blocks(theme=theme) as demo:
|
165 |
gr.HTML("""
|
166 |
<style>
|
167 |
.html-container:has(.css-styles) {
|
theme.py
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# from __future__ import annotations
|
2 |
+
from typing import Iterable
|
3 |
+
import gradio as gr
|
4 |
+
from gradio.themes import Soft
|
5 |
+
# from gradio.themes.base import Base
|
6 |
+
from gradio.themes.utils import colors, fonts, sizes
|
7 |
+
import time
|
8 |
+
|
9 |
+
|
10 |
+
class Apriel(Soft):
|
11 |
+
def __init__(
|
12 |
+
self,
|
13 |
+
*,
|
14 |
+
primary_hue: colors.Color | str = colors.gray,
|
15 |
+
secondary_hue: colors.Color | str = colors.slate,
|
16 |
+
neutral_hue: colors.Color | str = colors.gray,
|
17 |
+
# spacing_size: sizes.Size | str = sizes.spacing_md,
|
18 |
+
# radius_size: sizes.Size | str = sizes.radius_md,
|
19 |
+
text_size: sizes.Size | str = sizes.text_md,
|
20 |
+
font: fonts.Font
|
21 |
+
| str
|
22 |
+
| Iterable[fonts.Font | str] = (
|
23 |
+
fonts.GoogleFont("Inconsolata"),
|
24 |
+
"Arial",
|
25 |
+
"sans-serif",
|
26 |
+
),
|
27 |
+
font_mono: fonts.Font
|
28 |
+
| str
|
29 |
+
| Iterable[fonts.Font | str] = (
|
30 |
+
fonts.GoogleFont("IBM Plex Mono"),
|
31 |
+
"ui-monospace",
|
32 |
+
"monospace",
|
33 |
+
),
|
34 |
+
):
|
35 |
+
super().__init__(
|
36 |
+
primary_hue=primary_hue,
|
37 |
+
secondary_hue=secondary_hue,
|
38 |
+
neutral_hue=neutral_hue,
|
39 |
+
# spacing_size=spacing_size,
|
40 |
+
# radius_size=radius_size,
|
41 |
+
text_size=text_size,
|
42 |
+
font=font,
|
43 |
+
font_mono=font_mono,
|
44 |
+
)
|
45 |
+
super().set(
|
46 |
+
body_background_fill="linear-gradient(135deg, *primary_200, *secondary_300)",
|
47 |
+
body_background_fill_dark="linear-gradient(135deg, *primary_900, *secondary_800)",
|
48 |
+
button_primary_background_fill="linear-gradient(90deg, *primary_400, *secondary_600)",
|
49 |
+
button_primary_background_fill_hover="linear-gradient(90deg, *primary_200, *secondary_300)",
|
50 |
+
button_primary_text_color="white",
|
51 |
+
button_primary_text_color_hover="black",
|
52 |
+
button_primary_background_fill_dark="linear-gradient(90deg, *primary_500, *secondary_600)",
|
53 |
+
|
54 |
+
button_secondary_text_color="black",
|
55 |
+
button_secondary_text_color_hover="white",
|
56 |
+
button_secondary_background_fill="linear-gradient(90deg, *primary_200, *secondary_300)",
|
57 |
+
button_secondary_background_fill_hover="linear-gradient(90deg, *secondary_400, *secondary_500)",
|
58 |
+
button_secondary_background_fill_dark="linear-gradient(90deg, *secondary_500, *secondary_600)",
|
59 |
+
|
60 |
+
slider_color="*secondary_300",
|
61 |
+
slider_color_dark="*secondary_600",
|
62 |
+
block_title_text_weight="600",
|
63 |
+
block_border_width="3px",
|
64 |
+
block_shadow="*shadow_drop_lg",
|
65 |
+
button_primary_shadow="*shadow_drop_lg",
|
66 |
+
button_large_padding="11px",
|
67 |
+
|
68 |
+
color_accent_soft="*primary_100",
|
69 |
+
)
|
70 |
+
|
71 |
+
|
72 |
+
apriel = Apriel()
|
73 |
+
|
74 |
+
with gr.Blocks(theme=apriel) as demo:
|
75 |
+
textbox = gr.Textbox(label="Name")
|
76 |
+
slider = gr.Slider(label="Count", minimum=0, maximum=100, step=1)
|
77 |
+
with gr.Row():
|
78 |
+
button = gr.Button("Submit", variant="primary")
|
79 |
+
clear = gr.Button("Clear")
|
80 |
+
output = gr.Textbox(label="Output")
|
81 |
+
|
82 |
+
|
83 |
+
def repeat(name, count):
|
84 |
+
time.sleep(3)
|
85 |
+
return name * count
|
86 |
+
|
87 |
+
|
88 |
+
button.click(repeat, [textbox, slider], output)
|
89 |
+
|
90 |
+
if __name__ == "__main__":
|
91 |
+
demo.launch()
|