gordonchan commited on
Commit
7dfee87
·
verified ·
1 Parent(s): f5da45f

Delete themes

Browse files
themes/common.css DELETED
@@ -1,114 +0,0 @@
1
- /* hide remove all button */
2
- .remove-all.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
3
- visibility: hidden;
4
- }
5
-
6
- /* hide selector border */
7
- #input-plugin-group .wrap.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
8
- border: 0px;
9
- box-shadow: none;
10
- }
11
-
12
- #input-plugin-group .secondary-wrap.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
13
- border: none;
14
- min-width: 0;
15
- }
16
-
17
- /* hide selector label */
18
- #input-plugin-group .svelte-1gfkn6j {
19
- visibility: hidden;
20
- }
21
-
22
-
23
- /* height of the upload box */
24
- .wrap.svelte-xwlu1w {
25
- min-height: var(--size-32);
26
- }
27
-
28
- /* status bar height */
29
- .min.svelte-1yrv54 {
30
- min-height: var(--size-12);
31
- }
32
-
33
- /* copy btn */
34
- .message-btn-row {
35
- width: 19px;
36
- height: 19px;
37
- position: absolute;
38
- left: calc(100% + 3px);
39
- top: 0;
40
- display: flex;
41
- justify-content: space-between;
42
- }
43
- /* .message-btn-row-leading, .message-btn-row-trailing {
44
- display: inline-flex;
45
- gap: 4px;
46
- } */
47
- .message-btn-row button {
48
- font-size: 18px;
49
- align-self: center;
50
- align-items: center;
51
- flex-wrap: nowrap;
52
- white-space: nowrap;
53
- display: inline-flex;
54
- flex-direction: row;
55
- gap: 4px;
56
- padding-block: 2px !important;
57
- }
58
-
59
-
60
- /* Scrollbar Width */
61
- ::-webkit-scrollbar {
62
- width: 12px;
63
- }
64
-
65
- /* Scrollbar Track */
66
- ::-webkit-scrollbar-track {
67
- background: #f1f1f1;
68
- border-radius: 12px;
69
- }
70
-
71
- /* Scrollbar Handle */
72
- ::-webkit-scrollbar-thumb {
73
- background: #888;
74
- border-radius: 12px;
75
- }
76
-
77
- /* Scrollbar Handle on hover */
78
- ::-webkit-scrollbar-thumb:hover {
79
- background: #555;
80
- }
81
-
82
- /* input btns: clear, reset, stop */
83
- #input-panel button {
84
- min-width: min(80px, 100%);
85
- }
86
-
87
- /* input btns: clear, reset, stop */
88
- #input-panel2 button {
89
- min-width: min(80px, 100%);
90
- }
91
-
92
-
93
- #cbs {
94
- background-color: var(--block-background-fill) !important;
95
- }
96
-
97
- #interact-panel .form {
98
- border: hidden
99
- }
100
-
101
- .drag-area {
102
- border: solid;
103
- border-width: thin;
104
- user-select: none;
105
- padding-left: 2%;
106
- }
107
-
108
- .floating-component #input-panel2 {
109
- border-top-left-radius: 0px;
110
- border-top-right-radius: 0px;
111
- border: solid;
112
- border-width: thin;
113
- border-top-width: 0;
114
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/common.js DELETED
@@ -1,501 +0,0 @@
1
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
2
- // 第 1 部分: 工具函数
3
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
4
-
5
- function gradioApp() {
6
- // https://github.com/GaiZhenbiao/ChuanhuChatGPT/tree/main/web_assets/javascript
7
- const elems = document.getElementsByTagName('gradio-app');
8
- const elem = elems.length == 0 ? document : elems[0];
9
- if (elem !== document) {
10
- elem.getElementById = function (id) {
11
- return document.getElementById(id);
12
- };
13
- }
14
- return elem.shadowRoot ? elem.shadowRoot : elem;
15
- }
16
-
17
- function setCookie(name, value, days) {
18
- var expires = "";
19
-
20
- if (days) {
21
- var date = new Date();
22
- date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
23
- expires = "; expires=" + date.toUTCString();
24
- }
25
-
26
- document.cookie = name + "=" + value + expires + "; path=/";
27
- }
28
-
29
- function getCookie(name) {
30
- var decodedCookie = decodeURIComponent(document.cookie);
31
- var cookies = decodedCookie.split(';');
32
-
33
- for (var i = 0; i < cookies.length; i++) {
34
- var cookie = cookies[i].trim();
35
-
36
- if (cookie.indexOf(name + "=") === 0) {
37
- return cookie.substring(name.length + 1, cookie.length);
38
- }
39
- }
40
-
41
- return null;
42
- }
43
-
44
- let toastCount = 0;
45
- function toast_push(msg, duration) {
46
- duration = isNaN(duration) ? 3000 : duration;
47
- const existingToasts = document.querySelectorAll('.toast');
48
- existingToasts.forEach(toast => {
49
- toast.style.top = `${parseInt(toast.style.top, 10) - 70}px`;
50
- });
51
- const m = document.createElement('div');
52
- m.innerHTML = msg;
53
- m.classList.add('toast');
54
- m.style.cssText = `font-size: var(--text-md) !important; color: rgb(255, 255, 255); background-color: rgba(0, 0, 0, 0.6); padding: 10px 15px; border-radius: 4px; position: fixed; top: ${50 + toastCount * 70}%; left: 50%; transform: translateX(-50%); width: auto; text-align: center; transition: top 0.3s;`;
55
- document.body.appendChild(m);
56
- setTimeout(function () {
57
- m.style.opacity = '0';
58
- setTimeout(function () {
59
- document.body.removeChild(m);
60
- toastCount--;
61
- }, 500);
62
- }, duration);
63
- toastCount++;
64
- }
65
-
66
- function toast_up(msg) {
67
- var m = document.getElementById('toast_up');
68
- if (m) {
69
- document.body.removeChild(m); // remove the loader from the body
70
- }
71
- m = document.createElement('div');
72
- m.id = 'toast_up';
73
- m.innerHTML = msg;
74
- m.style.cssText = "font-size: var(--text-md) !important; color: rgb(255, 255, 255); background-color: rgba(0, 0, 100, 0.6); padding: 10px 15px; margin: 0 0 0 -60px; border-radius: 4px; position: fixed; top: 50%; left: 50%; width: auto; text-align: center;";
75
- document.body.appendChild(m);
76
- }
77
- function toast_down() {
78
- var m = document.getElementById('toast_up');
79
- if (m) {
80
- document.body.removeChild(m); // remove the loader from the body
81
- }
82
- }
83
-
84
-
85
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
86
- // 第 2 部分: 复制按钮
87
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
88
-
89
- function addCopyButton(botElement) {
90
- // https://github.com/GaiZhenbiao/ChuanhuChatGPT/tree/main/web_assets/javascript
91
- // Copy bot button
92
- const copiedIcon = '<span><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" height=".8em" width=".8em" xmlns="http://www.w3.org/2000/svg"><polyline points="20 6 9 17 4 12"></polyline></svg></span>';
93
- const copyIcon = '<span><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" height=".8em" width=".8em" xmlns="http://www.w3.org/2000/svg"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span>';
94
-
95
- const messageBtnColumnElement = botElement.querySelector('.message-btn-row');
96
- if (messageBtnColumnElement) {
97
- // Do something if .message-btn-column exists, for example, remove it
98
- // messageBtnColumnElement.remove();
99
- return;
100
- }
101
-
102
- var copyButton = document.createElement('button');
103
- copyButton.classList.add('copy-bot-btn');
104
- copyButton.setAttribute('aria-label', 'Copy');
105
- copyButton.innerHTML = copyIcon;
106
- copyButton.addEventListener('click', async () => {
107
- const textToCopy = botElement.innerText;
108
- try {
109
- if ("clipboard" in navigator) {
110
- await navigator.clipboard.writeText(textToCopy);
111
- copyButton.innerHTML = copiedIcon;
112
- setTimeout(() => {
113
- copyButton.innerHTML = copyIcon;
114
- }, 1500);
115
- } else {
116
- const textArea = document.createElement("textarea");
117
- textArea.value = textToCopy;
118
- document.body.appendChild(textArea);
119
- textArea.select();
120
- try {
121
- document.execCommand('copy');
122
- copyButton.innerHTML = copiedIcon;
123
- setTimeout(() => {
124
- copyButton.innerHTML = copyIcon;
125
- }, 1500);
126
- } catch (error) {
127
- console.error("Copy failed: ", error);
128
- }
129
- document.body.removeChild(textArea);
130
- }
131
- } catch (error) {
132
- console.error("Copy failed: ", error);
133
- }
134
- });
135
- var messageBtnColumn = document.createElement('div');
136
- messageBtnColumn.classList.add('message-btn-row');
137
- messageBtnColumn.appendChild(copyButton);
138
- botElement.appendChild(messageBtnColumn);
139
- }
140
-
141
- function chatbotContentChanged(attempt = 1, force = false) {
142
- // https://github.com/GaiZhenbiao/ChuanhuChatGPT/tree/main/web_assets/javascript
143
- for (var i = 0; i < attempt; i++) {
144
- setTimeout(() => {
145
- gradioApp().querySelectorAll('#gpt-chatbot .message-wrap .message.bot').forEach(addCopyButton);
146
- }, i === 0 ? 0 : 200);
147
- }
148
- }
149
-
150
-
151
-
152
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
153
- // 第 3 部分: chatbot动态高度调整
154
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
155
-
156
- function chatbotAutoHeight() {
157
- // 自动调整高度
158
- function update_height() {
159
- var { height_target, chatbot_height, chatbot } = get_elements(true);
160
- if (height_target != chatbot_height) {
161
- var pixelString = height_target.toString() + 'px';
162
- chatbot.style.maxHeight = pixelString; chatbot.style.height = pixelString;
163
- }
164
- }
165
-
166
- function update_height_slow() {
167
- var { height_target, chatbot_height, chatbot } = get_elements();
168
- if (height_target != chatbot_height) {
169
- new_panel_height = (height_target - chatbot_height) * 0.5 + chatbot_height;
170
- if (Math.abs(new_panel_height - height_target) < 10) {
171
- new_panel_height = height_target;
172
- }
173
- // console.log(chatbot_height, height_target, new_panel_height);
174
- var pixelString = new_panel_height.toString() + 'px';
175
- chatbot.style.maxHeight = pixelString; chatbot.style.height = pixelString;
176
- }
177
- }
178
- monitoring_input_box()
179
- update_height();
180
- setInterval(function () {
181
- update_height_slow()
182
- }, 50); // 每50毫秒执行一次
183
- }
184
-
185
- swapped = false;
186
- function swap_input_area() {
187
- // Get the elements to be swapped
188
- var element1 = document.querySelector("#input-panel");
189
- var element2 = document.querySelector("#basic-panel");
190
-
191
- // Get the parent of the elements
192
- var parent = element1.parentNode;
193
-
194
- // Get the next sibling of element2
195
- var nextSibling = element2.nextSibling;
196
-
197
- // Swap the elements
198
- parent.insertBefore(element2, element1);
199
- parent.insertBefore(element1, nextSibling);
200
- if (swapped) {swapped = false;}
201
- else {swapped = true;}
202
- }
203
-
204
- function get_elements(consider_state_panel = false) {
205
- var chatbot = document.querySelector('#gpt-chatbot > div.wrap.svelte-18telvq');
206
- if (!chatbot) {
207
- chatbot = document.querySelector('#gpt-chatbot');
208
- }
209
- const panel1 = document.querySelector('#input-panel').getBoundingClientRect();
210
- const panel2 = document.querySelector('#basic-panel').getBoundingClientRect()
211
- const panel3 = document.querySelector('#plugin-panel').getBoundingClientRect();
212
- // const panel4 = document.querySelector('#interact-panel').getBoundingClientRect();
213
- const panel_active = document.querySelector('#state-panel').getBoundingClientRect();
214
- if (consider_state_panel || panel_active.height < 25) {
215
- document.state_panel_height = panel_active.height;
216
- }
217
- // 25 是chatbot的label高度, 16 是右侧的gap
218
- var height_target = panel1.height + panel2.height + panel3.height + 0 + 0 - 25 + 16 * 2;
219
- // 禁止动态的state-panel高度影响
220
- height_target = height_target + (document.state_panel_height - panel_active.height)
221
- var height_target = parseInt(height_target);
222
- var chatbot_height = chatbot.style.height;
223
- // 交换输入区位置,使得输入区始终可用
224
- if (!swapped){
225
- if (panel1.top!=0 && panel1.top < 0){ swap_input_area(); }
226
- }
227
- else if (swapped){
228
- if (panel2.top!=0 && panel2.top > 0){ swap_input_area(); }
229
- }
230
- // 调整高度
231
- const err_tor = 5;
232
- if (Math.abs(panel1.left - chatbot.getBoundingClientRect().left) < err_tor){
233
- // 是否处于窄屏模式
234
- height_target = window.innerHeight * 0.6;
235
- }else{
236
- // 调整高度
237
- const chatbot_height_exceed = 15;
238
- const chatbot_height_exceed_m = 10;
239
- b_panel = Math.max(panel1.bottom, panel2.bottom, panel3.bottom)
240
- if (b_panel >= window.innerHeight - chatbot_height_exceed) {
241
- height_target = window.innerHeight - chatbot.getBoundingClientRect().top - chatbot_height_exceed_m;
242
- }
243
- else if (b_panel < window.innerHeight * 0.75) {
244
- height_target = window.innerHeight * 0.8;
245
- }
246
- }
247
- var chatbot_height = parseInt(chatbot_height);
248
- return { height_target, chatbot_height, chatbot };
249
- }
250
-
251
-
252
-
253
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
254
- // 第 4 部分: 粘贴、拖拽文件上传
255
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
256
-
257
- var elem_upload = null;
258
- var elem_upload_float = null;
259
- var elem_input_main = null;
260
- var elem_input_float = null;
261
- var elem_chatbot = null;
262
- var exist_file_msg = '⚠️请先删除上传区(左上方)中的历史文件,再尝试上传。'
263
-
264
- function add_func_paste(input) {
265
- let paste_files = [];
266
- if (input) {
267
- input.addEventListener("paste", async function (e) {
268
- const clipboardData = e.clipboardData || window.clipboardData;
269
- const items = clipboardData.items;
270
- if (items) {
271
- for (i = 0; i < items.length; i++) {
272
- if (items[i].kind === "file") { // 确保是文件类型
273
- const file = items[i].getAsFile();
274
- // 将每一个粘贴的文件添加到files数组中
275
- paste_files.push(file);
276
- e.preventDefault(); // 避免粘贴文件名到输入框
277
- }
278
- }
279
- if (paste_files.length > 0) {
280
- // 按照文件列表执行批量上传逻辑
281
- await upload_files(paste_files);
282
- paste_files = []
283
-
284
- }
285
- }
286
- });
287
- }
288
- }
289
-
290
- function add_func_drag(elem) {
291
- if (elem) {
292
- const dragEvents = ["dragover"];
293
- const leaveEvents = ["dragleave", "dragend", "drop"];
294
-
295
- const onDrag = function (e) {
296
- e.preventDefault();
297
- e.stopPropagation();
298
- if (elem_upload_float.querySelector("input[type=file]")) {
299
- toast_up('⚠️释放以上传文件')
300
- } else {
301
- toast_up(exist_file_msg)
302
- }
303
- };
304
-
305
- const onLeave = function (e) {
306
- toast_down();
307
- e.preventDefault();
308
- e.stopPropagation();
309
- };
310
-
311
- dragEvents.forEach(event => {
312
- elem.addEventListener(event, onDrag);
313
- });
314
-
315
- leaveEvents.forEach(event => {
316
- elem.addEventListener(event, onLeave);
317
- });
318
-
319
- elem.addEventListener("drop", async function (e) {
320
- const files = e.dataTransfer.files;
321
- await upload_files(files);
322
- });
323
- }
324
- }
325
-
326
- async function upload_files(files) {
327
- const uploadInputElement = elem_upload_float.querySelector("input[type=file]");
328
- let totalSizeMb = 0
329
- if (files && files.length > 0) {
330
- // 执行具体的上传逻辑
331
- if (uploadInputElement) {
332
- for (let i = 0; i < files.length; i++) {
333
- // 将从文件数组中获取的文件大小(单位为字节)转换为MB,
334
- totalSizeMb += files[i].size / 1024 / 1024;
335
- }
336
- // 检查文件总大小是否超过20MB
337
- if (totalSizeMb > 20) {
338
- toast_push('⚠️文件夹大于 20MB 🚀上传文件中', 3000)
339
- // return; // 如果超过了指定大小, 可以不进行后续上传操作
340
- }
341
- // 监听change事件, 原生Gradio可以实现
342
- // uploadInputElement.addEventListener('change', function(){replace_input_string()});
343
- let event = new Event("change");
344
- Object.defineProperty(event, "target", { value: uploadInputElement, enumerable: true });
345
- Object.defineProperty(event, "currentTarget", { value: uploadInputElement, enumerable: true });
346
- Object.defineProperty(uploadInputElement, "files", { value: files, enumerable: true });
347
- uploadInputElement.dispatchEvent(event);
348
- } else {
349
- toast_push(exist_file_msg, 3000)
350
- }
351
- }
352
- }
353
-
354
- function begin_loading_status() {
355
- // Create the loader div and add styling
356
- var loader = document.createElement('div');
357
- loader.id = 'Js_File_Loading';
358
- loader.style.position = "absolute";
359
- loader.style.top = "50%";
360
- loader.style.left = "50%";
361
- loader.style.width = "60px";
362
- loader.style.height = "60px";
363
- loader.style.border = "16px solid #f3f3f3";
364
- loader.style.borderTop = "16px solid #3498db";
365
- loader.style.borderRadius = "50%";
366
- loader.style.animation = "spin 2s linear infinite";
367
- loader.style.transform = "translate(-50%, -50%)";
368
- document.body.appendChild(loader); // Add the loader to the body
369
- // Set the CSS animation keyframes
370
- var styleSheet = document.createElement('style');
371
- // styleSheet.type = 'text/css';
372
- styleSheet.id = 'Js_File_Loading_Style'
373
- styleSheet.innerText = `
374
- @keyframes spin {
375
- 0% { transform: rotate(0deg); }
376
- 100% { transform: rotate(360deg); }
377
- }`;
378
- document.head.appendChild(styleSheet);
379
- }
380
-
381
- function cancel_loading_status() {
382
- var loadingElement = document.getElementById('Js_File_Loading');
383
- if (loadingElement) {
384
- document.body.removeChild(loadingElement); // remove the loader from the body
385
- }
386
- var loadingStyle = document.getElementById('Js_File_Loading_Style');
387
- if (loadingStyle) {
388
- document.head.removeChild(loadingStyle);
389
- }
390
- let clearButton = document.querySelectorAll('div[id*="elem_upload"] button[aria-label="Clear"]');
391
- for (let button of clearButton) {
392
- button.addEventListener('click', function () {
393
- setTimeout(function () {
394
- register_upload_event();
395
- }, 50);
396
- });
397
- }
398
- }
399
-
400
- function register_upload_event() {
401
- elem_upload_float = document.getElementById('elem_upload_float')
402
- const upload_component = elem_upload_float.querySelector("input[type=file]");
403
- if (upload_component) {
404
- upload_component.addEventListener('change', function (event) {
405
- toast_push('正在上传中,请稍等。', 2000);
406
- begin_loading_status();
407
- });
408
- }
409
- }
410
-
411
- function monitoring_input_box() {
412
- register_upload_event();
413
-
414
- elem_upload = document.getElementById('elem_upload')
415
- elem_upload_float = document.getElementById('elem_upload_float')
416
- elem_input_main = document.getElementById('user_input_main')
417
- elem_input_float = document.getElementById('user_input_float')
418
- elem_chatbot = document.getElementById('gpt-chatbot')
419
-
420
- if (elem_input_main) {
421
- if (elem_input_main.querySelector("textarea")) {
422
- add_func_paste(elem_input_main.querySelector("textarea"))
423
- }
424
- }
425
- if (elem_input_float) {
426
- if (elem_input_float.querySelector("textarea")) {
427
- add_func_paste(elem_input_float.querySelector("textarea"))
428
- }
429
- }
430
- if (elem_chatbot) {
431
- add_func_drag(elem_chatbot)
432
- }
433
- }
434
-
435
-
436
- // 监视页面变化
437
- window.addEventListener("DOMContentLoaded", function () {
438
- // const ga = document.getElementsByTagName("gradio-app");
439
- gradioApp().addEventListener("render", monitoring_input_box);
440
- });
441
-
442
-
443
-
444
-
445
-
446
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
447
- // 第 5 部分: 音频按钮样式变化
448
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
449
-
450
- function audio_fn_init() {
451
- let audio_component = document.getElementById('elem_audio');
452
- if (audio_component) {
453
- let buttonElement = audio_component.querySelector('button');
454
- let specificElement = audio_component.querySelector('.hide.sr-only');
455
- specificElement.remove();
456
-
457
- buttonElement.childNodes[1].nodeValue = '启动麦克风';
458
- buttonElement.addEventListener('click', function (event) {
459
- event.stopPropagation();
460
- toast_push('您启动了麦克风!下一步请点击“实时语音对话”启动语音对话。');
461
- });
462
-
463
- // 查找语音插件按钮
464
- let buttons = document.querySelectorAll('button');
465
- let audio_button = null;
466
- for (let button of buttons) {
467
- if (button.textContent.includes('语音')) {
468
- audio_button = button;
469
- break;
470
- }
471
- }
472
- if (audio_button) {
473
- audio_button.addEventListener('click', function () {
474
- toast_push('您点击了“实时语音对话”启动语音对话。');
475
- });
476
- let parent_element = audio_component.parentElement; // 将buttonElement移动到audio_button的内部
477
- audio_button.appendChild(audio_component);
478
- buttonElement.style.cssText = 'border-color: #00ffe0;border-width: 2px; height: 25px;'
479
- parent_element.remove();
480
- audio_component.style.cssText = 'width: 250px;right: 0px;display: inline-flex;flex-flow: row-reverse wrap;place-content: stretch space-between;align-items: center;background-color: #ffffff00;';
481
- }
482
-
483
- }
484
- }
485
-
486
-
487
-
488
-
489
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
490
- // 第 6 部分: JS初始化函数
491
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
492
-
493
- function GptAcademicJavaScriptInit(LAYOUT = "LEFT-RIGHT") {
494
- audio_fn_init();
495
- chatbotIndicator = gradioApp().querySelector('#gpt-chatbot > div.wrap');
496
- var chatbotObserver = new MutationObserver(() => {
497
- chatbotContentChanged(1);
498
- });
499
- chatbotObserver.observe(chatbotIndicator, { attributes: true, childList: true, subtree: true });
500
- if (LAYOUT === "LEFT-RIGHT") { chatbotAutoHeight(); }
501
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/contrast.css DELETED
@@ -1,482 +0,0 @@
1
- :root {
2
- --body-text-color: #FFFFFF;
3
- --link-text-color: #FFFFFF;
4
- --link-text-color-active: #FFFFFF;
5
- --link-text-color-hover: #FFFFFF;
6
- --link-text-color-visited: #FFFFFF;
7
- --body-text-color-subdued: #FFFFFF;
8
- --block-info-text-color: #FFFFFF;
9
- --block-label-text-color: #FFFFFF;
10
- --block-title-text-color: #FFFFFF;
11
- --checkbox-label-text-color: #FFFFFF;
12
- --checkbox-label-text-color-selected: #FFFFFF;
13
- --error-text-color: #FFFFFF;
14
- --button-cancel-text-color: #FFFFFF;
15
- --button-cancel-text-color-hover: #FFFFFF;
16
- --button-primary-text-color: #FFFFFF;
17
- --button-primary-text-color-hover: #FFFFFF;
18
- --button-secondary-text-color: #FFFFFF;
19
- --button-secondary-text-color-hover: #FFFFFF;
20
-
21
-
22
- --border-bottom-right-radius: 0px;
23
- --border-bottom-left-radius: 0px;
24
- --border-top-right-radius: 0px;
25
- --border-top-left-radius: 0px;
26
- --block-radius: 0px;
27
- --button-large-radius: 0px;
28
- --button-small-radius: 0px;
29
- --block-background-fill: #000000;
30
-
31
- --border-color-accent: #3cff00;
32
- --border-color-primary: #3cff00;
33
- --block-border-color: #3cff00;
34
- --block-label-border-color: #3cff00;
35
- --block-title-border-color: #3cff00;
36
- --panel-border-color: #3cff00;
37
- --checkbox-border-color: #3cff00;
38
- --checkbox-border-color-focus: #3cff00;
39
- --checkbox-border-color-hover: #3cff00;
40
- --checkbox-border-color-selected: #3cff00;
41
- --checkbox-label-border-color: #3cff00;
42
- --checkbox-label-border-color-hover: #3cff00;
43
- --error-border-color: #3cff00;
44
- --input-border-color: #3cff00;
45
- --input-border-color-focus: #3cff00;
46
- --input-border-color-hover: #3cff00;
47
- --table-border-color: #3cff00;
48
- --button-cancel-border-color: #3cff00;
49
- --button-cancel-border-color-hover: #3cff00;
50
- --button-primary-border-color: #3cff00;
51
- --button-primary-border-color-hover: #3cff00;
52
- --button-secondary-border-color: #3cff00;
53
- --button-secondary-border-color-hover: #3cff00;
54
-
55
-
56
- --body-background-fill: #000000;
57
- --background-fill-primary: #000000;
58
- --background-fill-secondary: #000000;
59
- --block-background-fill: #000000;
60
- --block-label-background-fill: #000000;
61
- --block-title-background-fill: #000000;
62
- --panel-background-fill: #000000;
63
- --chatbot-code-background-color: #000000;
64
- --checkbox-background-color: #000000;
65
- --checkbox-background-color-focus: #000000;
66
- --checkbox-background-color-hover: #000000;
67
- --checkbox-background-color-selected: #000000;
68
- --checkbox-label-background-fill: #000000;
69
- --checkbox-label-background-fill-hover: #000000;
70
- --checkbox-label-background-fill-selected: #000000;
71
- --error-background-fill: #000000;
72
- --input-background-fill: #000000;
73
- --input-background-fill-focus: #000000;
74
- --input-background-fill-hover: #000000;
75
- --stat-background-fill: #000000;
76
- --table-even-background-fill: #000000;
77
- --table-odd-background-fill: #000000;
78
- --button-cancel-background-fill: #000000;
79
- --button-cancel-background-fill-hover: #000000;
80
- --button-primary-background-fill: #000000;
81
- --button-primary-background-fill-hover: #000000;
82
- --button-secondary-background-fill: #000000;
83
- --button-secondary-background-fill-hover: #000000;
84
- --color-accent-soft: #000000;
85
- }
86
-
87
- .dark {
88
- --body-text-color: #FFFFFF;
89
- --link-text-color: #FFFFFF;
90
- --link-text-color-active: #FFFFFF;
91
- --link-text-color-hover: #FFFFFF;
92
- --link-text-color-visited: #FFFFFF;
93
- --body-text-color-subdued: #FFFFFF;
94
- --block-info-text-color: #FFFFFF;
95
- --block-label-text-color: #FFFFFF;
96
- --block-title-text-color: #FFFFFF;
97
- --checkbox-label-text-color: #FFFFFF;
98
- --checkbox-label-text-color-selected: #FFFFFF;
99
- --error-text-color: #FFFFFF;
100
- --button-cancel-text-color: #FFFFFF;
101
- --button-cancel-text-color-hover: #FFFFFF;
102
- --button-primary-text-color: #FFFFFF;
103
- --button-primary-text-color-hover: #FFFFFF;
104
- --button-secondary-text-color: #FFFFFF;
105
- --button-secondary-text-color-hover: #FFFFFF;
106
-
107
-
108
-
109
- --border-bottom-right-radius: 0px;
110
- --border-bottom-left-radius: 0px;
111
- --border-top-right-radius: 0px;
112
- --border-top-left-radius: 0px;
113
- --block-radius: 0px;
114
- --button-large-radius: 0px;
115
- --button-small-radius: 0px;
116
- --block-background-fill: #000000;
117
-
118
- --border-color-accent: #3cff00;
119
- --border-color-primary: #3cff00;
120
- --block-border-color: #3cff00;
121
- --block-label-border-color: #3cff00;
122
- --block-title-border-color: #3cff00;
123
- --panel-border-color: #3cff00;
124
- --checkbox-border-color: #3cff00;
125
- --checkbox-border-color-focus: #3cff00;
126
- --checkbox-border-color-hover: #3cff00;
127
- --checkbox-border-color-selected: #3cff00;
128
- --checkbox-label-border-color: #3cff00;
129
- --checkbox-label-border-color-hover: #3cff00;
130
- --error-border-color: #3cff00;
131
- --input-border-color: #3cff00;
132
- --input-border-color-focus: #3cff00;
133
- --input-border-color-hover: #3cff00;
134
- --table-border-color: #3cff00;
135
- --button-cancel-border-color: #3cff00;
136
- --button-cancel-border-color-hover: #3cff00;
137
- --button-primary-border-color: #3cff00;
138
- --button-primary-border-color-hover: #3cff00;
139
- --button-secondary-border-color: #3cff00;
140
- --button-secondary-border-color-hover: #3cff00;
141
-
142
-
143
- --body-background-fill: #000000;
144
- --background-fill-primary: #000000;
145
- --background-fill-secondary: #000000;
146
- --block-background-fill: #000000;
147
- --block-label-background-fill: #000000;
148
- --block-title-background-fill: #000000;
149
- --panel-background-fill: #000000;
150
- --chatbot-code-background-color: #000000;
151
- --checkbox-background-color: #000000;
152
- --checkbox-background-color-focus: #000000;
153
- --checkbox-background-color-hover: #000000;
154
- --checkbox-background-color-selected: #000000;
155
- --checkbox-label-background-fill: #000000;
156
- --checkbox-label-background-fill-hover: #000000;
157
- --checkbox-label-background-fill-selected: #000000;
158
- --error-background-fill: #000000;
159
- --input-background-fill: #000000;
160
- --input-background-fill-focus: #000000;
161
- --input-background-fill-hover: #000000;
162
- --stat-background-fill: #000000;
163
- --table-even-background-fill: #000000;
164
- --table-odd-background-fill: #000000;
165
- --button-cancel-background-fill: #000000;
166
- --button-cancel-background-fill-hover: #000000;
167
- --button-primary-background-fill: #000000;
168
- --button-primary-background-fill-hover: #000000;
169
- --button-secondary-background-fill: #000000;
170
- --button-secondary-background-fill-hover: #000000;
171
- --color-accent-soft: #000000;
172
- }
173
-
174
-
175
-
176
- .block.svelte-mppz8v {
177
- border-color: #3cff00;
178
- }
179
-
180
- /* 插件下拉菜单 */
181
- #plugin-panel .wrap.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
182
- box-shadow: var(--input-shadow);
183
- border: var(--input-border-width) dashed var(--border-color-primary);
184
- border-radius: 4px;
185
- }
186
-
187
- #plugin-panel .dropdown-arrow.svelte-p5edak {
188
- width: 50px;
189
- }
190
- #plugin-panel input.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
191
- padding-left: 5px;
192
- }
193
- .root{
194
- border-bottom-right-radius: 0px;
195
- border-bottom-left-radius: 0px;
196
- border-top-right-radius: 0px;
197
- border-top-left-radius: 0px;
198
- }
199
-
200
- /* 小按钮 */
201
- .sm {
202
- font-family: "Microsoft YaHei UI", "Helvetica", "Microsoft YaHei", "ui-sans-serif", "sans-serif", "system-ui";
203
- --button-small-text-weight: 600;
204
- --button-small-text-size: 16px;
205
- border-bottom-right-radius: 0px;
206
- border-bottom-left-radius: 0px;
207
- border-top-right-radius: 0px;
208
- border-top-left-radius: 0px;
209
- }
210
-
211
- #plugin-panel .sm {
212
- font-family: "Microsoft YaHei UI", "Helvetica", "Microsoft YaHei", "ui-sans-serif", "sans-serif", "system-ui";
213
- --button-small-text-weight: 400;
214
- --button-small-text-size: 14px;
215
- border-bottom-right-radius: 0px;
216
- border-bottom-left-radius: 0px;
217
- border-top-right-radius: 0px;
218
- border-top-left-radius: 0px;
219
- }
220
-
221
- .wrap-inner.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
222
- padding: 0%;
223
- }
224
-
225
- .markdown-body table {
226
- margin: 1em 0;
227
- border-collapse: collapse;
228
- empty-cells: show;
229
- }
230
-
231
- .markdown-body th, .markdown-body td {
232
- border: 1.2px solid var(--border-color-primary);
233
- padding: 5px;
234
- }
235
-
236
- .markdown-body thead {
237
- background-color: rgb(0, 0, 0);
238
- }
239
-
240
- .markdown-body thead th {
241
- padding: .5em .2em;
242
- }
243
-
244
- .normal_mut_select .svelte-1gfkn6j {
245
- float: left;
246
- width: auto;
247
- line-height: 260% !important;
248
- }
249
-
250
- .markdown-body ol, .markdown-body ul {
251
- padding-inline-start: 2em !important;
252
- }
253
-
254
- /* chat box. */
255
- [class *= "message"] {
256
- border-radius: var(--radius-xl) !important;
257
- /* padding: var(--spacing-xl) !important; */
258
- /* font-size: var(--text-md) !important; */
259
- /* line-height: var(--line-md) !important; */
260
- /* min-height: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl)); */
261
- /* min-width: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl)); */
262
- }
263
- [data-testid = "bot"] {
264
- max-width: 95%;
265
- /* width: auto !important; */
266
- border-bottom-left-radius: 0 !important;
267
- }
268
- [data-testid = "user"] {
269
- max-width: 100%;
270
- /* width: auto !important; */
271
- border-bottom-right-radius: 0 !important;
272
- }
273
-
274
- /* linein code block. */
275
- .markdown-body code {
276
- display: inline;
277
- white-space: break-spaces;
278
- border-radius: 6px;
279
- margin: 0 2px 0 2px;
280
- padding: .2em .4em .1em .4em;
281
- background-color: rgba(0, 0, 0, 0.95);
282
- color: #c9d1d9;
283
- }
284
-
285
- .dark .markdown-body code {
286
- display: inline;
287
- white-space: break-spaces;
288
- border-radius: 6px;
289
- margin: 0 2px 0 2px;
290
- padding: .2em .4em .1em .4em;
291
- background-color: rgba(0,0,0,0.2);
292
- }
293
-
294
- /* code block css */
295
- .markdown-body pre code {
296
- display: block;
297
- overflow: auto;
298
- white-space: pre;
299
- background-color: rgba(0, 0, 0, 0.95);
300
- border-radius: 10px;
301
- padding: 1em;
302
- margin: 1em 2em 1em 0.5em;
303
- }
304
-
305
- .dark .markdown-body pre code {
306
- display: block;
307
- overflow: auto;
308
- white-space: pre;
309
- background-color: rgba(0,0,0,0.2);
310
- border-radius: 10px;
311
- padding: 1em;
312
- margin: 1em 2em 1em 0.5em;
313
- }
314
-
315
- /* .mic-wrap.svelte-1thnwz {
316
-
317
- } */
318
- .block.svelte-mppz8v > .mic-wrap.svelte-1thnwz{
319
- justify-content: center;
320
- display: flex;
321
- padding: 0;
322
-
323
- }
324
-
325
- .codehilite .hll { background-color: #6e7681 }
326
- .codehilite .c { color: #8b949e; font-style: italic } /* Comment */
327
- .codehilite .err { color: #f85149 } /* Error */
328
- .codehilite .esc { color: #c9d1d9 } /* Escape */
329
- .codehilite .g { color: #c9d1d9 } /* Generic */
330
- .codehilite .k { color: #ff7b72 } /* Keyword */
331
- .codehilite .l { color: #a5d6ff } /* Literal */
332
- .codehilite .n { color: #c9d1d9 } /* Name */
333
- .codehilite .o { color: #ff7b72; font-weight: bold } /* Operator */
334
- .codehilite .x { color: #c9d1d9 } /* Other */
335
- .codehilite .p { color: #c9d1d9 } /* Punctuation */
336
- .codehilite .ch { color: #8b949e; font-style: italic } /* Comment.Hashbang */
337
- .codehilite .cm { color: #8b949e; font-style: italic } /* Comment.Multiline */
338
- .codehilite .cp { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Preproc */
339
- .codehilite .cpf { color: #8b949e; font-style: italic } /* Comment.PreprocFile */
340
- .codehilite .c1 { color: #8b949e; font-style: italic } /* Comment.Single */
341
- .codehilite .cs { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Special */
342
- .codehilite .gd { color: #ffa198; background-color: #490202 } /* Generic.Deleted */
343
- .codehilite .ge { color: #c9d1d9; font-style: italic } /* Generic.Emph */
344
- .codehilite .gr { color: #ffa198 } /* Generic.Error */
345
- .codehilite .gh { color: #79c0ff; font-weight: bold } /* Generic.Heading */
346
- .codehilite .gi { color: #56d364; background-color: #0f5323 } /* Generic.Inserted */
347
- .codehilite .go { color: #8b949e } /* Generic.Output */
348
- .codehilite .gp { color: #8b949e } /* Generic.Prompt */
349
- .codehilite .gs { color: #c9d1d9; font-weight: bold } /* Generic.Strong */
350
- .codehilite .gu { color: #79c0ff } /* Generic.Subheading */
351
- .codehilite .gt { color: #ff7b72 } /* Generic.Traceback */
352
- .codehilite .g-Underline { color: #c9d1d9; text-decoration: underline } /* Generic.Underline */
353
- .codehilite .kc { color: #79c0ff } /* Keyword.Constant */
354
- .codehilite .kd { color: #ff7b72 } /* Keyword.Declaration */
355
- .codehilite .kn { color: #ff7b72 } /* Keyword.Namespace */
356
- .codehilite .kp { color: #79c0ff } /* Keyword.Pseudo */
357
- .codehilite .kr { color: #ff7b72 } /* Keyword.Reserved */
358
- .codehilite .kt { color: #ff7b72 } /* Keyword.Type */
359
- .codehilite .ld { color: #79c0ff } /* Literal.Date */
360
- .codehilite .m { color: #a5d6ff } /* Literal.Number */
361
- .codehilite .s { color: #a5d6ff } /* Literal.String */
362
- .codehilite .na { color: #c9d1d9 } /* Name.Attribute */
363
- .codehilite .nb { color: #c9d1d9 } /* Name.Builtin */
364
- .codehilite .nc { color: #f0883e; font-weight: bold } /* Name.Class */
365
- .codehilite .no { color: #79c0ff; font-weight: bold } /* Name.Constant */
366
- .codehilite .nd { color: #d2a8ff; font-weight: bold } /* Name.Decorator */
367
- .codehilite .ni { color: #ffa657 } /* Name.Entity */
368
- .codehilite .ne { color: #f0883e; font-weight: bold } /* Name.Exception */
369
- .codehilite .nf { color: #d2a8ff; font-weight: bold } /* Name.Function */
370
- .codehilite .nl { color: #79c0ff; font-weight: bold } /* Name.Label */
371
- .codehilite .nn { color: #ff7b72 } /* Name.Namespace */
372
- .codehilite .nx { color: #c9d1d9 } /* Name.Other */
373
- .codehilite .py { color: #79c0ff } /* Name.Property */
374
- .codehilite .nt { color: #7ee787 } /* Name.Tag */
375
- .codehilite .nv { color: #79c0ff } /* Name.Variable */
376
- .codehilite .ow { color: #ff7b72; font-weight: bold } /* Operator.Word */
377
- .codehilite .pm { color: #c9d1d9 } /* Punctuation.Marker */
378
- .codehilite .w { color: #6e7681 } /* Text.Whitespace */
379
- .codehilite .mb { color: #a5d6ff } /* Literal.Number.Bin */
380
- .codehilite .mf { color: #a5d6ff } /* Literal.Number.Float */
381
- .codehilite .mh { color: #a5d6ff } /* Literal.Number.Hex */
382
- .codehilite .mi { color: #a5d6ff } /* Literal.Number.Integer */
383
- .codehilite .mo { color: #a5d6ff } /* Literal.Number.Oct */
384
- .codehilite .sa { color: #79c0ff } /* Literal.String.Affix */
385
- .codehilite .sb { color: #a5d6ff } /* Literal.String.Backtick */
386
- .codehilite .sc { color: #a5d6ff } /* Literal.String.Char */
387
- .codehilite .dl { color: #79c0ff } /* Literal.String.Delimiter */
388
- .codehilite .sd { color: #a5d6ff } /* Literal.String.Doc */
389
- .codehilite .s2 { color: #a5d6ff } /* Literal.String.Double */
390
- .codehilite .se { color: #79c0ff } /* Literal.String.Escape */
391
- .codehilite .sh { color: #79c0ff } /* Literal.String.Heredoc */
392
- .codehilite .si { color: #a5d6ff } /* Literal.String.Interpol */
393
- .codehilite .sx { color: #a5d6ff } /* Literal.String.Other */
394
- .codehilite .sr { color: #79c0ff } /* Literal.String.Regex */
395
- .codehilite .s1 { color: #a5d6ff } /* Literal.String.Single */
396
- .codehilite .ss { color: #a5d6ff } /* Literal.String.Symbol */
397
- .codehilite .bp { color: #c9d1d9 } /* Name.Builtin.Pseudo */
398
- .codehilite .fm { color: #d2a8ff; font-weight: bold } /* Name.Function.Magic */
399
- .codehilite .vc { color: #79c0ff } /* Name.Variable.Class */
400
- .codehilite .vg { color: #79c0ff } /* Name.Variable.Global */
401
- .codehilite .vi { color: #79c0ff } /* Name.Variable.Instance */
402
- .codehilite .vm { color: #79c0ff } /* Name.Variable.Magic */
403
- .codehilite .il { color: #a5d6ff } /* Literal.Number.Integer.Long */
404
-
405
- .dark .codehilite .hll { background-color: #2C3B41 }
406
- .dark .codehilite .c { color: #79d618; font-style: italic } /* Comment */
407
- .dark .codehilite .err { color: #FF5370 } /* Error */
408
- .dark .codehilite .esc { color: #89DDFF } /* Escape */
409
- .dark .codehilite .g { color: #EEFFFF } /* Generic */
410
- .dark .codehilite .k { color: #BB80B3 } /* Keyword */
411
- .dark .codehilite .l { color: #C3E88D } /* Literal */
412
- .dark .codehilite .n { color: #EEFFFF } /* Name */
413
- .dark .codehilite .o { color: #89DDFF } /* Operator */
414
- .dark .codehilite .p { color: #89DDFF } /* Punctuation */
415
- .dark .codehilite .ch { color: #79d618; font-style: italic } /* Comment.Hashbang */
416
- .dark .codehilite .cm { color: #79d618; font-style: italic } /* Comment.Multiline */
417
- .dark .codehilite .cp { color: #79d618; font-style: italic } /* Comment.Preproc */
418
- .dark .codehilite .cpf { color: #79d618; font-style: italic } /* Comment.PreprocFile */
419
- .dark .codehilite .c1 { color: #79d618; font-style: italic } /* Comment.Single */
420
- .dark .codehilite .cs { color: #79d618; font-style: italic } /* Comment.Special */
421
- .dark .codehilite .gd { color: #FF5370 } /* Generic.Deleted */
422
- .dark .codehilite .ge { color: #89DDFF } /* Generic.Emph */
423
- .dark .codehilite .gr { color: #FF5370 } /* Generic.Error */
424
- .dark .codehilite .gh { color: #C3E88D } /* Generic.Heading */
425
- .dark .codehilite .gi { color: #C3E88D } /* Generic.Inserted */
426
- .dark .codehilite .go { color: #79d618 } /* Generic.Output */
427
- .dark .codehilite .gp { color: #FFCB6B } /* Generic.Prompt */
428
- .dark .codehilite .gs { color: #FF5370 } /* Generic.Strong */
429
- .dark .codehilite .gu { color: #89DDFF } /* Generic.Subheading */
430
- .dark .codehilite .gt { color: #FF5370 } /* Generic.Traceback */
431
- .dark .codehilite .kc { color: #89DDFF } /* Keyword.Constant */
432
- .dark .codehilite .kd { color: #BB80B3 } /* Keyword.Declaration */
433
- .dark .codehilite .kn { color: #89DDFF; font-style: italic } /* Keyword.Namespace */
434
- .dark .codehilite .kp { color: #89DDFF } /* Keyword.Pseudo */
435
- .dark .codehilite .kr { color: #BB80B3 } /* Keyword.Reserved */
436
- .dark .codehilite .kt { color: #BB80B3 } /* Keyword.Type */
437
- .dark .codehilite .ld { color: #C3E88D } /* Literal.Date */
438
- .dark .codehilite .m { color: #F78C6C } /* Literal.Number */
439
- .dark .codehilite .s { color: #C3E88D } /* Literal.String */
440
- .dark .codehilite .na { color: #BB80B3 } /* Name.Attribute */
441
- .dark .codehilite .nb { color: #82AAFF } /* Name.Builtin */
442
- .dark .codehilite .nc { color: #FFCB6B } /* Name.Class */
443
- .dark .codehilite .no { color: #EEFFFF } /* Name.Constant */
444
- .dark .codehilite .nd { color: #82AAFF } /* Name.Decorator */
445
- .dark .codehilite .ni { color: #89DDFF } /* Name.Entity */
446
- .dark .codehilite .ne { color: #FFCB6B } /* Name.Exception */
447
- .dark .codehilite .nf { color: #82AAFF } /* Name.Function */
448
- .dark .codehilite .nl { color: #82AAFF } /* Name.Label */
449
- .dark .codehilite .nn { color: #FFCB6B } /* Name.Namespace */
450
- .dark .codehilite .nx { color: #EEFFFF } /* Name.Other */
451
- .dark .codehilite .py { color: #FFCB6B } /* Name.Property */
452
- .dark .codehilite .nt { color: #FF5370 } /* Name.Tag */
453
- .dark .codehilite .nv { color: #89DDFF } /* Name.Variable */
454
- .dark .codehilite .ow { color: #89DDFF; font-style: italic } /* Operator.Word */
455
- .dark .codehilite .pm { color: #89DDFF } /* Punctuation.Marker */
456
- .dark .codehilite .w { color: #EEFFFF } /* Text.Whitespace */
457
- .dark .codehilite .mb { color: #F78C6C } /* Literal.Number.Bin */
458
- .dark .codehilite .mf { color: #F78C6C } /* Literal.Number.Float */
459
- .dark .codehilite .mh { color: #F78C6C } /* Literal.Number.Hex */
460
- .dark .codehilite .mi { color: #F78C6C } /* Literal.Number.Integer */
461
- .dark .codehilite .mo { color: #F78C6C } /* Literal.Number.Oct */
462
- .dark .codehilite .sa { color: #BB80B3 } /* Literal.String.Affix */
463
- .dark .codehilite .sb { color: #C3E88D } /* Literal.String.Backtick */
464
- .dark .codehilite .sc { color: #C3E88D } /* Literal.String.Char */
465
- .dark .codehilite .dl { color: #EEFFFF } /* Literal.String.Delimiter */
466
- .dark .codehilite .sd { color: #79d618; font-style: italic } /* Literal.String.Doc */
467
- .dark .codehilite .s2 { color: #C3E88D } /* Literal.String.Double */
468
- .dark .codehilite .se { color: #EEFFFF } /* Literal.String.Escape */
469
- .dark .codehilite .sh { color: #C3E88D } /* Literal.String.Heredoc */
470
- .dark .codehilite .si { color: #89DDFF } /* Literal.String.Interpol */
471
- .dark .codehilite .sx { color: #C3E88D } /* Literal.String.Other */
472
- .dark .codehilite .sr { color: #89DDFF } /* Literal.String.Regex */
473
- .dark .codehilite .s1 { color: #C3E88D } /* Literal.String.Single */
474
- .dark .codehilite .ss { color: #89DDFF } /* Literal.String.Symbol */
475
- .dark .codehilite .bp { color: #89DDFF } /* Name.Builtin.Pseudo */
476
- .dark .codehilite .fm { color: #82AAFF } /* Name.Function.Magic */
477
- .dark .codehilite .vc { color: #89DDFF } /* Name.Variable.Class */
478
- .dark .codehilite .vg { color: #89DDFF } /* Name.Variable.Global */
479
- .dark .codehilite .vi { color: #89DDFF } /* Name.Variable.Instance */
480
- .dark .codehilite .vm { color: #82AAFF } /* Name.Variable.Magic */
481
- .dark .codehilite .il { color: #F78C6C } /* Literal.Number.Integer.Long */
482
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/contrast.py DELETED
@@ -1,89 +0,0 @@
1
- import os
2
- import gradio as gr
3
- from toolbox import get_conf
4
- CODE_HIGHLIGHT, ADD_WAIFU, LAYOUT = get_conf('CODE_HIGHLIGHT', 'ADD_WAIFU', 'LAYOUT')
5
- theme_dir = os.path.dirname(__file__)
6
-
7
- def adjust_theme():
8
-
9
- try:
10
- color_er = gr.themes.utils.colors.fuchsia
11
- set_theme = gr.themes.Default(
12
- primary_hue=gr.themes.utils.colors.orange,
13
- neutral_hue=gr.themes.utils.colors.gray,
14
- font=["Helvetica", "Microsoft YaHei", "ui-sans-serif", "sans-serif", "system-ui"],
15
- font_mono=["ui-monospace", "Consolas", "monospace"])
16
- set_theme.set(
17
- # Colors
18
- input_background_fill_dark="*neutral_800",
19
- # Transition
20
- button_transition="none",
21
- # Shadows
22
- button_shadow="*shadow_drop",
23
- button_shadow_hover="*shadow_drop_lg",
24
- button_shadow_active="*shadow_inset",
25
- input_shadow="0 0 0 *shadow_spread transparent, *shadow_inset",
26
- input_shadow_focus="0 0 0 *shadow_spread *secondary_50, *shadow_inset",
27
- input_shadow_focus_dark="0 0 0 *shadow_spread *neutral_700, *shadow_inset",
28
- checkbox_label_shadow="*shadow_drop",
29
- block_shadow="*shadow_drop",
30
- form_gap_width="1px",
31
- # Button borders
32
- input_border_width="1px",
33
- input_background_fill="white",
34
- # Gradients
35
- stat_background_fill="linear-gradient(to right, *primary_400, *primary_200)",
36
- stat_background_fill_dark="linear-gradient(to right, *primary_400, *primary_600)",
37
- error_background_fill=f"linear-gradient(to right, {color_er.c100}, *background_fill_secondary)",
38
- error_background_fill_dark="*background_fill_primary",
39
- checkbox_label_background_fill="linear-gradient(to top, *neutral_50, white)",
40
- checkbox_label_background_fill_dark="linear-gradient(to top, *neutral_900, *neutral_800)",
41
- checkbox_label_background_fill_hover="linear-gradient(to top, *neutral_100, white)",
42
- checkbox_label_background_fill_hover_dark="linear-gradient(to top, *neutral_900, *neutral_800)",
43
- button_primary_background_fill="linear-gradient(to bottom right, *primary_100, *primary_300)",
44
- button_primary_background_fill_dark="linear-gradient(to bottom right, *primary_500, *primary_600)",
45
- button_primary_background_fill_hover="linear-gradient(to bottom right, *primary_100, *primary_200)",
46
- button_primary_background_fill_hover_dark="linear-gradient(to bottom right, *primary_500, *primary_500)",
47
- button_primary_border_color_dark="*primary_500",
48
- button_secondary_background_fill="linear-gradient(to bottom right, *neutral_100, *neutral_200)",
49
- button_secondary_background_fill_dark="linear-gradient(to bottom right, *neutral_600, *neutral_700)",
50
- button_secondary_background_fill_hover="linear-gradient(to bottom right, *neutral_100, *neutral_100)",
51
- button_secondary_background_fill_hover_dark="linear-gradient(to bottom right, *neutral_600, *neutral_600)",
52
- button_cancel_background_fill=f"linear-gradient(to bottom right, {color_er.c100}, {color_er.c200})",
53
- button_cancel_background_fill_dark=f"linear-gradient(to bottom right, {color_er.c600}, {color_er.c700})",
54
- button_cancel_background_fill_hover=f"linear-gradient(to bottom right, {color_er.c100}, {color_er.c100})",
55
- button_cancel_background_fill_hover_dark=f"linear-gradient(to bottom right, {color_er.c600}, {color_er.c600})",
56
- button_cancel_border_color=color_er.c200,
57
- button_cancel_border_color_dark=color_er.c600,
58
- button_cancel_text_color=color_er.c600,
59
- button_cancel_text_color_dark="white",
60
- )
61
-
62
- with open(os.path.join(theme_dir, 'common.js'), 'r', encoding='utf8') as f:
63
- js = f"<script>{f.read()}</script>"
64
-
65
- # 添加一个萌萌的看板娘
66
- if ADD_WAIFU:
67
- js += """
68
- <script src="file=docs/waifu_plugin/jquery.min.js"></script>
69
- <script src="file=docs/waifu_plugin/jquery-ui.min.js"></script>
70
- <script src="file=docs/waifu_plugin/autoload.js"></script>
71
- """
72
- if not hasattr(gr, 'RawTemplateResponse'):
73
- gr.RawTemplateResponse = gr.routes.templates.TemplateResponse
74
- gradio_original_template_fn = gr.RawTemplateResponse
75
- def gradio_new_template_fn(*args, **kwargs):
76
- res = gradio_original_template_fn(*args, **kwargs)
77
- res.body = res.body.replace(b'</html>', f'{js}</html>'.encode("utf8"))
78
- res.init_headers()
79
- return res
80
- gr.routes.templates.TemplateResponse = gradio_new_template_fn # override gradio template
81
- except:
82
- set_theme = None
83
- print('gradio版本较旧, 不能自定义字体和颜色')
84
- return set_theme
85
-
86
- with open(os.path.join(theme_dir, 'contrast.css'), "r", encoding="utf-8") as f:
87
- advanced_css = f.read()
88
- with open(os.path.join(theme_dir, 'common.css'), "r", encoding="utf-8") as f:
89
- advanced_css += f.read()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/cookies.py DELETED
File without changes
themes/default.css DELETED
@@ -1,306 +0,0 @@
1
- /* 插件下拉菜单 */
2
- #elem_audio {
3
- border-style: hidden !important;
4
- }
5
-
6
- .dark {
7
- --background-fill-primary: #050810;
8
- --body-background-fill: var(--background-fill-primary);
9
- }
10
- /* 插件下拉菜单 */
11
- #plugin-panel .wrap.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
12
- box-shadow: var(--input-shadow);
13
- border: var(--input-border-width) dashed var(--border-color-primary);
14
- border-radius: 4px;
15
- }
16
-
17
- #plugin-panel .dropdown-arrow {
18
- width: 25px;
19
- }
20
- #plugin-panel input.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
21
- padding-left: 5px;
22
- }
23
-
24
- /* 小按钮 */
25
- #basic-panel .sm {
26
- font-family: "Microsoft YaHei UI", "Helvetica", "Microsoft YaHei", "ui-sans-serif", "sans-serif", "system-ui";
27
- --button-small-text-weight: 600;
28
- --button-small-text-size: 16px;
29
- border-bottom-right-radius: 6px;
30
- border-bottom-left-radius: 6px;
31
- border-top-right-radius: 6px;
32
- border-top-left-radius: 6px;
33
- }
34
-
35
- #plugin-panel .sm {
36
- font-family: "Microsoft YaHei UI", "Helvetica", "Microsoft YaHei", "ui-sans-serif", "sans-serif", "system-ui";
37
- --button-small-text-weight: 400;
38
- --button-small-text-size: 14px;
39
- border-bottom-right-radius: 6px;
40
- border-bottom-left-radius: 6px;
41
- border-top-right-radius: 6px;
42
- border-top-left-radius: 6px;
43
- }
44
-
45
- .wrap-inner.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
46
- padding: 0%;
47
- }
48
-
49
- .markdown-body table {
50
- margin: 1em 0;
51
- border-collapse: collapse;
52
- empty-cells: show;
53
- }
54
-
55
- .markdown-body th, .markdown-body td {
56
- border: 1.2px solid var(--border-color-primary);
57
- padding: 5px;
58
- }
59
-
60
- .markdown-body thead {
61
- background-color: rgba(175,184,193,0.2);
62
- }
63
-
64
- .markdown-body thead th {
65
- padding: .5em .2em;
66
- }
67
-
68
- .normal_mut_select .svelte-1gfkn6j {
69
- float: left;
70
- width: auto;
71
- line-height: 260% !important;
72
- }
73
-
74
- .markdown-body ol, .markdown-body ul {
75
- padding-inline-start: 2em !important;
76
- }
77
-
78
- /* chat box. */
79
- [class *= "message"] {
80
- border-radius: var(--radius-xl) !important;
81
- /* padding: var(--spacing-xl) !important; */
82
- /* font-size: var(--text-md) !important; */
83
- /* line-height: var(--line-md) !important; */
84
- /* min-height: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl)); */
85
- /* min-width: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl)); */
86
- }
87
- [data-testid = "bot"] {
88
- max-width: 95%;
89
- /* width: auto !important; */
90
- border-bottom-left-radius: 0 !important;
91
- }
92
- [data-testid = "user"] {
93
- max-width: 100%;
94
- /* width: auto !important; */
95
- border-bottom-right-radius: 0 !important;
96
- }
97
-
98
- /* linein code block. */
99
- .markdown-body code {
100
- display: inline;
101
- white-space: break-spaces;
102
- border-radius: 6px;
103
- margin: 0 2px 0 2px;
104
- padding: .2em .4em .1em .4em;
105
- background-color: rgba(13, 17, 23, 0.95);
106
- color: #c9d1d9;
107
- }
108
-
109
- .dark .markdown-body code {
110
- display: inline;
111
- white-space: break-spaces;
112
- border-radius: 6px;
113
- margin: 0 2px 0 2px;
114
- padding: .2em .4em .1em .4em;
115
- background-color: rgba(175,184,193,0.2);
116
- }
117
-
118
- /* code block css */
119
- .markdown-body pre code {
120
- display: block;
121
- overflow: auto;
122
- white-space: pre;
123
- background-color: rgba(13, 17, 23, 0.95);
124
- border-radius: 10px;
125
- padding: 1em;
126
- margin: 1em 2em 1em 0.5em;
127
- }
128
-
129
- .dark .markdown-body pre code {
130
- display: block;
131
- overflow: auto;
132
- white-space: pre;
133
- background-color: rgba(175,184,193,0.2);
134
- border-radius: 10px;
135
- padding: 1em;
136
- margin: 1em 2em 1em 0.5em;
137
- }
138
-
139
- /* .mic-wrap.svelte-1thnwz {
140
-
141
- } */
142
- .block.svelte-mppz8v > .mic-wrap.svelte-1thnwz{
143
- justify-content: center;
144
- display: flex;
145
- padding: 0;
146
-
147
- }
148
-
149
- .codehilite .hll { background-color: #6e7681 }
150
- .codehilite .c { color: #8b949e; font-style: italic } /* Comment */
151
- .codehilite .err { color: #f85149 } /* Error */
152
- .codehilite .esc { color: #c9d1d9 } /* Escape */
153
- .codehilite .g { color: #c9d1d9 } /* Generic */
154
- .codehilite .k { color: #ff7b72 } /* Keyword */
155
- .codehilite .l { color: #a5d6ff } /* Literal */
156
- .codehilite .n { color: #c9d1d9 } /* Name */
157
- .codehilite .o { color: #ff7b72; font-weight: bold } /* Operator */
158
- .codehilite .x { color: #c9d1d9 } /* Other */
159
- .codehilite .p { color: #c9d1d9 } /* Punctuation */
160
- .codehilite .ch { color: #8b949e; font-style: italic } /* Comment.Hashbang */
161
- .codehilite .cm { color: #8b949e; font-style: italic } /* Comment.Multiline */
162
- .codehilite .cp { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Preproc */
163
- .codehilite .cpf { color: #8b949e; font-style: italic } /* Comment.PreprocFile */
164
- .codehilite .c1 { color: #8b949e; font-style: italic } /* Comment.Single */
165
- .codehilite .cs { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Special */
166
- .codehilite .gd { color: #ffa198; background-color: #490202 } /* Generic.Deleted */
167
- .codehilite .ge { color: #c9d1d9; font-style: italic } /* Generic.Emph */
168
- .codehilite .gr { color: #ffa198 } /* Generic.Error */
169
- .codehilite .gh { color: #79c0ff; font-weight: bold } /* Generic.Heading */
170
- .codehilite .gi { color: #56d364; background-color: #0f5323 } /* Generic.Inserted */
171
- .codehilite .go { color: #8b949e } /* Generic.Output */
172
- .codehilite .gp { color: #8b949e } /* Generic.Prompt */
173
- .codehilite .gs { color: #c9d1d9; font-weight: bold } /* Generic.Strong */
174
- .codehilite .gu { color: #79c0ff } /* Generic.Subheading */
175
- .codehilite .gt { color: #ff7b72 } /* Generic.Traceback */
176
- .codehilite .g-Underline { color: #c9d1d9; text-decoration: underline } /* Generic.Underline */
177
- .codehilite .kc { color: #79c0ff } /* Keyword.Constant */
178
- .codehilite .kd { color: #ff7b72 } /* Keyword.Declaration */
179
- .codehilite .kn { color: #ff7b72 } /* Keyword.Namespace */
180
- .codehilite .kp { color: #79c0ff } /* Keyword.Pseudo */
181
- .codehilite .kr { color: #ff7b72 } /* Keyword.Reserved */
182
- .codehilite .kt { color: #ff7b72 } /* Keyword.Type */
183
- .codehilite .ld { color: #79c0ff } /* Literal.Date */
184
- .codehilite .m { color: #a5d6ff } /* Literal.Number */
185
- .codehilite .s { color: #a5d6ff } /* Literal.String */
186
- .codehilite .na { color: #c9d1d9 } /* Name.Attribute */
187
- .codehilite .nb { color: #c9d1d9 } /* Name.Builtin */
188
- .codehilite .nc { color: #f0883e; font-weight: bold } /* Name.Class */
189
- .codehilite .no { color: #79c0ff; font-weight: bold } /* Name.Constant */
190
- .codehilite .nd { color: #d2a8ff; font-weight: bold } /* Name.Decorator */
191
- .codehilite .ni { color: #ffa657 } /* Name.Entity */
192
- .codehilite .ne { color: #f0883e; font-weight: bold } /* Name.Exception */
193
- .codehilite .nf { color: #d2a8ff; font-weight: bold } /* Name.Function */
194
- .codehilite .nl { color: #79c0ff; font-weight: bold } /* Name.Label */
195
- .codehilite .nn { color: #ff7b72 } /* Name.Namespace */
196
- .codehilite .nx { color: #c9d1d9 } /* Name.Other */
197
- .codehilite .py { color: #79c0ff } /* Name.Property */
198
- .codehilite .nt { color: #7ee787 } /* Name.Tag */
199
- .codehilite .nv { color: #79c0ff } /* Name.Variable */
200
- .codehilite .ow { color: #ff7b72; font-weight: bold } /* Operator.Word */
201
- .codehilite .pm { color: #c9d1d9 } /* Punctuation.Marker */
202
- .codehilite .w { color: #6e7681 } /* Text.Whitespace */
203
- .codehilite .mb { color: #a5d6ff } /* Literal.Number.Bin */
204
- .codehilite .mf { color: #a5d6ff } /* Literal.Number.Float */
205
- .codehilite .mh { color: #a5d6ff } /* Literal.Number.Hex */
206
- .codehilite .mi { color: #a5d6ff } /* Literal.Number.Integer */
207
- .codehilite .mo { color: #a5d6ff } /* Literal.Number.Oct */
208
- .codehilite .sa { color: #79c0ff } /* Literal.String.Affix */
209
- .codehilite .sb { color: #a5d6ff } /* Literal.String.Backtick */
210
- .codehilite .sc { color: #a5d6ff } /* Literal.String.Char */
211
- .codehilite .dl { color: #79c0ff } /* Literal.String.Delimiter */
212
- .codehilite .sd { color: #a5d6ff } /* Literal.String.Doc */
213
- .codehilite .s2 { color: #a5d6ff } /* Literal.String.Double */
214
- .codehilite .se { color: #79c0ff } /* Literal.String.Escape */
215
- .codehilite .sh { color: #79c0ff } /* Literal.String.Heredoc */
216
- .codehilite .si { color: #a5d6ff } /* Literal.String.Interpol */
217
- .codehilite .sx { color: #a5d6ff } /* Literal.String.Other */
218
- .codehilite .sr { color: #79c0ff } /* Literal.String.Regex */
219
- .codehilite .s1 { color: #a5d6ff } /* Literal.String.Single */
220
- .codehilite .ss { color: #a5d6ff } /* Literal.String.Symbol */
221
- .codehilite .bp { color: #c9d1d9 } /* Name.Builtin.Pseudo */
222
- .codehilite .fm { color: #d2a8ff; font-weight: bold } /* Name.Function.Magic */
223
- .codehilite .vc { color: #79c0ff } /* Name.Variable.Class */
224
- .codehilite .vg { color: #79c0ff } /* Name.Variable.Global */
225
- .codehilite .vi { color: #79c0ff } /* Name.Variable.Instance */
226
- .codehilite .vm { color: #79c0ff } /* Name.Variable.Magic */
227
- .codehilite .il { color: #a5d6ff } /* Literal.Number.Integer.Long */
228
-
229
- .dark .codehilite .hll { background-color: #2C3B41 }
230
- .dark .codehilite .c { color: #79d618; font-style: italic } /* Comment */
231
- .dark .codehilite .err { color: #FF5370 } /* Error */
232
- .dark .codehilite .esc { color: #89DDFF } /* Escape */
233
- .dark .codehilite .g { color: #EEFFFF } /* Generic */
234
- .dark .codehilite .k { color: #BB80B3 } /* Keyword */
235
- .dark .codehilite .l { color: #C3E88D } /* Literal */
236
- .dark .codehilite .n { color: #EEFFFF } /* Name */
237
- .dark .codehilite .o { color: #89DDFF } /* Operator */
238
- .dark .codehilite .p { color: #89DDFF } /* Punctuation */
239
- .dark .codehilite .ch { color: #79d618; font-style: italic } /* Comment.Hashbang */
240
- .dark .codehilite .cm { color: #79d618; font-style: italic } /* Comment.Multiline */
241
- .dark .codehilite .cp { color: #79d618; font-style: italic } /* Comment.Preproc */
242
- .dark .codehilite .cpf { color: #79d618; font-style: italic } /* Comment.PreprocFile */
243
- .dark .codehilite .c1 { color: #79d618; font-style: italic } /* Comment.Single */
244
- .dark .codehilite .cs { color: #79d618; font-style: italic } /* Comment.Special */
245
- .dark .codehilite .gd { color: #FF5370 } /* Generic.Deleted */
246
- .dark .codehilite .ge { color: #89DDFF } /* Generic.Emph */
247
- .dark .codehilite .gr { color: #FF5370 } /* Generic.Error */
248
- .dark .codehilite .gh { color: #C3E88D } /* Generic.Heading */
249
- .dark .codehilite .gi { color: #C3E88D } /* Generic.Inserted */
250
- .dark .codehilite .go { color: #79d618 } /* Generic.Output */
251
- .dark .codehilite .gp { color: #FFCB6B } /* Generic.Prompt */
252
- .dark .codehilite .gs { color: #FF5370 } /* Generic.Strong */
253
- .dark .codehilite .gu { color: #89DDFF } /* Generic.Subheading */
254
- .dark .codehilite .gt { color: #FF5370 } /* Generic.Traceback */
255
- .dark .codehilite .kc { color: #89DDFF } /* Keyword.Constant */
256
- .dark .codehilite .kd { color: #BB80B3 } /* Keyword.Declaration */
257
- .dark .codehilite .kn { color: #89DDFF; font-style: italic } /* Keyword.Namespace */
258
- .dark .codehilite .kp { color: #89DDFF } /* Keyword.Pseudo */
259
- .dark .codehilite .kr { color: #BB80B3 } /* Keyword.Reserved */
260
- .dark .codehilite .kt { color: #BB80B3 } /* Keyword.Type */
261
- .dark .codehilite .ld { color: #C3E88D } /* Literal.Date */
262
- .dark .codehilite .m { color: #F78C6C } /* Literal.Number */
263
- .dark .codehilite .s { color: #C3E88D } /* Literal.String */
264
- .dark .codehilite .na { color: #BB80B3 } /* Name.Attribute */
265
- .dark .codehilite .nb { color: #82AAFF } /* Name.Builtin */
266
- .dark .codehilite .nc { color: #FFCB6B } /* Name.Class */
267
- .dark .codehilite .no { color: #EEFFFF } /* Name.Constant */
268
- .dark .codehilite .nd { color: #82AAFF } /* Name.Decorator */
269
- .dark .codehilite .ni { color: #89DDFF } /* Name.Entity */
270
- .dark .codehilite .ne { color: #FFCB6B } /* Name.Exception */
271
- .dark .codehilite .nf { color: #82AAFF } /* Name.Function */
272
- .dark .codehilite .nl { color: #82AAFF } /* Name.Label */
273
- .dark .codehilite .nn { color: #FFCB6B } /* Name.Namespace */
274
- .dark .codehilite .nx { color: #EEFFFF } /* Name.Other */
275
- .dark .codehilite .py { color: #FFCB6B } /* Name.Property */
276
- .dark .codehilite .nt { color: #FF5370 } /* Name.Tag */
277
- .dark .codehilite .nv { color: #89DDFF } /* Name.Variable */
278
- .dark .codehilite .ow { color: #89DDFF; font-style: italic } /* Operator.Word */
279
- .dark .codehilite .pm { color: #89DDFF } /* Punctuation.Marker */
280
- .dark .codehilite .w { color: #EEFFFF } /* Text.Whitespace */
281
- .dark .codehilite .mb { color: #F78C6C } /* Literal.Number.Bin */
282
- .dark .codehilite .mf { color: #F78C6C } /* Literal.Number.Float */
283
- .dark .codehilite .mh { color: #F78C6C } /* Literal.Number.Hex */
284
- .dark .codehilite .mi { color: #F78C6C } /* Literal.Number.Integer */
285
- .dark .codehilite .mo { color: #F78C6C } /* Literal.Number.Oct */
286
- .dark .codehilite .sa { color: #BB80B3 } /* Literal.String.Affix */
287
- .dark .codehilite .sb { color: #C3E88D } /* Literal.String.Backtick */
288
- .dark .codehilite .sc { color: #C3E88D } /* Literal.String.Char */
289
- .dark .codehilite .dl { color: #EEFFFF } /* Literal.String.Delimiter */
290
- .dark .codehilite .sd { color: #79d618; font-style: italic } /* Literal.String.Doc */
291
- .dark .codehilite .s2 { color: #C3E88D } /* Literal.String.Double */
292
- .dark .codehilite .se { color: #EEFFFF } /* Literal.String.Escape */
293
- .dark .codehilite .sh { color: #C3E88D } /* Literal.String.Heredoc */
294
- .dark .codehilite .si { color: #89DDFF } /* Literal.String.Interpol */
295
- .dark .codehilite .sx { color: #C3E88D } /* Literal.String.Other */
296
- .dark .codehilite .sr { color: #89DDFF } /* Literal.String.Regex */
297
- .dark .codehilite .s1 { color: #C3E88D } /* Literal.String.Single */
298
- .dark .codehilite .ss { color: #89DDFF } /* Literal.String.Symbol */
299
- .dark .codehilite .bp { color: #89DDFF } /* Name.Builtin.Pseudo */
300
- .dark .codehilite .fm { color: #82AAFF } /* Name.Function.Magic */
301
- .dark .codehilite .vc { color: #89DDFF } /* Name.Variable.Class */
302
- .dark .codehilite .vg { color: #89DDFF } /* Name.Variable.Global */
303
- .dark .codehilite .vi { color: #89DDFF } /* Name.Variable.Instance */
304
- .dark .codehilite .vm { color: #82AAFF } /* Name.Variable.Magic */
305
- .dark .codehilite .il { color: #F78C6C } /* Literal.Number.Integer.Long */
306
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/default.py DELETED
@@ -1,88 +0,0 @@
1
- import os
2
- import gradio as gr
3
- from toolbox import get_conf
4
- CODE_HIGHLIGHT, ADD_WAIFU, LAYOUT = get_conf('CODE_HIGHLIGHT', 'ADD_WAIFU', 'LAYOUT')
5
- theme_dir = os.path.dirname(__file__)
6
- def adjust_theme():
7
-
8
- try:
9
- color_er = gr.themes.utils.colors.fuchsia
10
- set_theme = gr.themes.Default(
11
- primary_hue=gr.themes.utils.colors.orange,
12
- neutral_hue=gr.themes.utils.colors.gray,
13
- font=["Helvetica", "Microsoft YaHei", "ui-sans-serif", "sans-serif", "system-ui"],
14
- font_mono=["ui-monospace", "Consolas", "monospace"])
15
- set_theme.set(
16
- # Colors
17
- input_background_fill_dark="*neutral_800",
18
- # Transition
19
- button_transition="none",
20
- # Shadows
21
- button_shadow="*shadow_drop",
22
- button_shadow_hover="*shadow_drop_lg",
23
- button_shadow_active="*shadow_inset",
24
- input_shadow="0 0 0 *shadow_spread transparent, *shadow_inset",
25
- input_shadow_focus="0 0 0 *shadow_spread *secondary_50, *shadow_inset",
26
- input_shadow_focus_dark="0 0 0 *shadow_spread *neutral_700, *shadow_inset",
27
- checkbox_label_shadow="*shadow_drop",
28
- block_shadow="*shadow_drop",
29
- form_gap_width="1px",
30
- # Button borders
31
- input_border_width="1px",
32
- input_background_fill="white",
33
- # Gradients
34
- stat_background_fill="linear-gradient(to right, *primary_400, *primary_200)",
35
- stat_background_fill_dark="linear-gradient(to right, *primary_400, *primary_600)",
36
- error_background_fill=f"linear-gradient(to right, {color_er.c100}, *background_fill_secondary)",
37
- error_background_fill_dark="*background_fill_primary",
38
- checkbox_label_background_fill="linear-gradient(to top, *neutral_50, white)",
39
- checkbox_label_background_fill_dark="linear-gradient(to top, *neutral_900, *neutral_800)",
40
- checkbox_label_background_fill_hover="linear-gradient(to top, *neutral_100, white)",
41
- checkbox_label_background_fill_hover_dark="linear-gradient(to top, *neutral_900, *neutral_800)",
42
- button_primary_background_fill="linear-gradient(to bottom right, *primary_100, *primary_300)",
43
- button_primary_background_fill_dark="linear-gradient(to bottom right, *primary_500, *primary_600)",
44
- button_primary_background_fill_hover="linear-gradient(to bottom right, *primary_100, *primary_200)",
45
- button_primary_background_fill_hover_dark="linear-gradient(to bottom right, *primary_500, *primary_500)",
46
- button_primary_border_color_dark="*primary_500",
47
- button_secondary_background_fill="linear-gradient(to bottom right, *neutral_100, *neutral_200)",
48
- button_secondary_background_fill_dark="linear-gradient(to bottom right, *neutral_600, *neutral_700)",
49
- button_secondary_background_fill_hover="linear-gradient(to bottom right, *neutral_100, *neutral_100)",
50
- button_secondary_background_fill_hover_dark="linear-gradient(to bottom right, *neutral_600, *neutral_600)",
51
- button_cancel_background_fill=f"linear-gradient(to bottom right, {color_er.c100}, {color_er.c200})",
52
- button_cancel_background_fill_dark=f"linear-gradient(to bottom right, {color_er.c600}, {color_er.c700})",
53
- button_cancel_background_fill_hover=f"linear-gradient(to bottom right, {color_er.c100}, {color_er.c100})",
54
- button_cancel_background_fill_hover_dark=f"linear-gradient(to bottom right, {color_er.c600}, {color_er.c600})",
55
- button_cancel_border_color=color_er.c200,
56
- button_cancel_border_color_dark=color_er.c600,
57
- button_cancel_text_color=color_er.c600,
58
- button_cancel_text_color_dark="white",
59
- )
60
-
61
- with open(os.path.join(theme_dir, 'common.js'), 'r', encoding='utf8') as f:
62
- js = f"<script>{f.read()}</script>"
63
-
64
- # 添加一个萌萌的看板娘
65
- if ADD_WAIFU:
66
- js += """
67
- <script src="file=docs/waifu_plugin/jquery.min.js"></script>
68
- <script src="file=docs/waifu_plugin/jquery-ui.min.js"></script>
69
- <script src="file=docs/waifu_plugin/autoload.js"></script>
70
- """
71
- if not hasattr(gr, 'RawTemplateResponse'):
72
- gr.RawTemplateResponse = gr.routes.templates.TemplateResponse
73
- gradio_original_template_fn = gr.RawTemplateResponse
74
- def gradio_new_template_fn(*args, **kwargs):
75
- res = gradio_original_template_fn(*args, **kwargs)
76
- res.body = res.body.replace(b'</html>', f'{js}</html>'.encode("utf8"))
77
- res.init_headers()
78
- return res
79
- gr.routes.templates.TemplateResponse = gradio_new_template_fn # override gradio template
80
- except:
81
- set_theme = None
82
- print('gradio版本较旧, 不能自定义字体和颜色')
83
- return set_theme
84
-
85
- with open(os.path.join(theme_dir, 'default.css'), "r", encoding="utf-8") as f:
86
- advanced_css = f.read()
87
- with open(os.path.join(theme_dir, 'common.css'), "r", encoding="utf-8") as f:
88
- advanced_css += f.read()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/gradios.py DELETED
@@ -1,53 +0,0 @@
1
- import logging
2
- import os
3
- import gradio as gr
4
- from toolbox import get_conf, ProxyNetworkActivate
5
- CODE_HIGHLIGHT, ADD_WAIFU, LAYOUT = get_conf('CODE_HIGHLIGHT', 'ADD_WAIFU', 'LAYOUT')
6
- theme_dir = os.path.dirname(__file__)
7
-
8
- def dynamic_set_theme(THEME):
9
- set_theme = gr.themes.ThemeClass()
10
- with ProxyNetworkActivate('Download_Gradio_Theme'):
11
- logging.info('正在下载Gradio主题,请稍等。')
12
- if THEME.startswith('Huggingface-'): THEME = THEME.lstrip('Huggingface-')
13
- if THEME.startswith('huggingface-'): THEME = THEME.lstrip('huggingface-')
14
- set_theme = set_theme.from_hub(THEME.lower())
15
- return set_theme
16
-
17
- def adjust_theme():
18
- try:
19
- set_theme = gr.themes.ThemeClass()
20
- with ProxyNetworkActivate('Download_Gradio_Theme'):
21
- logging.info('正在下载Gradio主题,请稍等。')
22
- THEME = get_conf('THEME')
23
- if THEME.startswith('Huggingface-'): THEME = THEME.lstrip('Huggingface-')
24
- if THEME.startswith('huggingface-'): THEME = THEME.lstrip('huggingface-')
25
- set_theme = set_theme.from_hub(THEME.lower())
26
-
27
- with open(os.path.join(theme_dir, 'common.js'), 'r', encoding='utf8') as f:
28
- js = f"<script>{f.read()}</script>"
29
-
30
- # 添加一个萌萌的看板娘
31
- if ADD_WAIFU:
32
- js += """
33
- <script src="file=docs/waifu_plugin/jquery.min.js"></script>
34
- <script src="file=docs/waifu_plugin/jquery-ui.min.js"></script>
35
- <script src="file=docs/waifu_plugin/autoload.js"></script>
36
- """
37
- if not hasattr(gr, 'RawTemplateResponse'):
38
- gr.RawTemplateResponse = gr.routes.templates.TemplateResponse
39
- gradio_original_template_fn = gr.RawTemplateResponse
40
- def gradio_new_template_fn(*args, **kwargs):
41
- res = gradio_original_template_fn(*args, **kwargs)
42
- res.body = res.body.replace(b'</html>', f'{js}</html>'.encode("utf8"))
43
- res.init_headers()
44
- return res
45
- gr.routes.templates.TemplateResponse = gradio_new_template_fn # override gradio template
46
- except Exception as e:
47
- set_theme = None
48
- from toolbox import trimmed_format_exc
49
- logging.error('gradio版本较旧, 不能自定义字体和颜色:', trimmed_format_exc())
50
- return set_theme
51
-
52
- with open(os.path.join(theme_dir, 'common.css'), "r", encoding="utf-8") as f:
53
- advanced_css = f.read()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/green.css DELETED
@@ -1,831 +0,0 @@
1
- :root {
2
- --chatbot-color-light: #000000;
3
- --chatbot-color-dark: #FFFFFF;
4
- --chatbot-background-color-light: #F3F3F3;
5
- --chatbot-background-color-dark: #121111;
6
- --message-user-background-color-light: #95EC69;
7
- --message-user-background-color-dark: #26B561;
8
- --message-bot-background-color-light: #FFFFFF;
9
- --message-bot-background-color-dark: #2C2C2C;
10
- }
11
- mspace {
12
- display: block;
13
- }
14
- @media only screen and (max-width: 767px) {
15
- #column_1 {
16
- display: none !important;
17
- }
18
- }
19
- @keyframes highlight {
20
- 0%, 100% {
21
- border: 2px solid transparent;
22
- }
23
- 50% {
24
- border-color: yellow;
25
- }
26
- }
27
- .normal_mut_select .svelte-1gfkn6j {
28
- float: left;
29
- width: auto;
30
- line-height: 260% !important;
31
- }
32
- #highlight_update {
33
- animation-name: highlight;
34
- animation-duration: 0.75s;
35
- animation-iteration-count: 3;
36
- }
37
-
38
- .table-wrap.svelte-13hsdno.svelte-13hsdno.svelte-13hsdno {
39
- border: 0px solid var(--border-color-primary) !important;
40
- }
41
-
42
- #examples_col {
43
- z-index: 2;
44
- position: absolute;
45
- bottom: 0;
46
- left: 0;
47
- width: 100%;
48
- margin-bottom: 30% !important;
49
- }
50
- #hide_examples {
51
- z-index: 0;
52
- }
53
-
54
- #debug_mes {
55
- position: absolute;
56
- display: flex;
57
- bottom: 0;
58
- left: 0;
59
- z-index: 1; /* 设置更高的 z-index 值 */
60
- margin-bottom: -4px !important;
61
- align-self: flex-end;
62
- }
63
- #chat_box {
64
- display: flex;
65
- flex-direction: column;
66
- overflow-y: visible !important;
67
- z-index: 3;
68
- flex-grow: 1; /* 自动填充剩余空间 */
69
- position: absolute;
70
- bottom: 0;
71
- left: 0;
72
- width: 100%;
73
- margin-bottom: 30px !important;
74
- border: 1px solid var(--border-color-primary);
75
- }
76
- .toast-body {
77
- z-index: 5 !important;
78
- }
79
- .chat_input {
80
-
81
- }
82
- .sm_btn {
83
- position: relative;
84
- bottom: 5px;
85
- height: 10%;
86
- border-radius: 20px!important;
87
- min-width: min(10%,100%) !important;
88
- overflow: hidden;
89
- }
90
- .sm_select {
91
- position: relative !important;
92
- z-index: 5 !important;
93
- bottom: 5px;
94
- min-width: min(20%,100%) !important;
95
- border-radius: 20px!important;
96
- }
97
- .sm_checkbox {
98
- position: relative !important;
99
- z-index: 5 !important;
100
- bottom: 5px;
101
- padding: 0 !important;
102
- }
103
- .sm_select .wrap-inner.svelte-aqlk7e.svelte-aqlk7e.svelte-aqlk7e {
104
- padding: 0 !important;
105
- }
106
- .sm_select .block.svelte-mppz8v {
107
- width: 10% !important;
108
- }
109
-
110
- button.sm {
111
- padding: 6px 8px !important;
112
- }
113
-
114
- /* usage_display */
115
- .insert_block {
116
- position: relative;
117
- bottom: 2px;
118
- min-width: min(55px,100%) !important;
119
- }
120
-
121
- .submit_btn {
122
- flex-direction: column-reverse;
123
- overflow-y: auto !important;
124
- position: absolute;
125
- bottom: 0;
126
- right: 10px;
127
- margin-bottom: 10px !important;
128
- min-width: min(50px,100%) !important;
129
- }
130
-
131
- textarea {
132
- resize: none;
133
- height: 100%; /* 填充父元素的高度 */
134
- }
135
- /* #main_chatbot {
136
- height: 75vh !important;
137
- max-height: 75vh !important;
138
- overflow: auto !important;
139
- z-index: 2;
140
- transform: translateZ(0) !important;
141
- backface-visibility: hidden !important;
142
- will-change: transform !important;
143
- } */
144
- #prompt_result{
145
- height: 60vh !important;
146
- max-height: 60vh !important;
147
- }
148
-
149
- #app_title {
150
- font-weight: var(--prose-header-text-weight);
151
- font-size: var(--text-xxl);
152
- line-height: 1.3;
153
- text-align: left;
154
- margin-top: 6px;
155
- white-space: nowrap;
156
- }
157
- #description {
158
- text-align: center;
159
- margin: 32px 0 4px 0;
160
- }
161
-
162
- /* gradio的页脚信息 */
163
- footer {
164
- /* display: none !important; */
165
- margin-top: .2em !important;
166
- font-size: 85%;
167
- }
168
- #footer {
169
- text-align: center;
170
- }
171
- #footer div {
172
- display: inline-block;
173
- }
174
- #footer .versions{
175
- font-size: 85%;
176
- opacity: 0.60;
177
- }
178
- /* user_info */
179
-
180
- #float_display {
181
- position: absolute;
182
- max-height: 30px;
183
- }
184
- /* user_info */
185
- #user_info {
186
- white-space: nowrap;
187
- position: absolute; left: 8em; top: .2em;
188
- z-index: var(--layer-2);
189
- box-shadow: var(--block-shadow);
190
- border: none; border-radius: var(--block-label-radius);
191
- background: var(--color-accent);
192
- padding: var(--block-label-padding);
193
- font-size: var(--block-label-text-size); line-height: var(--line-sm);
194
- width: auto; min-height: 30px !important;
195
- opacity: 1;
196
- transition: opacity 0.3s ease-in-out;
197
- }
198
- textarea.svelte-1pie7s6 {
199
- background: #e7e6e6 !important;
200
- width: 96% !important;
201
- }
202
-
203
- .dark textarea.svelte-1pie7s6 {
204
- background: var(--input-background-fill) !important;
205
- width: 96% !important;
206
- }
207
-
208
- .dark input[type=number].svelte-1cl284s {
209
- background: #393939 !important;
210
- border: var(--input-border-width) solid var(--input-border-color) !important;
211
- }
212
- /* .dark input[type="range"] {
213
- background: #393939 !important;
214
- } */
215
- #user_info .wrap {
216
- opacity: 0;
217
- }
218
- #user_info p {
219
- color: white;
220
- font-weight: var(--block-label-text-weight);
221
- }
222
- #user_info.hideK {
223
- opacity: 0;
224
- transition: opacity 1s ease-in-out;
225
- }
226
- [class *= "message"] {
227
- gap: 7px !important;
228
- border-radius: var(--radius-xl) !important
229
- }
230
- /* debug_mes */
231
- #debug_mes {
232
- min-height: 2em;
233
- align-items: flex-end;
234
- justify-content: flex-end;
235
- }
236
- #debug_mes p {
237
- font-size: .85em;
238
- font-family: ui-monospace, "SF Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "Microsoft Yahei UI", "Microsoft Yahei", monospace;
239
- /* Windows下中文的monospace会fallback为新宋体,实在太丑,这里折中使用微软雅黑 */
240
- color: #000000;
241
- }
242
- .dark #debug_mes p {
243
- color: #ee65ed;
244
- }
245
-
246
- #debug_mes {
247
- transition: all 0.6s;
248
- }
249
- #gpt-chatbot {
250
- transition: height 0.3s ease;
251
- }
252
-
253
- /* .wrap.svelte-18telvq.svelte-18telvq {
254
- padding: var(--block-padding) !important;
255
- height: 100% !important;
256
- max-height: 95% !important;
257
- overflow-y: auto !important;
258
- }*/
259
- /* .app.svelte-1mya07g.svelte-1mya07g {
260
- max-width: 100%;
261
- position: relative;
262
- padding: var(--size-4);
263
- width: 100%;
264
- height: 100%;
265
- } */
266
-
267
- .gradio-container-3-32-2 h1 {
268
- font-weight: 700 !important;
269
- font-size: 28px !important;
270
- }
271
-
272
-
273
- .gradio-container-3-32-2 h2 {
274
- font-weight: 600 !important;
275
- font-size: 24px !important;
276
- }
277
- .gradio-container-3-32-2 h3 {
278
- font-weight: 500 !important;
279
- font-size: 20px !important;
280
- }
281
- .gradio-container-3-32-2 h4 {
282
- font-weight: 400 !important;
283
- font-size: 16px !important;
284
- }
285
- .gradio-container-3-32-2 h5 {
286
- font-weight: 300 !important;
287
- font-size: 14px !important;
288
- }
289
- .gradio-container-3-32-2 h6 {
290
- font-weight: 200 !important;
291
- font-size: 12px !important;
292
- }
293
-
294
-
295
- #usage_display p, #usage_display span {
296
- margin: 0;
297
- font-size: .85em;
298
- color: var(--body-text-color-subdued);
299
- }
300
- .progress-bar {
301
- background-color: var(--input-background-fill);;
302
- margin: .5em 0 !important;
303
- height: 20px;
304
- border-radius: 10px;
305
- overflow: hidden;
306
- }
307
- .progress {
308
- background-color: var(--block-title-background-fill);
309
- height: 100%;
310
- border-radius: 10px;
311
- text-align: right;
312
- transition: width 0.5s ease-in-out;
313
- }
314
- .progress-text {
315
- /* color: white; */
316
- color: var(--color-accent) !important;
317
- font-size: 1em !important;
318
- font-weight: bold;
319
- padding-right: 10px;
320
- line-height: 20px;
321
- }
322
-
323
- .apSwitch {
324
- top: 2px;
325
- display: inline-block;
326
- height: 24px;
327
- position: relative;
328
- width: 48px;
329
- border-radius: 12px;
330
- }
331
- .apSwitch input {
332
- display: none !important;
333
- }
334
- .apSlider {
335
- background-color: var(--neutral-200);
336
- bottom: 0;
337
- cursor: pointer;
338
- left: 0;
339
- position: absolute;
340
- right: 0;
341
- top: 0;
342
- transition: .4s;
343
- font-size: 18px;
344
- border-radius: 7px;
345
- }
346
- .apSlider::before {
347
- bottom: -1.5px;
348
- left: 1px;
349
- position: absolute;
350
- transition: .4s;
351
- content: "🌞";
352
- }
353
- hr.append-display {
354
- margin: 8px 0;
355
- border: none;
356
- height: 1px;
357
- border-top-width: 0;
358
- background-image: linear-gradient(to right, rgba(50,50,50, 0.1), rgba(150, 150, 150, 0.8), rgba(50,50,50, 0.1));
359
- }
360
- .source-a {
361
- font-size: 0.8em;
362
- max-width: 100%;
363
- margin: 0;
364
- display: flex;
365
- flex-direction: row;
366
- flex-wrap: wrap;
367
- align-items: center;
368
- /* background-color: #dddddd88; */
369
- border-radius: 1.5rem;
370
- padding: 0.2em;
371
- }
372
- .source-a a {
373
- display: inline-block;
374
- background-color: #aaaaaa50;
375
- border-radius: 1rem;
376
- padding: 0.5em;
377
- text-align: center;
378
- text-overflow: ellipsis;
379
- overflow: hidden;
380
- min-width: 20%;
381
- white-space: nowrap;
382
- margin: 0.2rem 0.1rem;
383
- text-decoration: none !important;
384
- flex: 1;
385
- transition: flex 0.5s;
386
- }
387
- .source-a a:hover {
388
- background-color: #aaaaaa20;
389
- flex: 2;
390
- }
391
- input:checked + .apSlider {
392
- background-color: var(--primary-600);
393
- }
394
- input:checked + .apSlider::before {
395
- transform: translateX(23px);
396
- content:"🌚";
397
- }
398
-
399
- /* Override Slider Styles (for webkit browsers like Safari and Chrome)
400
- * 好希望这份提案能早日实现 https://github.com/w3c/csswg-drafts/issues/4410
401
- * 进度滑块在各个平台还是太不统一了
402
- */
403
- input[type="range"] {
404
- -webkit-appearance: none;
405
- height: 4px;
406
- background: var(--input-background-fill);
407
- border-radius: 5px;
408
- background-image: linear-gradient(var(--primary-500),var(--primary-500));
409
- background-size: 0% 100%;
410
- background-repeat: no-repeat;
411
- }
412
- input[type="range"]::-webkit-slider-thumb {
413
- -webkit-appearance: none;
414
- height: 20px;
415
- width: 20px;
416
- border-radius: 50%;
417
- border: solid 0.5px #ddd;
418
- background-color: white;
419
- cursor: ew-resize;
420
- box-shadow: var(--input-shadow);
421
- transition: background-color .1s ease;
422
- }
423
- input[type="range"]::-webkit-slider-thumb:hover {
424
- background: var(--neutral-50);
425
- }
426
- input[type="range"]::-webkit-slider-runnable-track {
427
- -webkit-appearance: none;
428
- box-shadow: none;
429
- border: none;
430
- background: transparent;
431
- }
432
-
433
- .submit_btn, #cancel_btn {
434
- height: 42px !important;
435
- }
436
- .submit_btn::before {
437
- content: url("data:image/svg+xml, %3Csvg width='21px' height='20px' viewBox='0 0 21 20' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='page' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='send' transform='translate(0.435849, 0.088463)' fill='%23FFFFFF' fill-rule='nonzero'%3E %3Cpath d='M0.579148261,0.0428666046 C0.301105539,-0.0961547561 -0.036517765,0.122307382 0.0032026237,0.420210298 L1.4927172,18.1553639 C1.5125774,18.4334066 1.79062012,18.5922882 2.04880264,18.4929872 L8.24518329,15.8913017 L11.6412765,19.7441794 C11.8597387,19.9825018 12.2370824,19.8832008 12.3165231,19.5852979 L13.9450591,13.4882182 L19.7839562,11.0255541 C20.0619989,10.8865327 20.0818591,10.4694687 19.7839562,10.3105871 L0.579148261,0.0428666046 Z M11.6138902,17.0883151 L9.85385903,14.7195502 L0.718169621,0.618812241 L12.69945,12.9346347 L11.6138902,17.0883151 Z' id='shape'%3E%3C/path%3E %3C/g%3E %3C/g%3E %3C/svg%3E");
438
- height: 21px;
439
- }
440
-
441
- #cancel_btn::before {
442
- content: url("data:image/svg+xml,%3Csvg width='21px' height='21px' viewBox='0 0 21 21' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='pg' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cpath d='M10.2072007,20.088463 C11.5727865,20.088463 12.8594566,19.8259823 14.067211,19.3010209 C15.2749653,18.7760595 16.3386126,18.0538087 17.2581528,17.1342685 C18.177693,16.2147282 18.8982283,15.1527965 19.4197586,13.9484733 C19.9412889,12.7441501 20.202054,11.4557644 20.202054,10.0833163 C20.202054,8.71773046 19.9395733,7.43106036 19.4146119,6.22330603 C18.8896505,5.01555169 18.1673997,3.95018885 17.2478595,3.0272175 C16.3283192,2.10424615 15.2646719,1.3837109 14.0569176,0.865611739 C12.8491633,0.34751258 11.5624932,0.088463 10.1969073,0.088463 C8.83132146,0.088463 7.54636692,0.34751258 6.34204371,0.865611739 C5.1377205,1.3837109 4.07407321,2.10424615 3.15110186,3.0272175 C2.22813051,3.95018885 1.5058797,5.01555169 0.984349419,6.22330603 C0.46281914,7.43106036 0.202054,8.71773046 0.202054,10.0833163 C0.202054,11.4557644 0.4645347,12.7441501 0.9894961,13.9484733 C1.5144575,15.1527965 2.23670831,16.2147282 3.15624854,17.1342685 C4.07578877,18.0538087 5.1377205,18.7760595 6.34204371,19.3010209 C7.54636692,19.8259823 8.83475258,20.088463 10.2072007,20.088463 Z M10.2072007,18.2562448 C9.07493099,18.2562448 8.01471483,18.0452309 7.0265522,17.6232031 C6.03838956,17.2011753 5.17031614,16.6161693 4.42233192,15.8681851 C3.6743477,15.1202009 3.09105726,14.2521274 2.67246059,13.2639648 C2.25386392,12.2758022 2.04456558,11.215586 2.04456558,10.0833163 C2.04456558,8.95104663 2.25386392,7.89083047 2.67246059,6.90266784 C3.09105726,5.9145052 3.6743477,5.04643178 4.42233192,4.29844756 C5.17031614,3.55046334 6.036674,2.9671729 7.02140552,2.54857623 C8.00613703,2.12997956 9.06463763,1.92068122 10.1969073,1.92068122 C11.329177,1.92068122 12.3911087,2.12997956 13.3827025,2.54857623 C14.3742962,2.9671729 15.2440852,3.55046334 15.9920694,4.29844756 C16.7400537,5.04643178 17.3233441,5.9145052 17.7419408,6.90266784 C18.1605374,7.89083047 18.3698358,8.95104663 18.3698358,10.0833163 C18.3698358,11.215586 18.1605374,12.2758022 17.7419408,13.2639648 C17.3233441,14.2521274 16.7400537,15.1202009 15.9920694,15.8681851 C15.2440852,16.6161693 14.3760118,17.2011753 13.3878492,17.6232031 C12.3996865,18.0452309 11.3394704,18.2562448 10.2072007,18.2562448 Z M7.65444721,13.6242324 L12.7496608,13.6242324 C13.0584616,13.6242324 13.3003556,13.5384544 13.4753427,13.3668984 C13.6503299,13.1953424 13.7378234,12.9585951 13.7378234,12.6566565 L13.7378234,7.49968276 C13.7378234,7.19774418 13.6503299,6.96099688 13.4753427,6.78944087 C13.3003556,6.61788486 13.0584616,6.53210685 12.7496608,6.53210685 L7.65444721,6.53210685 C7.33878414,6.53210685 7.09345904,6.61788486 6.91847191,6.78944087 C6.74348478,6.96099688 6.65599121,7.19774418 6.65599121,7.49968276 L6.65599121,12.6566565 C6.65599121,12.9585951 6.74348478,13.1953424 6.91847191,13.3668984 C7.09345904,13.5384544 7.33878414,13.6242324 7.65444721,13.6242324 Z' id='shape' fill='%23FF3B30' fill-rule='nonzero'%3E%3C/path%3E %3C/g%3E %3C/svg%3E");
443
- height: 21px;
444
- }
445
- /* list */
446
- ol:not(.options), ul:not(.options) {
447
- padding-inline-start: 2em !important;
448
- }
449
-
450
- /* 亮色(默认) */
451
- #gpt-chatbot {
452
- background-color: var(--chatbot-background-color-light) !important;
453
- color: var(--chatbot-color-light) !important;
454
- box-shadow: 0 0 12px 4px rgba(0, 0, 0, 0.06);
455
- }
456
- /* 暗色 */
457
- .dark #gpt-chatbot {
458
- background-color: var(--block-background-fill) !important;
459
- color: var(--chatbot-color-dark) !important;
460
- box-shadow: 0 0 12px 4px rgba(0, 0, 0, 0.2);
461
- }
462
-
463
- #gpt-panel > div {
464
- box-shadow: 0 0 12px 4px rgba(0, 0, 0, 0.06);
465
- }
466
- .dark #gpt-panel > div {
467
- box-shadow: 0 0 12px 4px rgba(0, 0, 0, 0.2);
468
- }
469
-
470
- /* 屏幕宽度大于等于500px的设备 */
471
- /* update on 2023.4.8: 高度的细致调整已写入JavaScript */
472
- /* @media screen and (min-width: 500px) {
473
- #main_chatbot {
474
- height: calc(100vh - 200px);
475
- }
476
- #main_chatbot .wrap {
477
- max-height: calc(100vh - 200px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
478
- }
479
- } */
480
- /* 屏幕宽度小于500px的设备 */
481
- /* @media screen and (max-width: 499px) {
482
- #main_chatbot {
483
- height: calc(100vh - 140px);
484
- }
485
- #main_chatbot .wrap {
486
- max-height: calc(100vh - 140px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
487
- }
488
- [data-testid = "bot"] {
489
- max-width: 95% !important;
490
- }
491
- #app_title h1{
492
- letter-spacing: -1px; font-size: 22px;
493
- }
494
- } */
495
- #gpt-chatbot .wrap {
496
- overflow-x: hidden
497
- }
498
- /* 对话气泡 */
499
- .message {
500
- border-radius: var(--radius-xl) !important;
501
- border: none;
502
- padding: var(--spacing-xl) !important;
503
- font-size: 15px !important;
504
- line-height: var(--line-md) !important;
505
- min-height: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl));
506
- min-width: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl));
507
- }
508
- [data-testid = "bot"] {
509
- max-width: 85%;
510
- border-bottom-left-radius: 0 !important;
511
- background-color: var(--message-bot-background-color-light) !important;
512
- }
513
- [data-testid = "user"] {
514
- max-width: 85%;
515
- width: auto !important;
516
- border-bottom-right-radius: 0 !important;
517
- background-color: var(--message-user-background-color-light) !important;
518
- }
519
- .dark [data-testid = "bot"] {
520
- background-color: var(--message-bot-background-color-dark) !important;
521
- }
522
- .dark [data-testid = "user"] {
523
- background-color: var(--message-user-background-color-dark) !important;
524
- }
525
-
526
- .message p {
527
- margin-top: 0.6em !important;
528
- margin-bottom: 0.6em !important;
529
- }
530
- .message p:first-child { margin-top: 0 !important; }
531
- .message p:last-of-type { margin-bottom: 0 !important; }
532
-
533
- .message .md-message {
534
- display: block;
535
- padding: 0 !important;
536
- }
537
- .message .raw-message {
538
- display: block;
539
- padding: 0 !important;
540
- white-space: pre-wrap;
541
- }
542
- .raw-message.hideM, .md-message.hideM {
543
- display: none;
544
- }
545
-
546
- /* custom buttons */
547
- .chuanhu-btn {
548
- border-radius: 5px;
549
- /* background-color: #E6E6E6 !important; */
550
- color: rgba(120, 120, 120, 0.64) !important;
551
- padding: 4px !important;
552
- position: absolute;
553
- right: -22px;
554
- cursor: pointer !important;
555
- transition: color .2s ease, background-color .2s ease;
556
- }
557
- .chuanhu-btn:hover {
558
- background-color: rgba(167, 167, 167, 0.25) !important;
559
- color: unset !important;
560
- }
561
- .chuanhu-btn:active {
562
- background-color: rgba(167, 167, 167, 0.5) !important;
563
- }
564
- .chuanhu-btn:focus {
565
- outline: none;
566
- }
567
- .copy-bot-btn {
568
- /* top: 18px; */
569
- bottom: 0;
570
- }
571
- .toggle-md-btn {
572
- /* top: 0; */
573
- bottom: 20px;
574
- }
575
- .copy-code-btn {
576
- position: relative;
577
- float: right;
578
- font-size: 1em;
579
- cursor: pointer;
580
- }
581
-
582
- .message-wrap>div img{
583
- border-radius: 10px !important;
584
- }
585
-
586
- /* history message */
587
- .wrap>.history-message {
588
- padding: 10px !important;
589
- }
590
- .history-message {
591
- /* padding: 0 !important; */
592
- opacity: 80%;
593
- display: flex;
594
- flex-direction: column;
595
- }
596
- .history-message>.history-message {
597
- padding: 0 !important;
598
- }
599
- .history-message>.message-wrap {
600
- padding: 0 !important;
601
- margin-bottom: 16px;
602
- }
603
- .history-message>.message {
604
- margin-bottom: 16px;
605
- }
606
- .wrap>.history-message::after {
607
- content: "";
608
- display: block;
609
- height: 2px;
610
- background-color: var(--body-text-color-subdued);
611
- margin-bottom: 10px;
612
- margin-top: -10px;
613
- clear: both;
614
- }
615
- .wrap>.history-message>:last-child::after {
616
- content: "仅供查看";
617
- display: block;
618
- text-align: center;
619
- color: var(--body-text-color-subdued);
620
- font-size: 0.8em;
621
- }
622
-
623
- /* 表格 */
624
- table {
625
- margin: 1em 0;
626
- border-collapse: collapse;
627
- empty-cells: show;
628
- }
629
- td,th {
630
- border: 1.2px solid var(--border-color-primary) !important;
631
- padding: 0.2em;
632
- }
633
- thead {
634
- background-color: rgba(175,184,193,0.2);
635
- }
636
- thead th {
637
- padding: .5em .2em;
638
- }
639
- /* 行内代码 */
640
- .message :not(pre) code {
641
- display: inline;
642
- white-space: break-spaces;
643
- border-radius: 6px;
644
- margin: 0 2px 0 2px;
645
- padding: .2em .4em .1em .4em;
646
- background-color: rgba(175,184,193,0.2);
647
- }
648
- /* 代码块 */
649
- .message pre code {
650
- display: block;
651
- overflow: auto;
652
- white-space: pre;
653
- background-color: hsla(0, 0%, 7%, 70%)!important;
654
- border-radius: 10px;
655
- padding: 1.2em 1em 0em .5em;
656
- margin: 0.6em 2em 1em 0.2em;
657
- color: #FFF;
658
- box-shadow: 6px 6px 16px hsla(0, 0%, 0%, 0.2);
659
- }
660
- .dark .message pre code {
661
- background-color: hsla(0, 0%, 20%, 300%)!important;
662
- }
663
- .message pre {
664
- padding: 0 !important;
665
- }
666
- .message pre code div.highlight {
667
- background-color: unset !important;
668
- }
669
-
670
- button.copy-button {
671
- display: none;
672
- }
673
-
674
- /* 代码高亮样式 */
675
- .codehilite .hll { background-color: #6e7681 }
676
- .codehilite .c { color: #8b949e; font-style: italic } /* Comment */
677
- .codehilite .err { color: #f85149 } /* Error */
678
- .codehilite .esc { color: #c9d1d9 } /* Escape */
679
- .codehilite .g { color: #c9d1d9 } /* Generic */
680
- .codehilite .k { color: #ff7b72 } /* Keyword */
681
- .codehilite .l { color: #a5d6ff } /* Literal */
682
- .codehilite .n { color: #c9d1d9 } /* Name */
683
- .codehilite .o { color: #ff7b72; font-weight: bold } /* Operator */
684
- .codehilite .x { color: #c9d1d9 } /* Other */
685
- .codehilite .p { color: #c9d1d9 } /* Punctuation */
686
- .codehilite .ch { color: #8b949e; font-style: italic } /* Comment.Hashbang */
687
- .codehilite .cm { color: #8b949e; font-style: italic } /* Comment.Multiline */
688
- .codehilite .cp { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Preproc */
689
- .codehilite .cpf { color: #8b949e; font-style: italic } /* Comment.PreprocFile */
690
- .codehilite .c1 { color: #8b949e; font-style: italic } /* Comment.Single */
691
- .codehilite .cs { color: #8b949e; font-weight: bold; font-style: italic } /* Comment.Special */
692
- .codehilite .gd { color: #ffa198; background-color: #490202 } /* Generic.Deleted */
693
- .codehilite .ge { color: #c9d1d9; font-style: italic } /* Generic.Emph */
694
- .codehilite .gr { color: #ffa198 } /* Generic.Error */
695
- .codehilite .gh { color: #79c0ff; font-weight: bold } /* Generic.Heading */
696
- .codehilite .gi { color: #56d364; background-color: #0f5323 } /* Generic.Inserted */
697
- .codehilite .go { color: #8b949e } /* Generic.Output */
698
- .codehilite .gp { color: #8b949e } /* Generic.Prompt */
699
- .codehilite .gs { color: #c9d1d9; font-weight: bold } /* Generic.Strong */
700
- .codehilite .gu { color: #79c0ff } /* Generic.Subheading */
701
- .codehilite .gt { color: #ff7b72 } /* Generic.Traceback */
702
- .codehilite .g-Underline { color: #c9d1d9; text-decoration: underline } /* Generic.Underline */
703
- .codehilite .kc { color: #79c0ff } /* Keyword.Constant */
704
- .codehilite .kd { color: #ff7b72 } /* Keyword.Declaration */
705
- .codehilite .kn { color: #ff7b72 } /* Keyword.Namespace */
706
- .codehilite .kp { color: #79c0ff } /* Keyword.Pseudo */
707
- .codehilite .kr { color: #ff7b72 } /* Keyword.Reserved */
708
- .codehilite .kt { color: #ff7b72 } /* Keyword.Type */
709
- .codehilite .ld { color: #79c0ff } /* Literal.Date */
710
- .codehilite .m { color: #a5d6ff } /* Literal.Number */
711
- .codehilite .s { color: #a5d6ff } /* Literal.String */
712
- .codehilite .na { color: #c9d1d9 } /* Name.Attribute */
713
- .codehilite .nb { color: #c9d1d9 } /* Name.Builtin */
714
- .codehilite .nc { color: #f0883e; font-weight: bold } /* Name.Class */
715
- .codehilite .no { color: #79c0ff; font-weight: bold } /* Name.Constant */
716
- .codehilite .nd { color: #d2a8ff; font-weight: bold } /* Name.Decorator */
717
- .codehilite .ni { color: #ffa657 } /* Name.Entity */
718
- .codehilite .ne { color: #f0883e; font-weight: bold } /* Name.Exception */
719
- .codehilite .nf { color: #d2a8ff; font-weight: bold } /* Name.Function */
720
- .codehilite .nl { color: #79c0ff; font-weight: bold } /* Name.Label */
721
- .codehilite .nn { color: #ff7b72 } /* Name.Namespace */
722
- .codehilite .nx { color: #c9d1d9 } /* Name.Other */
723
- .codehilite .py { color: #79c0ff } /* Name.Property */
724
- .codehilite .nt { color: #7ee787 } /* Name.Tag */
725
- .codehilite .nv { color: #79c0ff } /* Name.Variable */
726
- .codehilite .ow { color: #ff7b72; font-weight: bold } /* Operator.Word */
727
- .codehilite .pm { color: #c9d1d9 } /* Punctuation.Marker */
728
- .codehilite .w { color: #6e7681 } /* Text.Whitespace */
729
- .codehilite .mb { color: #a5d6ff } /* Literal.Number.Bin */
730
- .codehilite .mf { color: #a5d6ff } /* Literal.Number.Float */
731
- .codehilite .mh { color: #a5d6ff } /* Literal.Number.Hex */
732
- .codehilite .mi { color: #a5d6ff } /* Literal.Number.Integer */
733
- .codehilite .mo { color: #a5d6ff } /* Literal.Number.Oct */
734
- .codehilite .sa { color: #79c0ff } /* Literal.String.Affix */
735
- .codehilite .sb { color: #a5d6ff } /* Literal.String.Backtick */
736
- .codehilite .sc { color: #a5d6ff } /* Literal.String.Char */
737
- .codehilite .dl { color: #79c0ff } /* Literal.String.Delimiter */
738
- .codehilite .sd { color: #a5d6ff } /* Literal.String.Doc */
739
- .codehilite .s2 { color: #a5d6ff } /* Literal.String.Double */
740
- .codehilite .se { color: #79c0ff } /* Literal.String.Escape */
741
- .codehilite .sh { color: #79c0ff } /* Literal.String.Heredoc */
742
- .codehilite .si { color: #a5d6ff } /* Literal.String.Interpol */
743
- .codehilite .sx { color: #a5d6ff } /* Literal.String.Other */
744
- .codehilite .sr { color: #79c0ff } /* Literal.String.Regex */
745
- .codehilite .s1 { color: #a5d6ff } /* Literal.String.Single */
746
- .codehilite .ss { color: #a5d6ff } /* Literal.String.Symbol */
747
- .codehilite .bp { color: #c9d1d9 } /* Name.Builtin.Pseudo */
748
- .codehilite .fm { color: #d2a8ff; font-weight: bold } /* Name.Function.Magic */
749
- .codehilite .vc { color: #79c0ff } /* Name.Variable.Class */
750
- .codehilite .vg { color: #79c0ff } /* Name.Variable.Global */
751
- .codehilite .vi { color: #79c0ff } /* Name.Variable.Instance */
752
- .codehilite .vm { color: #79c0ff } /* Name.Variable.Magic */
753
- .codehilite .il { color: #a5d6ff } /* Literal.Number.Integer.Long */
754
-
755
- .dark .codehilite .hll { background-color: #2C3B41 }
756
- .dark .codehilite .c { color: #79d618; font-style: italic } /* Comment */
757
- .dark .codehilite .err { color: #FF5370 } /* Error */
758
- .dark .codehilite .esc { color: #89DDFF } /* Escape */
759
- .dark .codehilite .g { color: #EEFFFF } /* Generic */
760
- .dark .codehilite .k { color: #BB80B3 } /* Keyword */
761
- .dark .codehilite .l { color: #C3E88D } /* Literal */
762
- .dark .codehilite .n { color: #EEFFFF } /* Name */
763
- .dark .codehilite .o { color: #89DDFF } /* Operator */
764
- .dark .codehilite .p { color: #89DDFF } /* Punctuation */
765
- .dark .codehilite .ch { color: #79d618; font-style: italic } /* Comment.Hashbang */
766
- .dark .codehilite .cm { color: #79d618; font-style: italic } /* Comment.Multiline */
767
- .dark .codehilite .cp { color: #79d618; font-style: italic } /* Comment.Preproc */
768
- .dark .codehilite .cpf { color: #79d618; font-style: italic } /* Comment.PreprocFile */
769
- .dark .codehilite .c1 { color: #79d618; font-style: italic } /* Comment.Single */
770
- .dark .codehilite .cs { color: #79d618; font-style: italic } /* Comment.Special */
771
- .dark .codehilite .gd { color: #FF5370 } /* Generic.Deleted */
772
- .dark .codehilite .ge { color: #89DDFF } /* Generic.Emph */
773
- .dark .codehilite .gr { color: #FF5370 } /* Generic.Error */
774
- .dark .codehilite .gh { color: #C3E88D } /* Generic.Heading */
775
- .dark .codehilite .gi { color: #C3E88D } /* Generic.Inserted */
776
- .dark .codehilite .go { color: #79d618 } /* Generic.Output */
777
- .dark .codehilite .gp { color: #FFCB6B } /* Generic.Prompt */
778
- .dark .codehilite .gs { color: #FF5370 } /* Generic.Strong */
779
- .dark .codehilite .gu { color: #89DDFF } /* Generic.Subheading */
780
- .dark .codehilite .gt { color: #FF5370 } /* Generic.Traceback */
781
- .dark .codehilite .kc { color: #89DDFF } /* Keyword.Constant */
782
- .dark .codehilite .kd { color: #BB80B3 } /* Keyword.Declaration */
783
- .dark .codehilite .kn { color: #89DDFF; font-style: italic } /* Keyword.Namespace */
784
- .dark .codehilite .kp { color: #89DDFF } /* Keyword.Pseudo */
785
- .dark .codehilite .kr { color: #BB80B3 } /* Keyword.Reserved */
786
- .dark .codehilite .kt { color: #BB80B3 } /* Keyword.Type */
787
- .dark .codehilite .ld { color: #C3E88D } /* Literal.Date */
788
- .dark .codehilite .m { color: #F78C6C } /* Literal.Number */
789
- .dark .codehilite .s { color: #C3E88D } /* Literal.String */
790
- .dark .codehilite .na { color: #BB80B3 } /* Name.Attribute */
791
- .dark .codehilite .nb { color: #82AAFF } /* Name.Builtin */
792
- .dark .codehilite .nc { color: #FFCB6B } /* Name.Class */
793
- .dark .codehilite .no { color: #EEFFFF } /* Name.Constant */
794
- .dark .codehilite .nd { color: #82AAFF } /* Name.Decorator */
795
- .dark .codehilite .ni { color: #89DDFF } /* Name.Entity */
796
- .dark .codehilite .ne { color: #FFCB6B } /* Name.Exception */
797
- .dark .codehilite .nf { color: #82AAFF } /* Name.Function */
798
- .dark .codehilite .nl { color: #82AAFF } /* Name.Label */
799
- .dark .codehilite .nn { color: #FFCB6B } /* Name.Namespace */
800
- .dark .codehilite .nx { color: #EEFFFF } /* Name.Other */
801
- .dark .codehilite .py { color: #FFCB6B } /* Name.Property */
802
- .dark .codehilite .nt { color: #FF5370 } /* Name.Tag */
803
- .dark .codehilite .nv { color: #89DDFF } /* Name.Variable */
804
- .dark .codehilite .ow { color: #89DDFF; font-style: italic } /* Operator.Word */
805
- .dark .codehilite .pm { color: #89DDFF } /* Punctuation.Marker */
806
- .dark .codehilite .w { color: #EEFFFF } /* Text.Whitespace */
807
- .dark .codehilite .mb { color: #F78C6C } /* Literal.Number.Bin */
808
- .dark .codehilite .mf { color: #F78C6C } /* Literal.Number.Float */
809
- .dark .codehilite .mh { color: #F78C6C } /* Literal.Number.Hex */
810
- .dark .codehilite .mi { color: #F78C6C } /* Literal.Number.Integer */
811
- .dark .codehilite .mo { color: #F78C6C } /* Literal.Number.Oct */
812
- .dark .codehilite .sa { color: #BB80B3 } /* Literal.String.Affix */
813
- .dark .codehilite .sb { color: #C3E88D } /* Literal.String.Backtick */
814
- .dark .codehilite .sc { color: #C3E88D } /* Literal.String.Char */
815
- .dark .codehilite .dl { color: #EEFFFF } /* Literal.String.Delimiter */
816
- .dark .codehilite .sd { color: #79d618; font-style: italic } /* Literal.String.Doc */
817
- .dark .codehilite .s2 { color: #C3E88D } /* Literal.String.Double */
818
- .dark .codehilite .se { color: #EEFFFF } /* Literal.String.Escape */
819
- .dark .codehilite .sh { color: #C3E88D } /* Literal.String.Heredoc */
820
- .dark .codehilite .si { color: #89DDFF } /* Literal.String.Interpol */
821
- .dark .codehilite .sx { color: #C3E88D } /* Literal.String.Other */
822
- .dark .codehilite .sr { color: #89DDFF } /* Literal.String.Regex */
823
- .dark .codehilite .s1 { color: #C3E88D } /* Literal.String.Single */
824
- .dark .codehilite .ss { color: #89DDFF } /* Literal.String.Symbol */
825
- .dark .codehilite .bp { color: #89DDFF } /* Name.Builtin.Pseudo */
826
- .dark .codehilite .fm { color: #82AAFF } /* Name.Function.Magic */
827
- .dark .codehilite .vc { color: #89DDFF } /* Name.Variable.Class */
828
- .dark .codehilite .vg { color: #89DDFF } /* Name.Variable.Global */
829
- .dark .codehilite .vi { color: #89DDFF } /* Name.Variable.Instance */
830
- .dark .codehilite .vm { color: #82AAFF } /* Name.Variable.Magic */
831
- .dark .codehilite .il { color: #F78C6C } /* Literal.Number.Integer.Long */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/green.js DELETED
@@ -1,41 +0,0 @@
1
-
2
- var academic_chat = null;
3
-
4
- var sliders = null;
5
- var rangeInputs = null;
6
- var numberInputs = null;
7
-
8
- function set_elements() {
9
- academic_chat = document.querySelector('gradio-app');
10
- async function get_sliders() {
11
- sliders = document.querySelectorAll('input[type="range"]');
12
- while (sliders.length == 0) {
13
- await new Promise(r => setTimeout(r, 100));
14
- sliders = document.querySelectorAll('input[type="range"]');
15
- }
16
- setSlider();
17
- }
18
- get_sliders();
19
- }
20
-
21
- function setSlider() {
22
- rangeInputs = document.querySelectorAll('input[type="range"]');
23
- numberInputs = document.querySelectorAll('input[type="number"]')
24
- function setSliderRange() {
25
- var range = document.querySelectorAll('input[type="range"]');
26
- range.forEach(range => {
27
- range.style.backgroundSize = (range.value - range.min) / (range.max - range.min) * 100 + '% 100%';
28
- });
29
- }
30
- setSliderRange();
31
- rangeInputs.forEach(rangeInput => {
32
- rangeInput.addEventListener('input', setSliderRange);
33
- });
34
- numberInputs.forEach(numberInput => {
35
- numberInput.addEventListener('input', setSliderRange);
36
- })
37
- }
38
-
39
- window.addEventListener("DOMContentLoaded", () => {
40
- set_elements();
41
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/green.py DELETED
@@ -1,109 +0,0 @@
1
- import os
2
- import gradio as gr
3
- from toolbox import get_conf
4
- CODE_HIGHLIGHT, ADD_WAIFU, LAYOUT = get_conf('CODE_HIGHLIGHT', 'ADD_WAIFU', 'LAYOUT')
5
- theme_dir = os.path.dirname(__file__)
6
-
7
- def adjust_theme():
8
- try:
9
- set_theme = gr.themes.Soft(
10
- primary_hue=gr.themes.Color(
11
- c50="#EBFAF2",
12
- c100="#CFF3E1",
13
- c200="#A8EAC8",
14
- c300="#77DEA9",
15
- c400="#3FD086",
16
- c500="#02C160",
17
- c600="#06AE56",
18
- c700="#05974E",
19
- c800="#057F45",
20
- c900="#04673D",
21
- c950="#2E5541",
22
- name="small_and_beautiful",
23
- ),
24
- secondary_hue=gr.themes.Color(
25
- c50="#576b95",
26
- c100="#576b95",
27
- c200="#576b95",
28
- c300="#576b95",
29
- c400="#576b95",
30
- c500="#576b95",
31
- c600="#576b95",
32
- c700="#576b95",
33
- c800="#576b95",
34
- c900="#576b95",
35
- c950="#576b95",
36
- ),
37
- neutral_hue=gr.themes.Color(
38
- name="gray",
39
- c50="#f6f7f8",
40
- # c100="#f3f4f6",
41
- c100="#F2F2F2",
42
- c200="#e5e7eb",
43
- c300="#d1d5db",
44
- c400="#B2B2B2",
45
- c500="#808080",
46
- c600="#636363",
47
- c700="#515151",
48
- c800="#393939",
49
- # c900="#272727",
50
- c900="#2B2B2B",
51
- c950="#171717",
52
- ),
53
-
54
- radius_size=gr.themes.sizes.radius_sm,
55
- ).set(
56
- button_primary_background_fill="*primary_500",
57
- button_primary_background_fill_dark="*primary_600",
58
- button_primary_background_fill_hover="*primary_400",
59
- button_primary_border_color="*primary_500",
60
- button_primary_border_color_dark="*primary_600",
61
- button_primary_text_color="white",
62
- button_primary_text_color_dark="white",
63
- button_secondary_background_fill="*neutral_100",
64
- button_secondary_background_fill_hover="*neutral_50",
65
- button_secondary_background_fill_dark="*neutral_900",
66
- button_secondary_text_color="*neutral_800",
67
- button_secondary_text_color_dark="white",
68
- background_fill_primary="*neutral_50",
69
- background_fill_primary_dark="#1F1F1F",
70
- block_title_text_color="*primary_500",
71
- block_title_background_fill_dark="*primary_900",
72
- block_label_background_fill_dark="*primary_900",
73
- input_background_fill="#F6F6F6",
74
- chatbot_code_background_color="*neutral_950",
75
- chatbot_code_background_color_dark="*neutral_950",
76
- )
77
-
78
- with open(os.path.join(theme_dir, 'common.js'), 'r', encoding='utf8') as f:
79
- js = f"<script>{f.read()}</script>"
80
-
81
- # 添加一个萌萌的看板娘
82
- if ADD_WAIFU:
83
- js += """
84
- <script src="file=docs/waifu_plugin/jquery.min.js"></script>
85
- <script src="file=docs/waifu_plugin/jquery-ui.min.js"></script>
86
- <script src="file=docs/waifu_plugin/autoload.js"></script>
87
- """
88
-
89
- with open(os.path.join(theme_dir, 'green.js'), 'r', encoding='utf8') as f:
90
- js += f"<script>{f.read()}</script>"
91
-
92
- if not hasattr(gr, 'RawTemplateResponse'):
93
- gr.RawTemplateResponse = gr.routes.templates.TemplateResponse
94
- gradio_original_template_fn = gr.RawTemplateResponse
95
- def gradio_new_template_fn(*args, **kwargs):
96
- res = gradio_original_template_fn(*args, **kwargs)
97
- res.body = res.body.replace(b'</html>', f'{js}</html>'.encode("utf8"))
98
- res.init_headers()
99
- return res
100
- gr.routes.templates.TemplateResponse = gradio_new_template_fn # override gradio template
101
- except:
102
- set_theme = None
103
- print('gradio版本较旧, 不能自定义字体和颜色')
104
- return set_theme
105
-
106
- with open(os.path.join(theme_dir, 'green.css'), "r", encoding="utf-8") as f:
107
- advanced_css = f.read()
108
- with open(os.path.join(theme_dir, 'common.css'), "r", encoding="utf-8") as f:
109
- advanced_css += f.read()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/theme.py DELETED
@@ -1,118 +0,0 @@
1
- import pickle
2
- import base64
3
- import uuid
4
- from toolbox import get_conf
5
-
6
- """
7
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
8
- 第 1 部分
9
- 加载主题相关的工具函数
10
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
11
- """
12
-
13
- def load_dynamic_theme(THEME):
14
- adjust_dynamic_theme = None
15
- if THEME == 'Chuanhu-Small-and-Beautiful':
16
- from .green import adjust_theme, advanced_css
17
- theme_declaration = "<h2 align=\"center\" class=\"small\">[Chuanhu-Small-and-Beautiful主题]</h2>"
18
- elif THEME == 'High-Contrast':
19
- from .contrast import adjust_theme, advanced_css
20
- theme_declaration = ""
21
- elif '/' in THEME:
22
- from .gradios import adjust_theme, advanced_css
23
- from .gradios import dynamic_set_theme
24
- adjust_dynamic_theme = dynamic_set_theme(THEME)
25
- theme_declaration = ""
26
- else:
27
- from .default import adjust_theme, advanced_css
28
- theme_declaration = ""
29
- return adjust_theme, advanced_css, theme_declaration, adjust_dynamic_theme
30
-
31
- adjust_theme, advanced_css, theme_declaration, _ = load_dynamic_theme(get_conf('THEME'))
32
-
33
-
34
-
35
-
36
-
37
-
38
- """
39
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
40
- 第 2 部分
41
- cookie相关工具函数
42
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
43
- """
44
-
45
- def init_cookie(cookies, chatbot):
46
- # 为每一位访问的用户赋予一个独一无二的uuid编码
47
- cookies.update({'uuid': uuid.uuid4()})
48
- return cookies
49
-
50
- def to_cookie_str(d):
51
- # Pickle the dictionary and encode it as a string
52
- pickled_dict = pickle.dumps(d)
53
- cookie_value = base64.b64encode(pickled_dict).decode('utf-8')
54
- return cookie_value
55
-
56
- def from_cookie_str(c):
57
- # Decode the base64-encoded string and unpickle it into a dictionary
58
- pickled_dict = base64.b64decode(c.encode('utf-8'))
59
- return pickle.loads(pickled_dict)
60
-
61
-
62
-
63
-
64
-
65
- """
66
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
67
- 第 3 部分
68
- 内嵌的javascript代码
69
- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
70
- """
71
-
72
- js_code_for_css_changing = """(css) => {
73
- var existingStyles = document.querySelectorAll("body > gradio-app > div > style")
74
- for (var i = 0; i < existingStyles.length; i++) {
75
- var style = existingStyles[i];
76
- style.parentNode.removeChild(style);
77
- }
78
- var existingStyles = document.querySelectorAll("style[data-loaded-css]");
79
- for (var i = 0; i < existingStyles.length; i++) {
80
- var style = existingStyles[i];
81
- style.parentNode.removeChild(style);
82
- }
83
- var styleElement = document.createElement('style');
84
- styleElement.setAttribute('data-loaded-css', 'placeholder');
85
- styleElement.innerHTML = css;
86
- document.body.appendChild(styleElement);
87
- }
88
- """
89
-
90
- js_code_for_darkmode_init = """(dark) => {
91
- dark = dark == "True";
92
- if (document.querySelectorAll('.dark').length) {
93
- if (!dark){
94
- document.querySelectorAll('.dark').forEach(el => el.classList.remove('dark'));
95
- }
96
- } else {
97
- if (dark){
98
- document.querySelector('body').classList.add('dark');
99
- }
100
- }
101
- }
102
- """
103
-
104
- js_code_for_toggle_darkmode = """() => {
105
- if (document.querySelectorAll('.dark').length) {
106
- document.querySelectorAll('.dark').forEach(el => el.classList.remove('dark'));
107
- } else {
108
- document.querySelector('body').classList.add('dark');
109
- }
110
- }"""
111
-
112
-
113
- js_code_for_persistent_cookie_init = """(persistent_cookie) => {
114
- return getCookie("persistent_cookie");
115
- }
116
- """
117
-
118
-