Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
•
4f6b126
1
Parent(s):
8154a1c
bugfix: 修复了删除新对话时会出错的问题,删除对话后现在会新建对话
Browse files- ChuanhuChatbot.py +203 -116
- modules/models/base_model.py +1 -1
ChuanhuChatbot.py
CHANGED
@@ -1,22 +1,21 @@
|
|
1 |
# -*- coding:utf-8 -*-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
import logging
|
3 |
logging.basicConfig(
|
4 |
level=logging.INFO,
|
5 |
format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s",
|
6 |
)
|
7 |
|
8 |
-
import colorama
|
9 |
-
import gradio as gr
|
10 |
-
|
11 |
-
from modules import config
|
12 |
-
from modules.config import *
|
13 |
-
from modules.utils import *
|
14 |
-
from modules.presets import *
|
15 |
-
from modules.overwrites import *
|
16 |
-
from modules.webui import *
|
17 |
-
from modules.repo import *
|
18 |
-
from modules.train_func import *
|
19 |
-
from modules.models.models import get_model
|
20 |
|
21 |
logging.getLogger("httpx").setLevel(logging.WARNING)
|
22 |
|
@@ -26,24 +25,28 @@ gr.Chatbot.postprocess = postprocess
|
|
26 |
# with open("web_assets/css/ChuanhuChat.css", "r", encoding="utf-8") as f:
|
27 |
# ChuanhuChatCSS = f.read()
|
28 |
|
|
|
29 |
def create_new_model():
|
30 |
-
return get_model(model_name
|
|
|
31 |
|
32 |
with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
33 |
user_name = gr.State("")
|
34 |
promptTemplates = gr.State(load_template(get_template_names()[0], mode=2))
|
35 |
user_question = gr.State("")
|
36 |
-
assert type(my_api_key)==str
|
37 |
user_api_key = gr.State(my_api_key)
|
38 |
current_model = gr.State()
|
39 |
|
40 |
topic = gr.State(i18n("未命名对话历史记录"))
|
41 |
|
42 |
with gr.Row(elem_id="chuanhu-header"):
|
43 |
-
gr.HTML(get_html("header_title.html").format(
|
|
|
44 |
status_display = gr.Markdown(get_geoip(), elem_id="status-display")
|
45 |
with gr.Row(elem_id="float-display"):
|
46 |
-
user_info = gr.Markdown(
|
|
|
47 |
update_info = gr.HTML(get_html("update.html").format(
|
48 |
current_version=repo_tag_html(),
|
49 |
version_time=version_time(),
|
@@ -51,14 +54,15 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
51 |
update_btn=i18n("更新"),
|
52 |
seenew_btn=i18n("详情"),
|
53 |
ok_btn=i18n("好"),
|
54 |
-
|
55 |
|
56 |
with gr.Row(equal_height=True, elem_id="chuanhu-body"):
|
57 |
|
58 |
with gr.Column(elem_id="menu-area"):
|
59 |
with gr.Row(elem_id="chuanhu-history"):
|
60 |
with gr.Column():
|
61 |
-
historySearchTextbox = gr.Textbox(show_label=False, placeholder=i18n(
|
|
|
62 |
with gr.Row():
|
63 |
with gr.Column(scale=6, elem_id="history-select-wrap"):
|
64 |
historySelectList = gr.Radio(
|
@@ -73,9 +77,11 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
73 |
with gr.Column(min_width=42, scale=1):
|
74 |
historyRefreshBtn = gr.Button(i18n("🔄"))
|
75 |
with gr.Column(min_width=42, scale=1):
|
76 |
-
historyDeleteBtn = gr.Button(
|
|
|
77 |
with gr.Column(min_width=42, scale=1):
|
78 |
-
historyDownloadBtn = gr.Button(
|
|
|
79 |
with gr.Row():
|
80 |
with gr.Column(scale=6):
|
81 |
saveFileName = gr.Textbox(
|
@@ -87,12 +93,15 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
87 |
# container=False,
|
88 |
)
|
89 |
with gr.Column(scale=1):
|
90 |
-
saveHistoryBtn = gr.Button(
|
91 |
-
|
|
|
|
|
92 |
gr.Markdown(i18n("默认保存于history��件夹"))
|
93 |
with gr.Row():
|
94 |
with gr.Column():
|
95 |
-
downloadFile = gr.File(
|
|
|
96 |
|
97 |
with gr.Column(elem_id="chuanhu-menu-footer"):
|
98 |
with gr.Row(elem_id="chuanhu-func-nav"):
|
@@ -100,15 +109,13 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
100 |
# gr.HTML(get_html("footer.html").format(versions=versions_html()), elem_id="footer")
|
101 |
# gr.Markdown(CHUANHU_DESCRIPTION, elem_id="chuanhu-author")
|
102 |
|
103 |
-
|
104 |
-
|
105 |
with gr.Column(elem_id="chuanhu-area", scale=5):
|
106 |
with gr.Column(elem_id="chatbot-area"):
|
107 |
with gr.Row(elem_id="chatbot-header"):
|
108 |
model_select_dropdown = gr.Dropdown(
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
lora_select_dropdown = gr.Dropdown(
|
113 |
label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False,
|
114 |
container=False,
|
@@ -116,7 +123,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
116 |
gr.HTML(get_html("chatbot_header_btn.html").format(
|
117 |
json_label=i18n("历史记录(JSON)"),
|
118 |
md_label=i18n("导出为 Markdown")
|
119 |
-
),elem_id="chatbot-header-btn-bar")
|
120 |
with gr.Row():
|
121 |
chatbot = gr.Chatbot(
|
122 |
label="Chuanhu Chat",
|
@@ -148,30 +155,39 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
148 |
# container=False
|
149 |
)
|
150 |
with gr.Column(min_width=42, scale=1, elem_id="chatbot-ctrl-btns"):
|
151 |
-
submitBtn = gr.Button(
|
152 |
-
|
153 |
-
|
|
|
|
|
|
|
154 |
with gr.Column(min_width=120, scale=1):
|
155 |
emptyBtn = gr.Button(
|
156 |
i18n("🧹 新的对话"), elem_id="empty-btn"
|
157 |
)
|
158 |
with gr.Column(min_width=120, scale=1):
|
159 |
-
retryBtn = gr.Button(
|
|
|
160 |
with gr.Column(min_width=120, scale=1):
|
161 |
delFirstBtn = gr.Button(i18n("🗑️ 删除最旧对话"))
|
162 |
with gr.Column(min_width=120, scale=1):
|
163 |
-
delLastBtn = gr.Button(
|
|
|
164 |
with gr.Row(visible=False) as like_dislike_area:
|
165 |
with gr.Column(min_width=20, scale=1):
|
166 |
-
likeBtn = gr.Button(
|
|
|
167 |
with gr.Column(min_width=20, scale=1):
|
168 |
-
dislikeBtn = gr.Button(
|
|
|
169 |
|
170 |
with gr.Column(elem_id="toolbox-area", scale=1):
|
171 |
-
|
|
|
172 |
with gr.Row():
|
173 |
gr.Markdown("## "+i18n("工具箱"))
|
174 |
-
gr.HTML(get_html("close_btn.html").format(
|
|
|
175 |
with gr.Tabs(elem_id="chuanhu-toolbox-tabs"):
|
176 |
with gr.Tab(label=i18n("对话")):
|
177 |
with gr.Accordion(label="Prompt", open=True):
|
@@ -194,28 +210,34 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
194 |
container=False,
|
195 |
)
|
196 |
with gr.Column(scale=1):
|
197 |
-
templateRefreshBtn = gr.Button(
|
|
|
198 |
with gr.Row():
|
199 |
with gr.Column():
|
200 |
templateSelectDropdown = gr.Dropdown(
|
201 |
label=i18n("从Prompt模板中加载"),
|
202 |
choices=load_template(
|
203 |
-
get_template_names()[
|
|
|
204 |
),
|
205 |
multiselect=False,
|
206 |
container=False,
|
207 |
)
|
208 |
gr.Markdown("---", elem_classes="hr-line")
|
209 |
with gr.Accordion(label=i18n("知识库"), open=True):
|
210 |
-
use_websearch_checkbox = gr.Checkbox(label=i18n(
|
211 |
-
|
212 |
-
|
|
|
|
|
|
|
213 |
summarize_btn = gr.Button(i18n("总结"))
|
214 |
# TODO: 公式ocr
|
215 |
# formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
|
216 |
|
217 |
with gr.Tab(label=i18n("参数")):
|
218 |
-
gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️"),
|
|
|
219 |
with gr.Accordion(i18n("参数"), open=True):
|
220 |
temperature_slider = gr.Slider(
|
221 |
minimum=-0,
|
@@ -295,7 +317,8 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
295 |
lines=1,
|
296 |
)
|
297 |
with gr.Tab(label=i18n("拓展")):
|
298 |
-
gr.Markdown(
|
|
|
299 |
|
300 |
# changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
|
301 |
|
@@ -304,7 +327,8 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
304 |
with gr.Box(elem_id="chuanhu-setting"):
|
305 |
with gr.Row():
|
306 |
gr.Markdown("## "+i18n("设置"))
|
307 |
-
gr.HTML(get_html("close_btn.html").format(
|
|
|
308 |
with gr.Tabs(elem_id="chuanhu-setting-tabs"):
|
309 |
with gr.Tab(label=i18n("模型")):
|
310 |
keyTxt = gr.Textbox(
|
@@ -316,9 +340,11 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
316 |
label="API-Key",
|
317 |
)
|
318 |
if multi_api_key:
|
319 |
-
usageTxt = gr.Markdown(i18n(
|
|
|
320 |
else:
|
321 |
-
usageTxt = gr.Markdown(i18n(
|
|
|
322 |
# model_select_dropdown = gr.Dropdown(
|
323 |
# label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
|
324 |
# )
|
@@ -335,15 +361,18 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
335 |
)
|
336 |
|
337 |
with gr.Tab(label=i18n("高级")):
|
338 |
-
gr.HTML(get_html("appearance_switcher.html").format(
|
|
|
339 |
use_streaming_checkbox = gr.Checkbox(
|
340 |
-
|
341 |
-
|
342 |
-
single_turn_checkbox = gr.Checkbox(label=i18n(
|
|
|
343 |
# checkUpdateBtn = gr.Button(i18n("🔄 检查更新..."), visible=check_update)
|
344 |
|
345 |
with gr.Tab(i18n("网络")):
|
346 |
-
gr.Markdown(
|
|
|
347 |
default_btn = gr.Button(i18n("🔙 恢复默认网络设置"))
|
348 |
# 网络代理
|
349 |
proxyTxt = gr.Textbox(
|
@@ -371,34 +400,47 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
371 |
)
|
372 |
|
373 |
with gr.Tab(label=i18n("关于"), elem_id="about-tab"):
|
374 |
-
gr.Markdown(
|
|
|
375 |
gr.Markdown("# "+i18n("川虎Chat"))
|
376 |
-
gr.HTML(get_html("footer.html").format(
|
|
|
377 |
gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
|
378 |
|
379 |
with gr.Box(elem_id="chuanhu-training"):
|
380 |
with gr.Row():
|
381 |
gr.Markdown("## "+i18n("训练"))
|
382 |
-
gr.HTML(get_html("close_btn.html").format(
|
|
|
383 |
with gr.Tabs(elem_id="chuanhu-training-tabs"):
|
384 |
with gr.Tab(label="OpenAI "+i18n("微调")):
|
385 |
-
openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n(
|
|
|
386 |
|
387 |
with gr.Tab(label=i18n("准备数据集")):
|
388 |
-
dataset_preview_json = gr.JSON(
|
389 |
-
|
390 |
-
|
|
|
|
|
|
|
391 |
|
392 |
with gr.Tab(label=i18n("训练")):
|
393 |
-
openai_ft_file_id = gr.Textbox(label=i18n(
|
394 |
-
|
395 |
-
|
396 |
-
|
|
|
|
|
|
|
|
|
397 |
|
398 |
with gr.Tab(label=i18n("状态")):
|
399 |
openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
|
400 |
-
openai_cancel_all_jobs_btn = gr.Button(
|
401 |
-
|
|
|
|
|
402 |
|
403 |
with gr.Box(elem_id="web-config", visible=False):
|
404 |
gr.HTML(get_html('web_config.html').format(
|
@@ -409,26 +451,34 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
409 |
usingLatest_i18n=i18n("您使用的就是最新版!"),
|
410 |
updatingMsg_i18n=i18n("正在尝试更新..."),
|
411 |
updateSuccess_i18n=i18n("更新成功,请重启本程序"),
|
412 |
-
updateFailure_i18n=i18n(
|
|
|
413 |
regenerate_i18n=i18n("重新生成"),
|
414 |
deleteRound_i18n=i18n("删除这轮问答"),
|
415 |
renameChat_i18n=i18n("重命名该对话"),
|
416 |
))
|
417 |
with gr.Box(elem_id="fake-gradio-components", visible=False):
|
418 |
-
updateChuanhuBtn = gr.Button(
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
|
|
|
|
|
|
423 |
|
424 |
# https://github.com/gradio-app/gradio/pull/3296
|
|
|
425 |
def create_greeting(request: gr.Request):
|
426 |
-
if hasattr(request, "username") and request.username:
|
427 |
logging.info(f"Get User Name: {request.username}")
|
428 |
-
user_info, user_name = gr.Markdown.update(
|
|
|
429 |
else:
|
430 |
-
user_info, user_name = gr.Markdown.update(
|
431 |
-
|
|
|
|
|
432 |
current_model.set_user_identifier(user_name)
|
433 |
if not hide_history_when_not_logged_in or user_name:
|
434 |
system_prompt, chatbot = current_model.auto_load()
|
@@ -436,7 +486,8 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
436 |
system_prompt = gr.update()
|
437 |
chatbot = gr.Chatbot.update(label=MODELS[DEFAULT_MODEL])
|
438 |
return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), system_prompt, chatbot, init_history_list(user_name)
|
439 |
-
demo.load(create_greeting, inputs=None, outputs=[
|
|
|
440 |
chatgpt_predict_args = dict(
|
441 |
fn=predict,
|
442 |
inputs=[
|
@@ -468,11 +519,13 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
468 |
)
|
469 |
|
470 |
transfer_input_args = dict(
|
471 |
-
fn=transfer_input, inputs=[user_input], outputs=[
|
|
|
472 |
)
|
473 |
|
474 |
get_usage_args = dict(
|
475 |
-
fn=billing_info, inputs=[current_model], outputs=[
|
|
|
476 |
)
|
477 |
|
478 |
load_history_from_file_args = dict(
|
@@ -485,18 +538,21 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
485 |
fn=get_history_list, inputs=[user_name], outputs=[historySelectList]
|
486 |
)
|
487 |
|
488 |
-
|
489 |
# Chatbot
|
490 |
cancelBtn.click(interrupt, [current_model], [])
|
491 |
|
492 |
-
user_input.submit(**transfer_input_args).then(**
|
|
|
493 |
user_input.submit(**get_usage_args)
|
494 |
|
495 |
-
submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args,
|
|
|
496 |
submitBtn.click(**get_usage_args)
|
497 |
|
498 |
-
index_files.change(handle_file_upload, [current_model, index_files, chatbot, language_select_dropdown], [
|
499 |
-
|
|
|
|
|
500 |
|
501 |
emptyBtn.click(
|
502 |
reset,
|
@@ -551,16 +607,23 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
551 |
two_column.change(update_doc_config, [two_column], None)
|
552 |
|
553 |
# LLM Models
|
554 |
-
keyTxt.change(set_key, [current_model, keyTxt], [
|
|
|
555 |
keyTxt.submit(**get_usage_args)
|
556 |
-
single_turn_checkbox.change(
|
557 |
-
|
558 |
-
model_select_dropdown.change(
|
559 |
-
|
|
|
|
|
|
|
|
|
560 |
|
561 |
# Template
|
562 |
-
systemPromptTxt.change(set_system_prompt, [
|
563 |
-
|
|
|
|
|
564 |
templateFileSelectDropdown.input(
|
565 |
load_template,
|
566 |
[templateFileSelectDropdown],
|
@@ -590,10 +653,18 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
590 |
show_progress=True,
|
591 |
)
|
592 |
historyRefreshBtn.click(**refresh_history_args)
|
593 |
-
historyDeleteBtn.click(delete_chat_history, [current_model, historySelectList, user_name], [status_display, historySelectList, chatbot], _js='(a,b,c)=>{return showConfirmationDialog(a, b, c);}')
|
|
|
|
|
|
|
|
|
|
|
|
|
594 |
historySelectList.input(**load_history_from_file_args)
|
595 |
-
downloadFile.change(upload_chat_history, [current_model, downloadFile, user_name], [
|
596 |
-
|
|
|
|
|
597 |
historySearchTextbox.input(
|
598 |
filter_history,
|
599 |
[user_name, historySearchTextbox],
|
@@ -601,28 +672,45 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
601 |
)
|
602 |
|
603 |
# Train
|
604 |
-
dataset_selection.upload(handle_dataset_selection, dataset_selection, [
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
614 |
|
615 |
# Advanced
|
616 |
-
max_context_length_slider.change(
|
617 |
-
|
|
|
|
|
618 |
top_p_slider.change(set_top_p, [current_model, top_p_slider], None)
|
619 |
-
n_choices_slider.change(
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
626 |
|
627 |
default_btn.click(
|
628 |
reset_default, [], [apihostTxt, proxyTxt, status_display], show_progress=True
|
@@ -660,7 +748,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
660 |
outputs=[use_websearch_checkbox],
|
661 |
_js='(a)=>{return bgChangeOnlineSearch(a);}'
|
662 |
)
|
663 |
-
historySelectBtn.click(
|
664 |
fn=load_chat_history,
|
665 |
inputs=[current_model, historySelectList],
|
666 |
outputs=[saveFileName, systemPromptTxt, chatbot],
|
@@ -668,7 +756,6 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
668 |
)
|
669 |
|
670 |
|
671 |
-
|
672 |
logging.info(
|
673 |
colorama.Back.GREEN
|
674 |
+ "\n川虎的温馨提示:访问 http://localhost:7860 查看界面"
|
@@ -686,5 +773,5 @@ if __name__ == "__main__":
|
|
686 |
share=share,
|
687 |
auth=auth_from_conf if authflag else None,
|
688 |
favicon_path="./web_assets/favicon.ico",
|
689 |
-
inbrowser=not dockerflag,
|
690 |
)
|
|
|
1 |
# -*- coding:utf-8 -*-
|
2 |
+
from modules.models.models import get_model
|
3 |
+
from modules.train_func import *
|
4 |
+
from modules.repo import *
|
5 |
+
from modules.webui import *
|
6 |
+
from modules.overwrites import *
|
7 |
+
from modules.presets import *
|
8 |
+
from modules.utils import *
|
9 |
+
from modules.config import *
|
10 |
+
from modules import config
|
11 |
+
import gradio as gr
|
12 |
+
import colorama
|
13 |
import logging
|
14 |
logging.basicConfig(
|
15 |
level=logging.INFO,
|
16 |
format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s",
|
17 |
)
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
logging.getLogger("httpx").setLevel(logging.WARNING)
|
21 |
|
|
|
25 |
# with open("web_assets/css/ChuanhuChat.css", "r", encoding="utf-8") as f:
|
26 |
# ChuanhuChatCSS = f.read()
|
27 |
|
28 |
+
|
29 |
def create_new_model():
|
30 |
+
return get_model(model_name=MODELS[DEFAULT_MODEL], access_key=my_api_key)[0]
|
31 |
+
|
32 |
|
33 |
with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
34 |
user_name = gr.State("")
|
35 |
promptTemplates = gr.State(load_template(get_template_names()[0], mode=2))
|
36 |
user_question = gr.State("")
|
37 |
+
assert type(my_api_key) == str
|
38 |
user_api_key = gr.State(my_api_key)
|
39 |
current_model = gr.State()
|
40 |
|
41 |
topic = gr.State(i18n("未命名对话历史记录"))
|
42 |
|
43 |
with gr.Row(elem_id="chuanhu-header"):
|
44 |
+
gr.HTML(get_html("header_title.html").format(
|
45 |
+
app_title=CHUANHU_TITLE), elem_id="app-title")
|
46 |
status_display = gr.Markdown(get_geoip(), elem_id="status-display")
|
47 |
with gr.Row(elem_id="float-display"):
|
48 |
+
user_info = gr.Markdown(
|
49 |
+
value="getting user info...", elem_id="user-info")
|
50 |
update_info = gr.HTML(get_html("update.html").format(
|
51 |
current_version=repo_tag_html(),
|
52 |
version_time=version_time(),
|
|
|
54 |
update_btn=i18n("更新"),
|
55 |
seenew_btn=i18n("详情"),
|
56 |
ok_btn=i18n("好"),
|
57 |
+
), visible=check_update)
|
58 |
|
59 |
with gr.Row(equal_height=True, elem_id="chuanhu-body"):
|
60 |
|
61 |
with gr.Column(elem_id="menu-area"):
|
62 |
with gr.Row(elem_id="chuanhu-history"):
|
63 |
with gr.Column():
|
64 |
+
historySearchTextbox = gr.Textbox(show_label=False, placeholder=i18n(
|
65 |
+
"搜索..."), lines=1, elem_id="history-search-tb")
|
66 |
with gr.Row():
|
67 |
with gr.Column(scale=6, elem_id="history-select-wrap"):
|
68 |
historySelectList = gr.Radio(
|
|
|
77 |
with gr.Column(min_width=42, scale=1):
|
78 |
historyRefreshBtn = gr.Button(i18n("🔄"))
|
79 |
with gr.Column(min_width=42, scale=1):
|
80 |
+
historyDeleteBtn = gr.Button(
|
81 |
+
i18n("🗑️"), elem_id="gr-history-delete-btn")
|
82 |
with gr.Column(min_width=42, scale=1):
|
83 |
+
historyDownloadBtn = gr.Button(
|
84 |
+
i18n("⏬"), elem_id="gr-history-download-btn")
|
85 |
with gr.Row():
|
86 |
with gr.Column(scale=6):
|
87 |
saveFileName = gr.Textbox(
|
|
|
93 |
# container=False,
|
94 |
)
|
95 |
with gr.Column(scale=1):
|
96 |
+
saveHistoryBtn = gr.Button(
|
97 |
+
i18n("💾 保存对话"), elem_id="gr-history-save-btn")
|
98 |
+
exportMarkdownBtn = gr.Button(
|
99 |
+
i18n("📝 导出为Markdown"))
|
100 |
gr.Markdown(i18n("默认保存于history��件夹"))
|
101 |
with gr.Row():
|
102 |
with gr.Column():
|
103 |
+
downloadFile = gr.File(
|
104 |
+
interactive=True, label=i18n("下载/上传历史记录"))
|
105 |
|
106 |
with gr.Column(elem_id="chuanhu-menu-footer"):
|
107 |
with gr.Row(elem_id="chuanhu-func-nav"):
|
|
|
109 |
# gr.HTML(get_html("footer.html").format(versions=versions_html()), elem_id="footer")
|
110 |
# gr.Markdown(CHUANHU_DESCRIPTION, elem_id="chuanhu-author")
|
111 |
|
|
|
|
|
112 |
with gr.Column(elem_id="chuanhu-area", scale=5):
|
113 |
with gr.Column(elem_id="chatbot-area"):
|
114 |
with gr.Row(elem_id="chatbot-header"):
|
115 |
model_select_dropdown = gr.Dropdown(
|
116 |
+
label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True,
|
117 |
+
show_label=False, container=False, elem_id="model-select-dropdown"
|
118 |
+
)
|
119 |
lora_select_dropdown = gr.Dropdown(
|
120 |
label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False,
|
121 |
container=False,
|
|
|
123 |
gr.HTML(get_html("chatbot_header_btn.html").format(
|
124 |
json_label=i18n("历史记录(JSON)"),
|
125 |
md_label=i18n("导出为 Markdown")
|
126 |
+
), elem_id="chatbot-header-btn-bar")
|
127 |
with gr.Row():
|
128 |
chatbot = gr.Chatbot(
|
129 |
label="Chuanhu Chat",
|
|
|
155 |
# container=False
|
156 |
)
|
157 |
with gr.Column(min_width=42, scale=1, elem_id="chatbot-ctrl-btns"):
|
158 |
+
submitBtn = gr.Button(
|
159 |
+
value="", variant="primary", elem_id="submit-btn")
|
160 |
+
cancelBtn = gr.Button(
|
161 |
+
value="", variant="secondary", visible=False, elem_id="cancel-btn")
|
162 |
+
# Note: Buttons below are set invisible in UI. But they are used in JS.
|
163 |
+
with gr.Row(elem_id="chatbot-buttons", visible=False):
|
164 |
with gr.Column(min_width=120, scale=1):
|
165 |
emptyBtn = gr.Button(
|
166 |
i18n("🧹 新的对话"), elem_id="empty-btn"
|
167 |
)
|
168 |
with gr.Column(min_width=120, scale=1):
|
169 |
+
retryBtn = gr.Button(
|
170 |
+
i18n("🔄 重新生成"), elem_id="gr-retry-btn")
|
171 |
with gr.Column(min_width=120, scale=1):
|
172 |
delFirstBtn = gr.Button(i18n("🗑️ 删除最旧对话"))
|
173 |
with gr.Column(min_width=120, scale=1):
|
174 |
+
delLastBtn = gr.Button(
|
175 |
+
i18n("🗑️ 删除最新对话"), elem_id="gr-dellast-btn")
|
176 |
with gr.Row(visible=False) as like_dislike_area:
|
177 |
with gr.Column(min_width=20, scale=1):
|
178 |
+
likeBtn = gr.Button(
|
179 |
+
i18n("👍"), elem_id="gr-like-btn")
|
180 |
with gr.Column(min_width=20, scale=1):
|
181 |
+
dislikeBtn = gr.Button(
|
182 |
+
i18n("👎"), elem_id="gr-dislike-btn")
|
183 |
|
184 |
with gr.Column(elem_id="toolbox-area", scale=1):
|
185 |
+
# For CSS setting, there is an extra box. Don't remove it.
|
186 |
+
with gr.Box(elem_id="chuanhu-toolbox"):
|
187 |
with gr.Row():
|
188 |
gr.Markdown("## "+i18n("工具箱"))
|
189 |
+
gr.HTML(get_html("close_btn.html").format(
|
190 |
+
obj="toolbox"), elem_classes="close-btn")
|
191 |
with gr.Tabs(elem_id="chuanhu-toolbox-tabs"):
|
192 |
with gr.Tab(label=i18n("对话")):
|
193 |
with gr.Accordion(label="Prompt", open=True):
|
|
|
210 |
container=False,
|
211 |
)
|
212 |
with gr.Column(scale=1):
|
213 |
+
templateRefreshBtn = gr.Button(
|
214 |
+
i18n("🔄 刷新"))
|
215 |
with gr.Row():
|
216 |
with gr.Column():
|
217 |
templateSelectDropdown = gr.Dropdown(
|
218 |
label=i18n("从Prompt模板中加载"),
|
219 |
choices=load_template(
|
220 |
+
get_template_names()[
|
221 |
+
0], mode=1
|
222 |
),
|
223 |
multiselect=False,
|
224 |
container=False,
|
225 |
)
|
226 |
gr.Markdown("---", elem_classes="hr-line")
|
227 |
with gr.Accordion(label=i18n("知识库"), open=True):
|
228 |
+
use_websearch_checkbox = gr.Checkbox(label=i18n(
|
229 |
+
"使用在线搜索"), value=False, elem_classes="switch-checkbox", elem_id="gr-websearch-cb", visible=False)
|
230 |
+
index_files = gr.Files(label=i18n(
|
231 |
+
"上传"), type="file", elem_id="upload-index-file")
|
232 |
+
two_column = gr.Checkbox(label=i18n(
|
233 |
+
"双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
|
234 |
summarize_btn = gr.Button(i18n("总结"))
|
235 |
# TODO: 公式ocr
|
236 |
# formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
|
237 |
|
238 |
with gr.Tab(label=i18n("参数")):
|
239 |
+
gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️"),
|
240 |
+
elem_id="advanced-warning")
|
241 |
with gr.Accordion(i18n("参数"), open=True):
|
242 |
temperature_slider = gr.Slider(
|
243 |
minimum=-0,
|
|
|
317 |
lines=1,
|
318 |
)
|
319 |
with gr.Tab(label=i18n("拓展")):
|
320 |
+
gr.Markdown(
|
321 |
+
"Will be here soon...\n(We hope)\n\nAnd we hope you can help us to make more extensions!")
|
322 |
|
323 |
# changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
|
324 |
|
|
|
327 |
with gr.Box(elem_id="chuanhu-setting"):
|
328 |
with gr.Row():
|
329 |
gr.Markdown("## "+i18n("设置"))
|
330 |
+
gr.HTML(get_html("close_btn.html").format(
|
331 |
+
obj="box"), elem_classes="close-btn")
|
332 |
with gr.Tabs(elem_id="chuanhu-setting-tabs"):
|
333 |
with gr.Tab(label=i18n("模型")):
|
334 |
keyTxt = gr.Textbox(
|
|
|
340 |
label="API-Key",
|
341 |
)
|
342 |
if multi_api_key:
|
343 |
+
usageTxt = gr.Markdown(i18n(
|
344 |
+
"多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
345 |
else:
|
346 |
+
usageTxt = gr.Markdown(i18n(
|
347 |
+
"**发送消息** 或 **提交key** 以显示额度"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
348 |
# model_select_dropdown = gr.Dropdown(
|
349 |
# label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
|
350 |
# )
|
|
|
361 |
)
|
362 |
|
363 |
with gr.Tab(label=i18n("高级")):
|
364 |
+
gr.HTML(get_html("appearance_switcher.html").format(
|
365 |
+
label=i18n("切换亮暗色主题")), elem_classes="insert-block", visible=False)
|
366 |
use_streaming_checkbox = gr.Checkbox(
|
367 |
+
label=i18n("实时传输回答"), value=True, visible=ENABLE_STREAMING_OPTION, elem_classes="switch-checkbox"
|
368 |
+
)
|
369 |
+
single_turn_checkbox = gr.Checkbox(label=i18n(
|
370 |
+
"单轮对话"), value=False, elem_classes="switch-checkbox", elem_id="gr-single-session-cb", visible=False)
|
371 |
# checkUpdateBtn = gr.Button(i18n("🔄 检查更新..."), visible=check_update)
|
372 |
|
373 |
with gr.Tab(i18n("网络")):
|
374 |
+
gr.Markdown(
|
375 |
+
i18n("⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置"), elem_id="netsetting-warning")
|
376 |
default_btn = gr.Button(i18n("🔙 恢复默认网络设置"))
|
377 |
# 网络代理
|
378 |
proxyTxt = gr.Textbox(
|
|
|
400 |
)
|
401 |
|
402 |
with gr.Tab(label=i18n("关于"), elem_id="about-tab"):
|
403 |
+
gr.Markdown(
|
404 |
+
'<img alt="Chuanhu Chat logo" src="file=web_assets/icon/any-icon-512.png" style="max-width: 144px;">')
|
405 |
gr.Markdown("# "+i18n("川虎Chat"))
|
406 |
+
gr.HTML(get_html("footer.html").format(
|
407 |
+
versions=versions_html()), elem_id="footer")
|
408 |
gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
|
409 |
|
410 |
with gr.Box(elem_id="chuanhu-training"):
|
411 |
with gr.Row():
|
412 |
gr.Markdown("## "+i18n("训练"))
|
413 |
+
gr.HTML(get_html("close_btn.html").format(
|
414 |
+
obj="box"), elem_classes="close-btn")
|
415 |
with gr.Tabs(elem_id="chuanhu-training-tabs"):
|
416 |
with gr.Tab(label="OpenAI "+i18n("微调")):
|
417 |
+
openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n(
|
418 |
+
"查看[使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)"))
|
419 |
|
420 |
with gr.Tab(label=i18n("准备数据集")):
|
421 |
+
dataset_preview_json = gr.JSON(
|
422 |
+
label=i18n("数据集预览"), readonly=True)
|
423 |
+
dataset_selection = gr.Files(label=i18n("选择数据集"), file_types=[
|
424 |
+
".xlsx", ".jsonl"], file_count="single")
|
425 |
+
upload_to_openai_btn = gr.Button(
|
426 |
+
i18n("上传到OpenAI"), variant="primary", interactive=False)
|
427 |
|
428 |
with gr.Tab(label=i18n("训练")):
|
429 |
+
openai_ft_file_id = gr.Textbox(label=i18n(
|
430 |
+
"文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动填充"))
|
431 |
+
openai_ft_suffix = gr.Textbox(label=i18n(
|
432 |
+
"模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
|
433 |
+
openai_train_epoch_slider = gr.Slider(label=i18n(
|
434 |
+
"训练轮数(Epochs)"), minimum=1, maximum=100, value=3, step=1, interactive=True)
|
435 |
+
openai_start_train_btn = gr.Button(
|
436 |
+
i18n("开始训练"), variant="primary", interactive=False)
|
437 |
|
438 |
with gr.Tab(label=i18n("状态")):
|
439 |
openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
|
440 |
+
openai_cancel_all_jobs_btn = gr.Button(
|
441 |
+
i18n("取消所有任务"))
|
442 |
+
add_to_models_btn = gr.Button(
|
443 |
+
i18n("添加训练好的模型到模型列表"), interactive=False)
|
444 |
|
445 |
with gr.Box(elem_id="web-config", visible=False):
|
446 |
gr.HTML(get_html('web_config.html').format(
|
|
|
451 |
usingLatest_i18n=i18n("您使用的就是最新版!"),
|
452 |
updatingMsg_i18n=i18n("正在尝试更新..."),
|
453 |
updateSuccess_i18n=i18n("更新成功,请重启本程序"),
|
454 |
+
updateFailure_i18n=i18n(
|
455 |
+
'更新失败,请尝试<a href="https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新" target="_blank">手动更新</a>'),
|
456 |
regenerate_i18n=i18n("重新生成"),
|
457 |
deleteRound_i18n=i18n("删除这轮问答"),
|
458 |
renameChat_i18n=i18n("重命名该对话"),
|
459 |
))
|
460 |
with gr.Box(elem_id="fake-gradio-components", visible=False):
|
461 |
+
updateChuanhuBtn = gr.Button(
|
462 |
+
visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
|
463 |
+
changeSingleSessionBtn = gr.Button(
|
464 |
+
visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
|
465 |
+
changeOnlineSearchBtn = gr.Button(
|
466 |
+
visible=False, elem_classes="invisible-btn", elem_id="change-online-search-btn")
|
467 |
+
historySelectBtn = gr.Button(
|
468 |
+
visible=False, elem_classes="invisible-btn", elem_id="history-select-btn") # Not used
|
469 |
|
470 |
# https://github.com/gradio-app/gradio/pull/3296
|
471 |
+
|
472 |
def create_greeting(request: gr.Request):
|
473 |
+
if hasattr(request, "username") and request.username: # is not None or is not ""
|
474 |
logging.info(f"Get User Name: {request.username}")
|
475 |
+
user_info, user_name = gr.Markdown.update(
|
476 |
+
value=f"User: {request.username}"), request.username
|
477 |
else:
|
478 |
+
user_info, user_name = gr.Markdown.update(
|
479 |
+
value=f"", visible=False), ""
|
480 |
+
current_model = get_model(
|
481 |
+
model_name=MODELS[DEFAULT_MODEL], access_key=my_api_key)[0]
|
482 |
current_model.set_user_identifier(user_name)
|
483 |
if not hide_history_when_not_logged_in or user_name:
|
484 |
system_prompt, chatbot = current_model.auto_load()
|
|
|
486 |
system_prompt = gr.update()
|
487 |
chatbot = gr.Chatbot.update(label=MODELS[DEFAULT_MODEL])
|
488 |
return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), system_prompt, chatbot, init_history_list(user_name)
|
489 |
+
demo.load(create_greeting, inputs=None, outputs=[
|
490 |
+
user_info, user_name, current_model, like_dislike_area, systemPromptTxt, chatbot, historySelectList], api_name="load")
|
491 |
chatgpt_predict_args = dict(
|
492 |
fn=predict,
|
493 |
inputs=[
|
|
|
519 |
)
|
520 |
|
521 |
transfer_input_args = dict(
|
522 |
+
fn=transfer_input, inputs=[user_input], outputs=[
|
523 |
+
user_question, user_input, submitBtn, cancelBtn], show_progress=True
|
524 |
)
|
525 |
|
526 |
get_usage_args = dict(
|
527 |
+
fn=billing_info, inputs=[current_model], outputs=[
|
528 |
+
usageTxt], show_progress=False
|
529 |
)
|
530 |
|
531 |
load_history_from_file_args = dict(
|
|
|
538 |
fn=get_history_list, inputs=[user_name], outputs=[historySelectList]
|
539 |
)
|
540 |
|
|
|
541 |
# Chatbot
|
542 |
cancelBtn.click(interrupt, [current_model], [])
|
543 |
|
544 |
+
user_input.submit(**transfer_input_args).then(**
|
545 |
+
chatgpt_predict_args).then(**end_outputing_args)
|
546 |
user_input.submit(**get_usage_args)
|
547 |
|
548 |
+
submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args,
|
549 |
+
api_name="predict").then(**end_outputing_args)
|
550 |
submitBtn.click(**get_usage_args)
|
551 |
|
552 |
+
index_files.change(handle_file_upload, [current_model, index_files, chatbot, language_select_dropdown], [
|
553 |
+
index_files, chatbot, status_display])
|
554 |
+
summarize_btn.click(handle_summarize_index, [
|
555 |
+
current_model, index_files, chatbot, language_select_dropdown], [chatbot, status_display])
|
556 |
|
557 |
emptyBtn.click(
|
558 |
reset,
|
|
|
607 |
two_column.change(update_doc_config, [two_column], None)
|
608 |
|
609 |
# LLM Models
|
610 |
+
keyTxt.change(set_key, [current_model, keyTxt], [
|
611 |
+
user_api_key, status_display], api_name="set_key").then(**get_usage_args)
|
612 |
keyTxt.submit(**get_usage_args)
|
613 |
+
single_turn_checkbox.change(
|
614 |
+
set_single_turn, [current_model, single_turn_checkbox], None)
|
615 |
+
model_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider, top_p_slider, systemPromptTxt, user_name], [
|
616 |
+
current_model, status_display, chatbot, lora_select_dropdown, user_api_key, keyTxt], show_progress=True, api_name="get_model")
|
617 |
+
model_select_dropdown.change(toggle_like_btn_visibility, [model_select_dropdown], [
|
618 |
+
like_dislike_area], show_progress=False)
|
619 |
+
lora_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider,
|
620 |
+
top_p_slider, systemPromptTxt, user_name], [current_model, status_display, chatbot], show_progress=True)
|
621 |
|
622 |
# Template
|
623 |
+
systemPromptTxt.change(set_system_prompt, [
|
624 |
+
current_model, systemPromptTxt], None)
|
625 |
+
templateRefreshBtn.click(get_template_dropdown, None, [
|
626 |
+
templateFileSelectDropdown])
|
627 |
templateFileSelectDropdown.input(
|
628 |
load_template,
|
629 |
[templateFileSelectDropdown],
|
|
|
653 |
show_progress=True,
|
654 |
)
|
655 |
historyRefreshBtn.click(**refresh_history_args)
|
656 |
+
historyDeleteBtn.click(delete_chat_history, [current_model, historySelectList, user_name], [status_display, historySelectList, chatbot], _js='(a,b,c)=>{return showConfirmationDialog(a, b, c);}').then(
|
657 |
+
reset,
|
658 |
+
inputs=[current_model],
|
659 |
+
outputs=[chatbot, status_display, historySelectList],
|
660 |
+
show_progress=True,
|
661 |
+
_js='clearChatbot',
|
662 |
+
)
|
663 |
historySelectList.input(**load_history_from_file_args)
|
664 |
+
downloadFile.change(upload_chat_history, [current_model, downloadFile, user_name], [
|
665 |
+
saveFileName, systemPromptTxt, chatbot])
|
666 |
+
historyDownloadBtn.click(None, [
|
667 |
+
user_name, historySelectList], None, _js='(a,b)=>{return downloadHistory(a,b);}')
|
668 |
historySearchTextbox.input(
|
669 |
filter_history,
|
670 |
[user_name, historySearchTextbox],
|
|
|
672 |
)
|
673 |
|
674 |
# Train
|
675 |
+
dataset_selection.upload(handle_dataset_selection, dataset_selection, [
|
676 |
+
dataset_preview_json, upload_to_openai_btn, openai_train_status])
|
677 |
+
dataset_selection.clear(handle_dataset_clear, [], [
|
678 |
+
dataset_preview_json, upload_to_openai_btn])
|
679 |
+
upload_to_openai_btn.click(upload_to_openai, [dataset_selection], [
|
680 |
+
openai_ft_file_id, openai_train_status], show_progress=True)
|
681 |
+
|
682 |
+
openai_ft_file_id.change(lambda x: gr.update(interactive=True) if len(
|
683 |
+
x) > 0 else gr.update(interactive=False), [openai_ft_file_id], [openai_start_train_btn])
|
684 |
+
openai_start_train_btn.click(start_training, [
|
685 |
+
openai_ft_file_id, openai_ft_suffix, openai_train_epoch_slider], [openai_train_status])
|
686 |
+
|
687 |
+
openai_status_refresh_btn.click(get_training_status, [], [
|
688 |
+
openai_train_status, add_to_models_btn])
|
689 |
+
add_to_models_btn.click(add_to_models, [], [
|
690 |
+
model_select_dropdown, openai_train_status], show_progress=True)
|
691 |
+
openai_cancel_all_jobs_btn.click(
|
692 |
+
cancel_all_jobs, [], [openai_train_status], show_progress=True)
|
693 |
|
694 |
# Advanced
|
695 |
+
max_context_length_slider.change(
|
696 |
+
set_token_upper_limit, [current_model, max_context_length_slider], None)
|
697 |
+
temperature_slider.change(
|
698 |
+
set_temperature, [current_model, temperature_slider], None)
|
699 |
top_p_slider.change(set_top_p, [current_model, top_p_slider], None)
|
700 |
+
n_choices_slider.change(
|
701 |
+
set_n_choices, [current_model, n_choices_slider], None)
|
702 |
+
stop_sequence_txt.change(
|
703 |
+
set_stop_sequence, [current_model, stop_sequence_txt], None)
|
704 |
+
max_generation_slider.change(
|
705 |
+
set_max_tokens, [current_model, max_generation_slider], None)
|
706 |
+
presence_penalty_slider.change(
|
707 |
+
set_presence_penalty, [current_model, presence_penalty_slider], None)
|
708 |
+
frequency_penalty_slider.change(
|
709 |
+
set_frequency_penalty, [current_model, frequency_penalty_slider], None)
|
710 |
+
logit_bias_txt.change(
|
711 |
+
set_logit_bias, [current_model, logit_bias_txt], None)
|
712 |
+
user_identifier_txt.change(set_user_identifier, [
|
713 |
+
current_model, user_identifier_txt], None)
|
714 |
|
715 |
default_btn.click(
|
716 |
reset_default, [], [apihostTxt, proxyTxt, status_display], show_progress=True
|
|
|
748 |
outputs=[use_websearch_checkbox],
|
749 |
_js='(a)=>{return bgChangeOnlineSearch(a);}'
|
750 |
)
|
751 |
+
historySelectBtn.click( # This is an experimental feature... Not actually used.
|
752 |
fn=load_chat_history,
|
753 |
inputs=[current_model, historySelectList],
|
754 |
outputs=[saveFileName, systemPromptTxt, chatbot],
|
|
|
756 |
)
|
757 |
|
758 |
|
|
|
759 |
logging.info(
|
760 |
colorama.Back.GREEN
|
761 |
+ "\n川虎的温馨提示:访问 http://localhost:7860 查看界面"
|
|
|
773 |
share=share,
|
774 |
auth=auth_from_conf if authflag else None,
|
775 |
favicon_path="./web_assets/favicon.ico",
|
776 |
+
inbrowser=not dockerflag, # 禁止在docker下开启inbrowser
|
777 |
)
|
modules/models/base_model.py
CHANGED
@@ -735,7 +735,7 @@ class BaseLLMModel:
|
|
735 |
return i18n("删除对话历史成功"), get_history_list(user_name), []
|
736 |
except:
|
737 |
logging.info(f"删除对话历史失败 {history_file_path}")
|
738 |
-
return i18n("对话历史")+filename+i18n("已经被删除啦"),
|
739 |
|
740 |
def auto_load(self):
|
741 |
self.history_file_path = get_history_filepath(self.user_identifier)
|
|
|
735 |
return i18n("删除对话历史成功"), get_history_list(user_name), []
|
736 |
except:
|
737 |
logging.info(f"删除对话历史失败 {history_file_path}")
|
738 |
+
return i18n("对话历史")+filename+i18n("已经被删除啦"), get_history_list(user_name), []
|
739 |
|
740 |
def auto_load(self):
|
741 |
self.history_file_path = get_history_filepath(self.user_identifier)
|