MZhaovo commited on
Commit
9bfafbf
1 Parent(s): 6bb9d92

定义主题移动到`presets.py`

Browse files
Files changed (2) hide show
  1. ChuanhuChatbot.py +1 -63
  2. modules/presets.py +62 -0
ChuanhuChatbot.py CHANGED
@@ -57,69 +57,7 @@ PromptHelper.compact_text_chunks = compact_text_chunks
57
  with open("assets/custom.css", "r", encoding="utf-8") as f:
58
  customCSS = f.read()
59
 
60
- with gr.Blocks(
61
- css=customCSS,
62
- theme=gr.themes.Soft(
63
- primary_hue=gr.themes.Color(
64
- c50="#02C160",
65
- c100="rgba(2, 193, 96, 0.2)",
66
- c200="#02C160",
67
- c300="rgba(2, 193, 96, 0.32)",
68
- c400="rgba(2, 193, 96, 0.32)",
69
- c500="rgba(2, 193, 96, 1.0)",
70
- c600="rgba(2, 193, 96, 1.0)",
71
- c700="rgba(2, 193, 96, 0.32)",
72
- c800="rgba(2, 193, 96, 0.32)",
73
- c900="#02C160",
74
- c950="#02C160",
75
- ),
76
- secondary_hue=gr.themes.Color(
77
- c50="#576b95",
78
- c100="#576b95",
79
- c200="#576b95",
80
- c300="#576b95",
81
- c400="#576b95",
82
- c500="#576b95",
83
- c600="#576b95",
84
- c700="#576b95",
85
- c800="#576b95",
86
- c900="#576b95",
87
- c950="#576b95",
88
- ),
89
- neutral_hue=gr.themes.Color(
90
- name="gray",
91
- c50="#f9fafb",
92
- c100="#f3f4f6",
93
- c200="#e5e7eb",
94
- c300="#d1d5db",
95
- c400="#B2B2B2",
96
- c500="#808080",
97
- c600="#636363",
98
- c700="#515151",
99
- c800="#393939",
100
- c900="#272727",
101
- c950="#171717",
102
- ),
103
- radius_size=gr.themes.sizes.radius_sm,
104
- ).set(
105
- button_primary_background_fill="#06AE56",
106
- button_primary_background_fill_dark="#06AE56",
107
- button_primary_background_fill_hover="#07C863",
108
- button_primary_border_color="#06AE56",
109
- button_primary_border_color_dark="#06AE56",
110
- button_primary_text_color="#FFFFFF",
111
- button_primary_text_color_dark="#FFFFFF",
112
- button_secondary_background_fill="#F2F2F2",
113
- button_secondary_background_fill_dark="#2B2B2B",
114
- button_secondary_text_color="#393939",
115
- button_secondary_text_color_dark="#FFFFFF",
116
- # background_fill_primary="#F7F7F7",
117
- # background_fill_primary_dark="#1F1F1F",
118
- block_title_text_color="*primary_500",
119
- block_title_background_fill="*primary_100",
120
- input_background_fill="#F6F6F6",
121
- ),
122
- ) as demo:
123
  history = gr.State([])
124
  token_count = gr.State([])
125
  promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
 
57
  with open("assets/custom.css", "r", encoding="utf-8") as f:
58
  customCSS = f.read()
59
 
60
+ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  history = gr.State([])
62
  token_count = gr.State([])
63
  promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
modules/presets.py CHANGED
@@ -1,4 +1,5 @@
1
  # -*- coding:utf-8 -*-
 
2
 
3
  # ChatGPT 设置
4
  initial_prompt = "You are a helpful assistant."
@@ -98,3 +99,64 @@ Given the new context, refine the original answer to better
98
  Reply in {reply_language}
99
  If the context isn't useful, return the original answer.
100
  """
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # -*- coding:utf-8 -*-
2
+ import gradio as gr
3
 
4
  # ChatGPT 设置
5
  initial_prompt = "You are a helpful assistant."
 
99
  Reply in {reply_language}
100
  If the context isn't useful, return the original answer.
101
  """
102
+
103
+ small_and_beautiful_theme = gr.themes.Soft(
104
+ primary_hue=gr.themes.Color(
105
+ c50="#02C160",
106
+ c100="rgba(2, 193, 96, 0.2)",
107
+ c200="#02C160",
108
+ c300="rgba(2, 193, 96, 0.32)",
109
+ c400="rgba(2, 193, 96, 0.32)",
110
+ c500="rgba(2, 193, 96, 1.0)",
111
+ c600="rgba(2, 193, 96, 1.0)",
112
+ c700="rgba(2, 193, 96, 0.32)",
113
+ c800="rgba(2, 193, 96, 0.32)",
114
+ c900="#02C160",
115
+ c950="#02C160",
116
+ ),
117
+ secondary_hue=gr.themes.Color(
118
+ c50="#576b95",
119
+ c100="#576b95",
120
+ c200="#576b95",
121
+ c300="#576b95",
122
+ c400="#576b95",
123
+ c500="#576b95",
124
+ c600="#576b95",
125
+ c700="#576b95",
126
+ c800="#576b95",
127
+ c900="#576b95",
128
+ c950="#576b95",
129
+ ),
130
+ neutral_hue=gr.themes.Color(
131
+ name="gray",
132
+ c50="#f9fafb",
133
+ c100="#f3f4f6",
134
+ c200="#e5e7eb",
135
+ c300="#d1d5db",
136
+ c400="#B2B2B2",
137
+ c500="#808080",
138
+ c600="#636363",
139
+ c700="#515151",
140
+ c800="#393939",
141
+ c900="#272727",
142
+ c950="#171717",
143
+ ),
144
+ radius_size=gr.themes.sizes.radius_sm,
145
+ ).set(
146
+ button_primary_background_fill="#06AE56",
147
+ button_primary_background_fill_dark="#06AE56",
148
+ button_primary_background_fill_hover="#07C863",
149
+ button_primary_border_color="#06AE56",
150
+ button_primary_border_color_dark="#06AE56",
151
+ button_primary_text_color="#FFFFFF",
152
+ button_primary_text_color_dark="#FFFFFF",
153
+ button_secondary_background_fill="#F2F2F2",
154
+ button_secondary_background_fill_dark="#2B2B2B",
155
+ button_secondary_text_color="#393939",
156
+ button_secondary_text_color_dark="#FFFFFF",
157
+ # background_fill_primary="#F7F7F7",
158
+ # background_fill_primary_dark="#1F1F1F",
159
+ block_title_text_color="*primary_500",
160
+ block_title_background_fill="*primary_100",
161
+ input_background_fill="#F6F6F6",
162
+ )