Keldos commited on
Commit
c4401df
1 Parent(s): 455961c

WIP 暂存

Browse files
ChuanhuChatbot.py CHANGED
@@ -127,38 +127,49 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
127
  dislikeBtn = gr.Button(i18n("👎"))
128
 
129
  with gr.Column(elem_id="toolbox-area", min_width=50, scale=1):
130
- with gr.Accordion(label="Prompt", open=True):
131
- systemPromptTxt = gr.Textbox(
132
- show_label=True,
133
- placeholder=i18n("在这里输入System Prompt..."),
134
- label="System prompt",
135
- value=INITIAL_SYSTEM_PROMPT,
136
- lines=10
137
- )
138
- with gr.Accordion(label=i18n("加载Prompt模板"), open=True):
139
- with gr.Column():
140
- with gr.Row():
141
- with gr.Column(scale=6):
142
- templateFileSelectDropdown = gr.Dropdown(
143
- label=i18n("选择Prompt模板集合文件"),
144
- choices=get_template_names(plain=True),
145
- multiselect=False,
146
- value=get_template_names(plain=True)[0],
147
- container=False,
148
- )
149
- with gr.Column(scale=1):
150
- templateRefreshBtn = gr.Button(i18n("🔄 刷新"))
151
- with gr.Row():
152
  with gr.Column():
153
- templateSelectDropdown = gr.Dropdown(
154
- label=i18n("从Prompt模板中加载"),
155
- choices=load_template(
156
- get_template_names(plain=True)[0], mode=1
157
- ),
158
- multiselect=False,
159
- container=False,
160
- )
161
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
 
163
  # changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
164
  updateChuanhuBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
@@ -169,7 +180,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
169
  with gr.Box(elem_id="chuanhu-setting"):
170
  with gr.Row():
171
  gr.Markdown("## Settings")
172
- gr.HTML(get_html("close_box_btn.html"),elem_classes="close-box-btn")
173
  with gr.Tabs(elem_id="chuanhu-setting-tabs"):
174
  with gr.Tab(label=i18n("模型")):
175
  keyTxt = gr.Textbox(
@@ -325,7 +336,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
325
  with gr.Box(elem_id="chuanhu-training"):
326
  with gr.Row():
327
  gr.Markdown("## Training")
328
- gr.HTML(get_html("close_box_btn.html"),elem_classes="close-box-btn")
329
  with gr.Tabs(elem_id="chuanhu-training-tabs"):
330
  with gr.Tab(label=i18n("OpenAI 微调")):
331
  openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n("在这里[查看使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B#%E5%BE%AE%E8%B0%83-gpt-35)"))
 
127
  dislikeBtn = gr.Button(i18n("👎"))
128
 
129
  with gr.Column(elem_id="toolbox-area", min_width=50, scale=1):
130
+ with gr.Box(elem_id="chuanhu-toolbox"):
131
+ with gr.Row():
132
+ gr.Markdown("## 🛠️ Toolbox")
133
+ gr.HTML(get_html("close_btn.html").format(obj="toolbox"), elem_classes="close-btn")
134
+ with gr.Tabs(elem_id="chuanhu-toolbox-tabs"):
135
+ with gr.Tab(label=i18n("Prompt")):
136
+ # with gr.Accordion(label="Prompt", open=True):
137
+ systemPromptTxt = gr.Textbox(
138
+ show_label=True,
139
+ placeholder=i18n("在这里输入System Prompt..."),
140
+ label="System prompt",
141
+ value=INITIAL_SYSTEM_PROMPT,
142
+ lines=10
143
+ )
144
+ with gr.Accordion(label=i18n("加载Prompt模板"), open=True):
 
 
 
 
 
 
 
145
  with gr.Column():
