Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
d75a717
1
Parent(s):
e11c457
UI微信化
Browse files- ChuanhuChatbot.py +66 -10
ChuanhuChatbot.py
CHANGED
@@ -53,7 +53,67 @@ gr.Chatbot.postprocess = postprocess
|
|
53 |
with open("custom.css", "r") as f:
|
54 |
customCSS = f.read()
|
55 |
|
56 |
-
with gr.Blocks(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
history = gr.State([])
|
58 |
token_count = gr.State([])
|
59 |
promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
|
@@ -74,8 +134,8 @@ with gr.Blocks(css=customCSS) as demo:
|
|
74 |
user_input = gr.Textbox(
|
75 |
show_label=False, placeholder="在这里输入"
|
76 |
).style(container=False)
|
77 |
-
with gr.Column(min_width=
|
78 |
-
submitBtn = gr.Button("
|
79 |
with gr.Row(scale=1):
|
80 |
emptyBtn = gr.Button(
|
81 |
"🧹 新的对话",
|
@@ -193,7 +253,7 @@ with gr.Blocks(css=customCSS) as demo:
|
|
193 |
placeholder=f"在这里输入API地址...",
|
194 |
label="API地址",
|
195 |
value="https://api.openai.com/v1/chat/completions",
|
196 |
-
lines=2
|
197 |
)
|
198 |
changeAPIURLBtn = gr.Button("🔄 切换API地址")
|
199 |
proxyTxt = gr.Textbox(
|
@@ -201,11 +261,10 @@ with gr.Blocks(css=customCSS) as demo:
|
|
201 |
placeholder=f"在这里输入代理地址...",
|
202 |
label="代理地址(示例:http://127.0.0.1:10809)",
|
203 |
value="",
|
204 |
-
lines=2
|
205 |
)
|
206 |
changeProxyBtn = gr.Button("🔄 设置代理地址")
|
207 |
|
208 |
-
|
209 |
gr.Markdown(description)
|
210 |
|
211 |
# Chatbot
|
@@ -340,10 +399,7 @@ with gr.Blocks(css=customCSS) as demo:
|
|
340 |
|
341 |
# Advanced
|
342 |
default_btn.click(
|
343 |
-
reset_default,
|
344 |
-
[],
|
345 |
-
[apiurlTxt, proxyTxt, status_display],
|
346 |
-
show_progress=True
|
347 |
)
|
348 |
changeAPIURLBtn.click(
|
349 |
change_api_url,
|
|
|
53 |
with open("custom.css", "r") as f:
|
54 |
customCSS = f.read()
|
55 |
|
56 |
+
with gr.Blocks(
|
57 |
+
css=customCSS,
|
58 |
+
theme=gr.themes.Soft(
|
59 |
+
primary_hue=gr.themes.Color(
|
60 |
+
c50="#02C160",
|
61 |
+
c100="rgba(2, 193, 96, 0.2)",
|
62 |
+
c200="#02C160",
|
63 |
+
c300="rgba(2, 193, 96, 0.32)",
|
64 |
+
c400="rgba(2, 193, 96, 0.32)",
|
65 |
+
c500="rgba(2, 193, 96, 1.0)",
|
66 |
+
c600="rgba(2, 193, 96, 1.0)",
|
67 |
+
c700="rgba(2, 193, 96, 0.32)",
|
68 |
+
c800="rgba(2, 193, 96, 0.32)",
|
69 |
+
c900="#02C160",
|
70 |
+
c950="#02C160",
|
71 |
+
),
|
72 |
+
secondary_hue=gr.themes.Color(
|
73 |
+
c50="#576b95",
|
74 |
+
c100="#576b95",
|
75 |
+
c200="#576b95",
|
76 |
+
c300="#576b95",
|
77 |
+
c400="#576b95",
|
78 |
+
c500="#576b95",
|
79 |
+
c600="#576b95",
|
80 |
+
c700="#576b95",
|
81 |
+
c800="#576b95",
|
82 |
+
c900="#576b95",
|
83 |
+
c950="#576b95",
|
84 |
+
),
|
85 |
+
neutral_hue=gr.themes.Color(
|
86 |
+
name="gray",
|
87 |
+
c50="#f9fafb",
|
88 |
+
c100="#f3f4f6",
|
89 |
+
c200="#e5e7eb",
|
90 |
+
c300="#d1d5db",
|
91 |
+
c400="#B2B2B2",
|
92 |
+
c500="#808080",
|
93 |
+
c600="#636363",
|
94 |
+
c700="#515151",
|
95 |
+
c800="#393939",
|
96 |
+
c900="#272727",
|
97 |
+
c950="#171717",
|
98 |
+
),
|
99 |
+
radius_size=gr.themes.sizes.radius_sm,
|
100 |
+
).set(
|
101 |
+
button_primary_background_fill="#06AE56",
|
102 |
+
button_primary_background_fill_dark="#06AE56",
|
103 |
+
button_primary_border_color="#06AE56",
|
104 |
+
button_primary_border_color_dark="#06AE56",
|
105 |
+
button_primary_text_color="#FFFFFF",
|
106 |
+
button_primary_text_color_dark="#FFFFFF",
|
107 |
+
button_secondary_background_fill="#F2F2F2",
|
108 |
+
button_secondary_background_fill_dark="#2B2B2B",
|
109 |
+
button_secondary_text_color="#06AE56",
|
110 |
+
button_secondary_text_color_dark="#FFFFFF",
|
111 |
+
background_fill_primary="#F7F7F7",
|
112 |
+
background_fill_primary_dark="#1F1F1F",
|
113 |
+
block_title_text_color="#6E737B",
|
114 |
+
block_title_background_fill = "*background_fill_primary",
|
115 |
+
),
|
116 |
+
) as demo:
|
117 |
history = gr.State([])
|
118 |
token_count = gr.State([])
|
119 |
promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
|
|
|
134 |
user_input = gr.Textbox(
|
135 |
show_label=False, placeholder="在这里输入"
|
136 |
).style(container=False)
|
137 |
+
with gr.Column(min_width=70, scale=1):
|
138 |
+
submitBtn = gr.Button("发送", variant="primary")
|
139 |
with gr.Row(scale=1):
|
140 |
emptyBtn = gr.Button(
|
141 |
"🧹 新的对话",
|
|
|
253 |
placeholder=f"在这里输入API地址...",
|
254 |
label="API地址",
|
255 |
value="https://api.openai.com/v1/chat/completions",
|
256 |
+
lines=2,
|
257 |
)
|
258 |
changeAPIURLBtn = gr.Button("🔄 切换API地址")
|
259 |
proxyTxt = gr.Textbox(
|
|
|
261 |
placeholder=f"在这里输入代理地址...",
|
262 |
label="代理地址(示例:http://127.0.0.1:10809)",
|
263 |
value="",
|
264 |
+
lines=2,
|
265 |
)
|
266 |
changeProxyBtn = gr.Button("🔄 设置代理地址")
|
267 |
|
|
|
268 |
gr.Markdown(description)
|
269 |
|
270 |
# Chatbot
|
|
|
399 |
|
400 |
# Advanced
|
401 |
default_btn.click(
|
402 |
+
reset_default, [], [apiurlTxt, proxyTxt, status_display], show_progress=True
|
|
|
|
|
|
|
403 |
)
|
404 |
changeAPIURLBtn.click(
|
405 |
change_api_url,
|