146
+ with gr.Row():
147
+ with gr.Column(scale=6):
148
+ templateFileSelectDropdown = gr.Dropdown(
149
+ label=i18n("选择Prompt模板集合文件"),
150
+ choices=get_template_names(plain=True),
151
+ multiselect=False,
152
+ value=get_template_names(plain=True)[0],
153
+ container=False,
154
+ )
155
+ with gr.Column(scale=1):
156
+ templateRefreshBtn = gr.Button(i18n("🔄 刷新"))
157
+ with gr.Row():
158
+ with gr.Column():
159
+ templateSelectDropdown = gr.Dropdown(
160
+ label=i18n("从Prompt模板中加载"),
161
+ choices=load_template(
162
+ get_template_names(plain=True)[0], mode=1
163
+ ),
164
+ multiselect=False,
165
+ container=False,
166
+ )
167
+ with gr.Tab(label=i18n("Parameters")):
168
+ gr.Markdown("will be here soon...")
169
+ with gr.Tab(label=i18n("Extensions")):
170
+ gr.Markdown("no, not yet...")
171
+ with gr.Tab(label=i18n("不知道还有啥tab")):
172
+ gr.Markdown("I am Keldos. Hello, world!")
173
 
174
  # changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
175
  updateChuanhuBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
 
180
  with gr.Box(elem_id="chuanhu-setting"):
181
  with gr.Row():
182
  gr.Markdown("## Settings")
183
+ gr.HTML(get_html("close_btn.html").format(obj="box"),elem_classes="close-btn")
184
  with gr.Tabs(elem_id="chuanhu-setting-tabs"):
185
  with gr.Tab(label=i18n("模型")):
186
  keyTxt = gr.Textbox(
 
336
  with gr.Box(elem_id="chuanhu-training"):
337
  with gr.Row():
338
  gr.Markdown("## Training")
339
+ gr.HTML(get_html("close_btn.html").format(obj="box"),elem_classes="close-btn")
340
  with gr.Tabs(elem_id="chuanhu-training-tabs"):
341
  with gr.Tab(label=i18n("OpenAI 微调")):
342
  openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n("在这里[查看使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B#%E5%BE%AE%E8%B0%83-gpt-35)"))
web_assets/html/close_box_btn.html DELETED
@@ -1,3 +0,0 @@
1
- <button class="text-gray-500 transition hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
2
- onclick="closeBox()"
3
- ><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" height="20" width="20" xmlns="http://www.w3.org/2000/svg"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>
 
 
 
 
web_assets/html/close_btn.html ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <button class="text-gray-500 transition hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200"
2
+ onclick='closeBtnClick("{obj}")'>
3
+ <svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round"
4
+ stroke-linejoin="round" height="20" width="20" xmlns="http://www.w3.org/2000/svg"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line>
5
+ </svg>
6
+ </button>
web_assets/javascript/webui.js CHANGED
@@ -50,9 +50,13 @@ function showSideMask() {
50
  // sideMask.style.opacity = '0';
51
  if (document.querySelector('.chuanhu-side-mask')) {
52
  sideMask.style.display = 'block';
53
- setTimeout(() => {sideMask.style.opacity = '0.5'; }, 200);
 
 
54
  } else {
55
- sideMask.style.opacity = '0.5';
 
 
56
  }
57
  // sideMask.style.display = 'block';
58
  // // sideMask.style.opacity = '0.5';
@@ -62,7 +66,8 @@ function showSideMask() {
62
  } else {
63
  // sideMask.style.display = 'none';
64
  document.body.classList.remove('popup-open');
65
- sideMask.style.opacity = '0';
 
66
  // sideMask.style.display = 'none';
67
  // note: 动画卡,气死我了
68
  setTimeout(() => {sideMask.style.display = 'none'; }, 100);
@@ -86,6 +91,14 @@ function showSideMask() {
86
  });
87
  }
88
 
 
 
 
 
 
 
 
 
89
  function closeBox() {
90
  chuanhuPopup.classList.remove('showBox');
91
  popupWrapper.classList.remove('showBox');
 
50
  // sideMask.style.opacity = '0';
51
  if (document.querySelector('.chuanhu-side-mask')) {
52
  sideMask.style.display = 'block';
53
+ // setTimeout(() => {sideMask.style.opacity = '0.5'; }, 200);
54
+ setTimeout(() => {sideMask.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';}, 200);
55
+ sideMask.classList.add('mask-blur');
56
  } else {
57
+ // sideMask.style.opacity = '0.5';
58
+ sideMask.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
59
+ sideMask.classList.add('mask-blur');
60
  }
61
  // sideMask.style.display = 'block';
62
  // // sideMask.style.opacity = '0.5';
 
66
  } else {
67
  // sideMask.style.display = 'none';
68
  document.body.classList.remove('popup-open');
69
+ // sideMask.style.opacity = '0';
70
+ sideMask.style.backgroundColor = 'rgba(0, 0, 0, 0)';
71
  // sideMask.style.display = 'none';
72
  // note: 动画卡,气死我了
73
  setTimeout(() => {sideMask.style.display = 'none'; }, 100);
 
91
  });
92
  }
93
 
94
+ function closeBtnClick(obj) {
95
+ if (obj == "box") {
96
+ closeBox();
97
+ } else if (obj == "toolbox") {
98
+ closeSide(toolbox);
99
+ }
100
+ }
101
+
102
  function closeBox() {
103
  chuanhuPopup.classList.remove('showBox');
104
  popupWrapper.classList.remove('showBox');
web_assets/stylesheet/ChuanhuChat.css CHANGED
@@ -123,8 +123,9 @@ body.popup-open {
123
 
124
  /* masks */
125
  .chuanhu-mask, .chuanhu-side-mask {
126
- background-color: gray;
127
- transition: opacity 0.3s ease;
 
128
  position: fixed;
129
  top: 0;
130
  left: 0;
@@ -134,14 +135,20 @@ body.popup-open {
134
  /* background-color: transparent; */
135
  }
136
  .chuanhu-mask {
137
- opacity: 0.5;
 
 
 
 
 
 
138
  }
139
 
140
  .chuanhu-side-mask {
141
- opacity: 0;
142
  }
143
  .chuanhu-top-mask {
144
- opacity: 0;
145
  z-index: 10001;
146
  }
147
 
@@ -168,6 +175,7 @@ body.popup-open {
168
  }
169
  #chuanhu-popup.showBox {
170
  display: block;
 
171
  }
172
 
173
  #chuanhu-popup > .gradio-box {
@@ -186,6 +194,7 @@ body.popup-open {
186
  right: 0;
187
  /* padding: 6px 64px; */
188
  background: var(--background-fill-primary);
 
189
 
190
  @media screen and (max-width: 639px) {
191
  padding: 6px 24px;
@@ -211,6 +220,9 @@ body.popup-open {
211
  position: absolute;
212
  top: 48px;
213
  }
 
 
 
214
 
215
  /* default invisible */
216
  #menu-area, #toolbox-area {
@@ -270,6 +282,7 @@ body.popup-open {
270
  }
271
  #menu-area.showSide {
272
  left: 0;
 
273
  /* margin-left: -16px; */
274
  }
275
 
@@ -292,6 +305,7 @@ body.popup-open {
292
  right: 0;
293
  top: calc( 10vh + 48px );
294
  margin: 0;
 
295
  }
296
  /* #menu-area.showSide, #toolbox-area.showSide {
297
  z-index: 9999;
@@ -316,7 +330,9 @@ body.popup-open {
316
  padding: 24px !important;
317
  border-bottom: 1.8px solid var(--border-color-primary);
318
  }
319
- #chuanhu-popup > .gradio-box > .gradio-row > .close-box-btn {
 
 
320
  max-width: 28px;
321
  display: flex;
322
  justify-content: flex-end;
@@ -364,7 +380,7 @@ body.popup-open {
364
  color: var(--button-primary-text-color);
365
  }
366
 
367
- @media screen and (max-width: 499px) {
368
 
369
  #popup-wrapper.showBox {
370
  place-items: end;
@@ -374,17 +390,22 @@ body.popup-open {
374
  height: calc( 90vh - 48px );
375
  border-radius: inherit inherit 0 0;
376
  }
 
377
  #chuanhu-popup > .gradio-box > .gradio-row:first-of-type {
378
- padding: 24px 24px 0 !important;
379
  border-bottom: 0;
380
  }
 
381
  #chuanhu-popup > .gradio-box > .gradio-tabs {
382
- height: calc( 90vh - 48px - 52px );
383
  width: 100vw;
384
  overflow: hidden;
385
  }
 
386
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tabitem {
387
- height: calc( 90vh - 48px - 104px );
 
 
388
  }
389
  /* 下面是弃用方案:横条按钮tab */
390
  /*
@@ -413,10 +434,11 @@ body.popup-open {
413
  background: var(--background-fill-secondary);
414
  }
415
  */
 
416
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav {
417
  display: flex;
418
  margin: 0;
419
- padding: 10px 16px 0;
420
  overflow-x: auto;
421
  overflow-y: hidden;
422
  flex-direction: row;
@@ -429,6 +451,7 @@ body.popup-open {
429
  border-bottom: 1px solid var(--border-color-primary);
430
  align-items: baseline;
431
  }
 
432
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav > button {
433
  display: inline-block;
434
  position: relative;
@@ -440,12 +463,14 @@ body.popup-open {
440
  background: none;
441
  transition: font-size 0.3s ease-in-out;
442
  }
 
443
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav > button.selected {
444
  background-color: unset !important;
445
  font-weight: bold;
446
  font-size: large;
447
  color: var(--body-text-color);
448
  }
 
449
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav > button.selected::after {
450
  content: "";
451
  background-color: var(--primary-600);
@@ -458,8 +483,66 @@ body.popup-open {
458
  transform: translateX(-50%);
459
  }
460
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
461
 
462
-
 
 
463
  /* #chuanhu-popup ul.options {
464
  transform: translate(-50%, -50%);
465
  } */
 
123
 
124
  /* masks */
125
  .chuanhu-mask, .chuanhu-side-mask {
126
+ /* background-color: gray; */
127
+ background-color: rgba(0, 0, 0, 0.5);
128
+ transition: background-color 0.3s ease;
129
  position: fixed;
130
  top: 0;
131
  left: 0;
 
135
  /* background-color: transparent; */
136
  }
137
  .chuanhu-mask {
138
+ background-color: rgba(0, 0, 0, 0.5);
139
+ -webkit-backdrop-filter: blur(2px);
140
+ backdrop-filter: blur(2px);
141
+ }
142
+ .mask-blur {
143
+ -webkit-backdrop-filter: blur(2px);
144
+ backdrop-filter: blur(2px);
145
  }
146
 
147
  .chuanhu-side-mask {
148
+ background-color: rgba(0, 0, 0, 0);
149
  }
150
  .chuanhu-top-mask {
151
+ /* background-color: rgba(0, 0, 0, 0.0); */
152
  z-index: 10001;
153
  }
154
 
 
175
  }
176
  #chuanhu-popup.showBox {
177
  display: block;
178
+ box-shadow: 0 2px 64px 4px rgba(0, 0, 0, 0.2);
179
  }
180
 
181
  #chuanhu-popup > .gradio-box {
 
194
  right: 0;
195
  /* padding: 6px 64px; */
196
  background: var(--background-fill-primary);
197
+ border-bottom: 1px solid var(--border-color-primary);
198
 
199
  @media screen and (max-width: 639px) {
200
  padding: 6px 24px;
 
220
  position: absolute;
221
  top: 48px;
222
  }
223
+ .api-docs-wrap {
224
+ margin-top: 64px;
225
+ }
226
 
227
  /* default invisible */
228
  #menu-area, #toolbox-area {
 
282
  }
283
  #menu-area.showSide {
284
  left: 0;
285
+ /* box-shadow: 0 2px 64px 4px rgba(0, 0, 0, 0.2); */
286
  /* margin-left: -16px; */
287
  }
288
 
 
305
  right: 0;
306
  top: calc( 10vh + 48px );
307
  margin: 0;
308
+ box-shadow: 0 2px 64px 4px rgba(0, 0, 0, 0.2);
309
  }
310
  /* #menu-area.showSide, #toolbox-area.showSide {
311
  z-index: 9999;
 
330
  padding: 24px !important;
331
  border-bottom: 1.8px solid var(--border-color-primary);
332
  }
333
+
334
+ #toolbox-area > .gradio-box > .gradio-row > .close-btn,
335
+ #chuanhu-popup > .gradio-box > .gradio-row > .close-btn {
336
  max-width: 28px;
337
  display: flex;
338
  justify-content: flex-end;
 
380
  color: var(--button-primary-text-color);
381
  }
382
 
383
+ @media screen and (max-width: 767px) {
384
 
385
  #popup-wrapper.showBox {
386
  place-items: end;
 
390
  height: calc( 90vh - 48px );
391
  border-radius: inherit inherit 0 0;
392
  }
393
+ #toolbox-area > .gradio-box > .gradio-row:first-of-type,
394
  #chuanhu-popup > .gradio-box > .gradio-row:first-of-type {
395
+ padding: 18px 24px 0 !important;
396
  border-bottom: 0;
397
  }
398
+ #toolbox-area > .gradio-box > .gradio-tabs,
399
  #chuanhu-popup > .gradio-box > .gradio-tabs {
400
+ height: auto;
401
  width: 100vw;
402
  overflow: hidden;
403
  }
404
+ #toolbox-area > .gradio-box > .gradio-tabs > div.tabitem,
405
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tabitem {
406
+ height: calc( 90vh - 48px - 46px - 45px );
407
+ overflow-x: auto;
408
+ border: none;
409
  }
410
  /* 下面是弃用方案:横条按钮tab */
411
  /*
 
434
  background: var(--background-fill-secondary);
435
  }
436
  */
437
+ #toolbox-area > .gradio-box > .gradio-tabs > div.tab-nav,
438
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav {
439
  display: flex;
440
  margin: 0;
441
+ padding: 6px 16px 0;
442
  overflow-x: auto;
443
  overflow-y: hidden;
444
  flex-direction: row;
 
451
  border-bottom: 1px solid var(--border-color-primary);
452
  align-items: baseline;
453
  }
454
+ #toolbox-area > .gradio-box > .gradio-tabs > div.tab-nav > button,
455
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav > button {
456
  display: inline-block;
457
  position: relative;
 
463
  background: none;
464
  transition: font-size 0.3s ease-in-out;
465
  }
466
+ #toolbox-area > .gradio-box > .gradio-tabs > div.tab-nav > button.selected,
467
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav > button.selected {
468
  background-color: unset !important;
469
  font-weight: bold;
470
  font-size: large;
471
  color: var(--body-text-color);
472
  }
473
+ #toolbox-area > .gradio-box > .gradio-tabs > div.tab-nav > button.selected::after,
474
  #chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav > button.selected::after {
475
  content: "";
476
  background-color: var(--primary-600);
 
483
  transform: translateX(-50%);
484
  }
485
  }
486
+ /* 下面是大屏幕的 */
487
+ @media screen and (min-width: 768px) {
488
+ #toolbox-area {
489
+ border-left: 1px solid var(--border-color-primary);
490
+ }
491
+ #toolbox-area > .gradio-box > .gradio-row > .close-btn {
492
+ display: none;
493
+ }
494
+ #toolbox-area > .gradio-box > .gradio-row:first-of-type {
495
+ display: none;
496
+ }
497
+ #toolbox-area > .gradio-box > .gradio-tabs{
498
+ height: auto;
499
+ width: var(--toolbox-width);
500
+ overflow: hidden;
501
+ }
502
+ #toolbox-area > .gradio-box > .gradio-tabs > div.tabitem {
503
+ height: calc( 90vh - 48px - 46px - 45px );
504
+ overflow-x: auto;
505
+ border: none;
506
+ }
507
+ #toolbox-area > .gradio-box > .gradio-tabs > div.tab-nav {
508
+ display: flex;
509
+ margin: 0;
510
+ padding: 4px;
511
+ overflow-x: auto;
512
+ overflow-y: hidden;
513
+ flex-direction: row;
514
+ flex-wrap: nowrap;
515
+ border-radius: 10px;
516
+ gap: 4px;
517
+ width: 100%;
518
+ height: auto;
519
+ background: var(--button-secondary-background-fill);
520
+ border-bottom: 1px solid var(--border-color-primary);
521
+ border:none;
522
+ align-items: baseline;
523
+ }
524
+ #toolbox-area > .gradio-box > .gradio-tabs > div.tab-nav > button {
525
+ display: inline-block;
526
+ position: relative;
527
+ padding: 7px 12px;
528
+ border: none;
529
+ white-space: nowrap;
530
+ width: auto;
531
+ text-align: center;
532
+ background: var(--button-secondary-background-fill);
533
+ transition: font-size 0.3s ease-in-out;
534
+ }
535
+ #toolbox-area > .gradio-box > .gradio-tabs > div.tab-nav > button.selected {
536
+ background-color: var(--primary-600);
537
+ font-weight: bold;
538
+ /* font-size: large; */
539
+ color: white;
540
+ }
541
+ }
542
 
543
+ #toolbox-area > .gradio-box {
544
+ padding: 0;
545
+ }
546
  /* #chuanhu-popup ul.options {
547
  transform: translate(-50%, -50%);
548
  } */