Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
6848520
1
Parent(s):
bedaaff
WIP: new ui
Browse files- ChuanhuChatbot.py +226 -205
- web_assets/html/func_nav.html +11 -0
- web_assets/html/header_title.html +22 -0
- web_assets/javascript/ChuanhuChat.js +22 -0
- web_assets/javascript/webui.js +78 -0
- web_assets/stylesheet/ChuanhuChat.css +54 -0
ChuanhuChatbot.py
CHANGED
|
@@ -39,8 +39,8 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 39 |
|
| 40 |
topic = gr.State(i18n("未命名对话历史记录"))
|
| 41 |
|
| 42 |
-
with gr.Row():
|
| 43 |
-
gr.HTML(CHUANHU_TITLE, elem_id="app-title")
|
| 44 |
status_display = gr.Markdown(get_geoip(), elem_id="status-display")
|
| 45 |
with gr.Row(elem_id="float-display"):
|
| 46 |
user_info = gr.Markdown(value="getting user info...", elem_id="user-info")
|
|
@@ -54,8 +54,48 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 54 |
ok_btn=i18n("好"),
|
| 55 |
), visible=check_update)
|
| 56 |
|
| 57 |
-
with gr.Row(equal_height=True):
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
with gr.Row():
|
| 60 |
chatbot = gr.Chatbot(label="Chuanhu Chat", elem_id="chuanhu-chatbot", latex_delimiters=latex_delimiters_set, height=700)
|
| 61 |
with gr.Row():
|
|
@@ -85,43 +125,10 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 85 |
with gr.Column(min_width=20, scale=1):
|
| 86 |
dislikeBtn = gr.Button(i18n("👎"))
|
| 87 |
|
| 88 |
-
with gr.Column():
|
| 89 |
with gr.Column(min_width=50, scale=1):
|
| 90 |
-
with gr.Tab(label=i18n("模型")):
|
| 91 |
-
keyTxt = gr.Textbox(
|
| 92 |
-
show_label=True,
|
| 93 |
-
placeholder=f"Your API-key...",
|
| 94 |
-
value=hide_middle_chars(user_api_key.value),
|
| 95 |
-
type="password",
|
| 96 |
-
visible=not HIDE_MY_KEY,
|
| 97 |
-
label="API-Key",
|
| 98 |
-
)
|
| 99 |
-
if multi_api_key:
|
| 100 |
-
usageTxt = gr.Markdown(i18n("多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
| 101 |
-
else:
|
| 102 |
-
usageTxt = gr.Markdown(i18n("**发送消息** 或 **提交key** 以显示额度"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
| 103 |
-
model_select_dropdown = gr.Dropdown(
|
| 104 |
-
label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
|
| 105 |
-
)
|
| 106 |
-
lora_select_dropdown = gr.Dropdown(
|
| 107 |
-
label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
|
| 108 |
-
)
|
| 109 |
-
with gr.Row():
|
| 110 |
-
single_turn_checkbox = gr.Checkbox(label=i18n("单轮对话"), value=False, elem_classes="switch-checkbox")
|
| 111 |
-
use_websearch_checkbox = gr.Checkbox(label=i18n("使用在线搜索"), value=False, elem_classes="switch-checkbox")
|
| 112 |
-
language_select_dropdown = gr.Dropdown(
|
| 113 |
-
label=i18n("选择回复语言(针对搜索&索引功能)"),
|
| 114 |
-
choices=REPLY_LANGUAGES,
|
| 115 |
-
multiselect=False,
|
| 116 |
-
value=REPLY_LANGUAGES[0],
|
| 117 |
-
)
|
| 118 |
-
index_files = gr.Files(label=i18n("上传"), type="file", elem_id="upload-index-file")
|
| 119 |
-
two_column = gr.Checkbox(label=i18n("双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
|
| 120 |
-
summarize_btn = gr.Button(i18n("总结"))
|
| 121 |
-
# TODO: 公式ocr
|
| 122 |
-
# formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
|
| 123 |
|
| 124 |
-
with gr.
|
| 125 |
systemPromptTxt = gr.Textbox(
|
| 126 |
show_label=True,
|
| 127 |
placeholder=i18n("在这里输入System Prompt..."),
|
|
@@ -153,174 +160,182 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 153 |
container=False,
|
| 154 |
)
|
| 155 |
|
| 156 |
-
|
| 157 |
-
with gr.Accordion(label=i18n("保存/加载对话历史记录"), open=True):
|
| 158 |
-
with gr.Column():
|
| 159 |
-
with gr.Row():
|
| 160 |
-
with gr.Column(scale=6):
|
| 161 |
-
historyFileSelectDropdown = gr.Dropdown(
|
| 162 |
-
label=i18n("从列表中加载对话"),
|
| 163 |
-
choices=get_history_names(plain=True),
|
| 164 |
-
multiselect=False,
|
| 165 |
-
container=False,
|
| 166 |
-
)
|
| 167 |
-
with gr.Row():
|
| 168 |
-
with gr.Column(min_width=42, scale=1):
|
| 169 |
-
historyRefreshBtn = gr.Button(i18n("🔄 刷新"))
|
| 170 |
-
with gr.Column(min_width=42, scale=1):
|
| 171 |
-
historyDeleteBtn = gr.Button(i18n("🗑️ 删除"))
|
| 172 |
-
with gr.Row():
|
| 173 |
-
with gr.Column(scale=6):
|
| 174 |
-
saveFileName = gr.Textbox(
|
| 175 |
-
show_label=True,
|
| 176 |
-
placeholder=i18n("设置文件名: 默认为.json,可选为.md"),
|
| 177 |
-
label=i18n("设置保存文件名"),
|
| 178 |
-
value=i18n("对话历史记录"),
|
| 179 |
-
elem_classes="no-container"
|
| 180 |
-
# container=False,
|
| 181 |
-
)
|
| 182 |
-
with gr.Column(scale=1):
|
| 183 |
-
saveHistoryBtn = gr.Button(i18n("💾 保存对话"))
|
| 184 |
-
exportMarkdownBtn = gr.Button(i18n("📝 导出为Markdown"))
|
| 185 |
-
gr.Markdown(i18n("默认保存于history文件夹"))
|
| 186 |
-
with gr.Row():
|
| 187 |
-
with gr.Column():
|
| 188 |
-
downloadFile = gr.File(interactive=True)
|
| 189 |
-
|
| 190 |
-
with gr.Tab(label=i18n("微调")):
|
| 191 |
-
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)"))
|
| 192 |
-
|
| 193 |
-
with gr.Tab(label=i18n("准备数据集")):
|
| 194 |
-
dataset_preview_json = gr.JSON(label=i18n("数据集预览"), readonly=True)
|
| 195 |
-
dataset_selection = gr.Files(label = i18n("选择数据集"), file_types=[".xlsx", ".jsonl"], file_count="single")
|
| 196 |
-
upload_to_openai_btn = gr.Button(i18n("上传到OpenAI"), variant="primary", interactive=False)
|
| 197 |
-
|
| 198 |
-
with gr.Tab(label=i18n("训练")):
|
| 199 |
-
openai_ft_file_id = gr.Textbox(label=i18n("文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动填充"))
|
| 200 |
-
openai_ft_suffix = gr.Textbox(label=i18n("模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
|
| 201 |
-
openai_train_epoch_slider = gr.Slider(label=i18n("训练轮数(Epochs)"), minimum=1, maximum=100, value=3, step=1, interactive=True)
|
| 202 |
-
openai_start_train_btn = gr.Button(i18n("开始训练"), variant="primary", interactive=False)
|
| 203 |
-
|
| 204 |
-
with gr.Tab(label=i18n("状态")):
|
| 205 |
-
openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
|
| 206 |
-
openai_cancel_all_jobs_btn = gr.Button(i18n("取消所有任务"))
|
| 207 |
-
add_to_models_btn = gr.Button(i18n("添加训练好的模型到模型列表"), interactive=False)
|
| 208 |
-
|
| 209 |
-
with gr.Tab(label=i18n("高级")):
|
| 210 |
-
gr.HTML(get_html("appearance_switcher.html").format(label=i18n("切换亮暗色主题")), elem_classes="insert-block")
|
| 211 |
-
use_streaming_checkbox = gr.Checkbox(
|
| 212 |
-
label=i18n("实时传输回答"), value=True, visible=ENABLE_STREAMING_OPTION, elem_classes="switch-checkbox"
|
| 213 |
-
)
|
| 214 |
-
checkUpdateBtn = gr.Button(i18n("🔄 检查更新..."), visible=check_update)
|
| 215 |
-
gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️"), elem_id="advanced-warning")
|
| 216 |
-
with gr.Accordion(i18n("参数"), open=False):
|
| 217 |
-
temperature_slider = gr.Slider(
|
| 218 |
-
minimum=-0,
|
| 219 |
-
maximum=2.0,
|
| 220 |
-
value=1.0,
|
| 221 |
-
step=0.1,
|
| 222 |
-
interactive=True,
|
| 223 |
-
label="temperature",
|
| 224 |
-
)
|
| 225 |
-
top_p_slider = gr.Slider(
|
| 226 |
-
minimum=-0,
|
| 227 |
-
maximum=1.0,
|
| 228 |
-
value=1.0,
|
| 229 |
-
step=0.05,
|
| 230 |
-
interactive=True,
|
| 231 |
-
label="top-p",
|
| 232 |
-
)
|
| 233 |
-
n_choices_slider = gr.Slider(
|
| 234 |
-
minimum=1,
|
| 235 |
-
maximum=10,
|
| 236 |
-
value=1,
|
| 237 |
-
step=1,
|
| 238 |
-
interactive=True,
|
| 239 |
-
label="n choices",
|
| 240 |
-
)
|
| 241 |
-
stop_sequence_txt = gr.Textbox(
|
| 242 |
-
show_label=True,
|
| 243 |
-
placeholder=i18n("停止符,用英文逗号隔开..."),
|
| 244 |
-
label="stop",
|
| 245 |
-
value="",
|
| 246 |
-
lines=1,
|
| 247 |
-
)
|
| 248 |
-
max_context_length_slider = gr.Slider(
|
| 249 |
-
minimum=1,
|
| 250 |
-
maximum=32768,
|
| 251 |
-
value=2000,
|
| 252 |
-
step=1,
|
| 253 |
-
interactive=True,
|
| 254 |
-
label="max context",
|
| 255 |
-
)
|
| 256 |
-
max_generation_slider = gr.Slider(
|
| 257 |
-
minimum=1,
|
| 258 |
-
maximum=32768,
|
| 259 |
-
value=1000,
|
| 260 |
-
step=1,
|
| 261 |
-
interactive=True,
|
| 262 |
-
label="max generations",
|
| 263 |
-
)
|
| 264 |
-
presence_penalty_slider = gr.Slider(
|
| 265 |
-
minimum=-2.0,
|
| 266 |
-
maximum=2.0,
|
| 267 |
-
value=0.0,
|
| 268 |
-
step=0.01,
|
| 269 |
-
interactive=True,
|
| 270 |
-
label="presence penalty",
|
| 271 |
-
)
|
| 272 |
-
frequency_penalty_slider = gr.Slider(
|
| 273 |
-
minimum=-2.0,
|
| 274 |
-
maximum=2.0,
|
| 275 |
-
value=0.0,
|
| 276 |
-
step=0.01,
|
| 277 |
-
interactive=True,
|
| 278 |
-
label="frequency penalty",
|
| 279 |
-
)
|
| 280 |
-
logit_bias_txt = gr.Textbox(
|
| 281 |
-
show_label=True,
|
| 282 |
-
placeholder=f"word:likelihood",
|
| 283 |
-
label="logit bias",
|
| 284 |
-
value="",
|
| 285 |
-
lines=1,
|
| 286 |
-
)
|
| 287 |
-
user_identifier_txt = gr.Textbox(
|
| 288 |
-
show_label=True,
|
| 289 |
-
placeholder=i18n("用于定位滥用行为"),
|
| 290 |
-
label=i18n("用户名"),
|
| 291 |
-
value=user_name.value,
|
| 292 |
-
lines=1,
|
| 293 |
-
)
|
| 294 |
-
|
| 295 |
-
with gr.Accordion(i18n("网络参数"), open=False):
|
| 296 |
-
gr.Markdown(i18n("---\n⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置"), elem_id="netsetting-warning")
|
| 297 |
-
default_btn = gr.Button(i18n("🔙 恢复默认网络设置"))
|
| 298 |
-
# 网络代理
|
| 299 |
-
proxyTxt = gr.Textbox(
|
| 300 |
-
show_label=True,
|
| 301 |
-
placeholder=i18n("未设置代理..."),
|
| 302 |
-
label=i18n("代理地址"),
|
| 303 |
-
value=config.http_proxy,
|
| 304 |
-
lines=1,
|
| 305 |
-
interactive=False,
|
| 306 |
-
# container=False,
|
| 307 |
-
elem_classes="view-only-textbox no-container",
|
| 308 |
-
)
|
| 309 |
-
# changeProxyBtn = gr.Button(i18n("🔄 设置代理地址"))
|
| 310 |
-
|
| 311 |
-
# 优先展示自定义的api_host
|
| 312 |
-
apihostTxt = gr.Textbox(
|
| 313 |
-
show_label=True,
|
| 314 |
-
placeholder="api.openai.com",
|
| 315 |
-
label="OpenAI API-Host",
|
| 316 |
-
value=config.api_host or shared.API_HOST,
|
| 317 |
-
lines=1,
|
| 318 |
-
interactive=False,
|
| 319 |
-
# container=False,
|
| 320 |
-
elem_classes="view-only-textbox no-container",
|
| 321 |
-
)
|
| 322 |
# changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
|
| 323 |
updateChuanhuBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
|
| 325 |
|
| 326 |
gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
|
|
@@ -542,6 +557,12 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 542 |
[status_display],
|
| 543 |
show_progress=True,
|
| 544 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 545 |
|
| 546 |
logging.info(
|
| 547 |
colorama.Back.GREEN
|
|
|
|
| 39 |
|
| 40 |
topic = gr.State(i18n("未命名对话历史记录"))
|
| 41 |
|
| 42 |
+
with gr.Row(elem_id="chuanhu-header"):
|
| 43 |
+
gr.HTML(get_html("header_title.html").format(app_title=CHUANHU_TITLE), elem_id="app-title")
|
| 44 |
status_display = gr.Markdown(get_geoip(), elem_id="status-display")
|
| 45 |
with gr.Row(elem_id="float-display"):
|
| 46 |
user_info = gr.Markdown(value="getting user info...", elem_id="user-info")
|
|
|
|
| 54 |
ok_btn=i18n("好"),
|
| 55 |
), visible=check_update)
|
| 56 |
|
| 57 |
+
with gr.Row(equal_height=True, elem_id="chuanhu-body"):
|
| 58 |
+
|
| 59 |
+
with gr.Column(elem_id="menu-area"):
|
| 60 |
+
with gr.Row(elem_id="chuanhu-history"):
|
| 61 |
+
with gr.Accordion(label=i18n("保存/加载对话历史记录"), open=True):
|
| 62 |
+
with gr.Column():
|
| 63 |
+
with gr.Row():
|
| 64 |
+
with gr.Column(scale=6, elem_id="history-select-wrap"):
|
| 65 |
+
historyFileSelectDropdown = gr.Radio(
|
| 66 |
+
label=i18n("从列表中加载对话"),
|
| 67 |
+
choices=get_history_names(plain=True),
|
| 68 |
+
multiselect=False,
|
| 69 |
+
container=False,
|
| 70 |
+
elem_id="history-select-dropdown"
|
| 71 |
+
)
|
| 72 |
+
with gr.Row():
|
| 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(i18n("🗑️ 删除"))
|
| 77 |
+
with gr.Row():
|
| 78 |
+
with gr.Column(scale=6):
|
| 79 |
+
saveFileName = gr.Textbox(
|
| 80 |
+
show_label=True,
|
| 81 |
+
placeholder=i18n("设置文件名: 默认为.json,可选为.md"),
|
| 82 |
+
label=i18n("设置保存文件名"),
|
| 83 |
+
value=i18n("对话历史记录"),
|
| 84 |
+
elem_classes="no-container"
|
| 85 |
+
# container=False,
|
| 86 |
+
)
|
| 87 |
+
with gr.Column(scale=1):
|
| 88 |
+
saveHistoryBtn = gr.Button(i18n("💾 保存对话"))
|
| 89 |
+
exportMarkdownBtn = gr.Button(i18n("📝 导出为Markdown"))
|
| 90 |
+
gr.Markdown(i18n("默认保存于history文件夹"))
|
| 91 |
+
with gr.Row():
|
| 92 |
+
with gr.Column():
|
| 93 |
+
downloadFile = gr.File(interactive=True)
|
| 94 |
+
|
| 95 |
+
with gr.Row(elem_id="chuanhu-func-nav"):
|
| 96 |
+
gr.HTML(get_html("func_nav.html"))
|
| 97 |
+
|
| 98 |
+
with gr.Column(scale=5, elem_id="chatbot-area"):
|
| 99 |
with gr.Row():
|
| 100 |
chatbot = gr.Chatbot(label="Chuanhu Chat", elem_id="chuanhu-chatbot", latex_delimiters=latex_delimiters_set, height=700)
|
| 101 |
with gr.Row():
|
|
|
|
| 125 |
with gr.Column(min_width=20, scale=1):
|
| 126 |
dislikeBtn = gr.Button(i18n("👎"))
|
| 127 |
|
| 128 |
+
with gr.Column(elem_id="toolbox-area"):
|
| 129 |
with gr.Column(min_width=50, scale=1):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
+
with gr.Accordion(label="Prompt", open=True):
|
| 132 |
systemPromptTxt = gr.Textbox(
|
| 133 |
show_label=True,
|
| 134 |
placeholder=i18n("在这里输入System Prompt..."),
|
|
|
|
| 160 |
container=False,
|
| 161 |
)
|
| 162 |
|
| 163 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
# changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
|
| 165 |
updateChuanhuBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
|
| 166 |
+
historySelectBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="history-select-btn")
|
| 167 |
+
|
| 168 |
+
with gr.Box(elem_id="chuanhu-popup"):
|
| 169 |
+
with gr.Box(elem_id="chuanhu-setting"):
|
| 170 |
+
gr.Markdown("## Setting")
|
| 171 |
+
with gr.Tab(label=i18n("模型")):
|
| 172 |
+
keyTxt = gr.Textbox(
|
| 173 |
+
show_label=True,
|
| 174 |
+
placeholder=f"Your API-key...",
|
| 175 |
+
value=hide_middle_chars(user_api_key.value),
|
| 176 |
+
type="password",
|
| 177 |
+
visible=not HIDE_MY_KEY,
|
| 178 |
+
label="API-Key",
|
| 179 |
+
)
|
| 180 |
+
if multi_api_key:
|
| 181 |
+
usageTxt = gr.Markdown(i18n("多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
| 182 |
+
else:
|
| 183 |
+
usageTxt = gr.Markdown(i18n("**发送消息** 或 **提交key** 以显示额度"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
| 184 |
+
model_select_dropdown = gr.Dropdown(
|
| 185 |
+
label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
|
| 186 |
+
)
|
| 187 |
+
lora_select_dropdown = gr.Dropdown(
|
| 188 |
+
label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
|
| 189 |
+
)
|
| 190 |
+
with gr.Row():
|
| 191 |
+
single_turn_checkbox = gr.Checkbox(label=i18n("单轮对话"), value=False, elem_classes="switch-checkbox")
|
| 192 |
+
use_websearch_checkbox = gr.Checkbox(label=i18n("使用在线搜索"), value=False, elem_classes="switch-checkbox")
|
| 193 |
+
language_select_dropdown = gr.Dropdown(
|
| 194 |
+
label=i18n("选择回复语言(针对搜索&索引功能)"),
|
| 195 |
+
choices=REPLY_LANGUAGES,
|
| 196 |
+
multiselect=False,
|
| 197 |
+
value=REPLY_LANGUAGES[0],
|
| 198 |
+
)
|
| 199 |
+
index_files = gr.Files(label=i18n("上传"), type="file", elem_id="upload-index-file")
|
| 200 |
+
two_column = gr.Checkbox(label=i18n("双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
|
| 201 |
+
summarize_btn = gr.Button(i18n("总结"))
|
| 202 |
+
# TODO: 公式ocr
|
| 203 |
+
# formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
|
| 204 |
+
|
| 205 |
+
with gr.Tab(label=i18n("高级")):
|
| 206 |
+
gr.HTML(get_html("appearance_switcher.html").format(label=i18n("切换亮暗色主题")), elem_classes="insert-block")
|
| 207 |
+
use_streaming_checkbox = gr.Checkbox(
|
| 208 |
+
label=i18n("实时传输回答"), value=True, visible=ENABLE_STREAMING_OPTION, elem_classes="switch-checkbox"
|
| 209 |
+
)
|
| 210 |
+
checkUpdateBtn = gr.Button(i18n("🔄 检查更新..."), visible=check_update)
|
| 211 |
+
gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️"), elem_id="advanced-warning")
|
| 212 |
+
with gr.Accordion(i18n("参数"), open=False):
|
| 213 |
+
temperature_slider = gr.Slider(
|
| 214 |
+
minimum=-0,
|
| 215 |
+
maximum=2.0,
|
| 216 |
+
value=1.0,
|
| 217 |
+
step=0.1,
|
| 218 |
+
interactive=True,
|
| 219 |
+
label="temperature",
|
| 220 |
+
)
|
| 221 |
+
top_p_slider = gr.Slider(
|
| 222 |
+
minimum=-0,
|
| 223 |
+
maximum=1.0,
|
| 224 |
+
value=1.0,
|
| 225 |
+
step=0.05,
|
| 226 |
+
interactive=True,
|
| 227 |
+
label="top-p",
|
| 228 |
+
)
|
| 229 |
+
n_choices_slider = gr.Slider(
|
| 230 |
+
minimum=1,
|
| 231 |
+
maximum=10,
|
| 232 |
+
value=1,
|
| 233 |
+
step=1,
|
| 234 |
+
interactive=True,
|
| 235 |
+
label="n choices",
|
| 236 |
+
)
|
| 237 |
+
stop_sequence_txt = gr.Textbox(
|
| 238 |
+
show_label=True,
|
| 239 |
+
placeholder=i18n("停止符,用英文逗号隔开..."),
|
| 240 |
+
label="stop",
|
| 241 |
+
value="",
|
| 242 |
+
lines=1,
|
| 243 |
+
)
|
| 244 |
+
max_context_length_slider = gr.Slider(
|
| 245 |
+
minimum=1,
|
| 246 |
+
maximum=32768,
|
| 247 |
+
value=2000,
|
| 248 |
+
step=1,
|
| 249 |
+
interactive=True,
|
| 250 |
+
label="max context",
|
| 251 |
+
)
|
| 252 |
+
max_generation_slider = gr.Slider(
|
| 253 |
+
minimum=1,
|
| 254 |
+
maximum=32768,
|
| 255 |
+
value=1000,
|
| 256 |
+
step=1,
|
| 257 |
+
interactive=True,
|
| 258 |
+
label="max generations",
|
| 259 |
+
)
|
| 260 |
+
presence_penalty_slider = gr.Slider(
|
| 261 |
+
minimum=-2.0,
|
| 262 |
+
maximum=2.0,
|
| 263 |
+
value=0.0,
|
| 264 |
+
step=0.01,
|
| 265 |
+
interactive=True,
|
| 266 |
+
label="presence penalty",
|
| 267 |
+
)
|
| 268 |
+
frequency_penalty_slider = gr.Slider(
|
| 269 |
+
minimum=-2.0,
|
| 270 |
+
maximum=2.0,
|
| 271 |
+
value=0.0,
|
| 272 |
+
step=0.01,
|
| 273 |
+
interactive=True,
|
| 274 |
+
label="frequency penalty",
|
| 275 |
+
)
|
| 276 |
+
logit_bias_txt = gr.Textbox(
|
| 277 |
+
show_label=True,
|
| 278 |
+
placeholder=f"word:likelihood",
|
| 279 |
+
label="logit bias",
|
| 280 |
+
value="",
|
| 281 |
+
lines=1,
|
| 282 |
+
)
|
| 283 |
+
user_identifier_txt = gr.Textbox(
|
| 284 |
+
show_label=True,
|
| 285 |
+
placeholder=i18n("用于定位滥用行为"),
|
| 286 |
+
label=i18n("用户名"),
|
| 287 |
+
value=user_name.value,
|
| 288 |
+
lines=1,
|
| 289 |
+
)
|
| 290 |
+
|
| 291 |
+
with gr.Accordion(i18n("网络参数"), open=False):
|
| 292 |
+
gr.Markdown(i18n("---\n⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置"), elem_id="netsetting-warning")
|
| 293 |
+
default_btn = gr.Button(i18n("🔙 恢复默认网络设置"))
|
| 294 |
+
# 网络代理
|
| 295 |
+
proxyTxt = gr.Textbox(
|
| 296 |
+
show_label=True,
|
| 297 |
+
placeholder=i18n("未设置代理..."),
|
| 298 |
+
label=i18n("代理地址"),
|
| 299 |
+
value=config.http_proxy,
|
| 300 |
+
lines=1,
|
| 301 |
+
interactive=False,
|
| 302 |
+
# container=False,
|
| 303 |
+
elem_classes="view-only-textbox no-container",
|
| 304 |
+
)
|
| 305 |
+
# changeProxyBtn = gr.Button(i18n("🔄 设置代理地址"))
|
| 306 |
+
|
| 307 |
+
# 优先展示自定义的api_host
|
| 308 |
+
apihostTxt = gr.Textbox(
|
| 309 |
+
show_label=True,
|
| 310 |
+
placeholder="api.openai.com",
|
| 311 |
+
label="OpenAI API-Host",
|
| 312 |
+
value=config.api_host or shared.API_HOST,
|
| 313 |
+
lines=1,
|
| 314 |
+
interactive=False,
|
| 315 |
+
# container=False,
|
| 316 |
+
elem_classes="view-only-textbox no-container",
|
| 317 |
+
)
|
| 318 |
+
|
| 319 |
+
with gr.Box(elem_id="chuanhu-training"):
|
| 320 |
+
gr.Markdown("## Training")
|
| 321 |
+
with gr.Tab(label=i18n("微调")):
|
| 322 |
+
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)"))
|
| 323 |
+
|
| 324 |
+
with gr.Tab(label=i18n("准备数据集")):
|
| 325 |
+
dataset_preview_json = gr.JSON(label=i18n("数据集预览"), readonly=True)
|
| 326 |
+
dataset_selection = gr.Files(label = i18n("选择数据集"), file_types=[".xlsx", ".jsonl"], file_count="single")
|
| 327 |
+
upload_to_openai_btn = gr.Button(i18n("上传到OpenAI"), variant="primary", interactive=False)
|
| 328 |
+
|
| 329 |
+
with gr.Tab(label=i18n("训练")):
|
| 330 |
+
openai_ft_file_id = gr.Textbox(label=i18n("文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动填充"))
|
| 331 |
+
openai_ft_suffix = gr.Textbox(label=i18n("模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
|
| 332 |
+
openai_train_epoch_slider = gr.Slider(label=i18n("训练轮数(Epochs)"), minimum=1, maximum=100, value=3, step=1, interactive=True)
|
| 333 |
+
openai_start_train_btn = gr.Button(i18n("开始训练"), variant="primary", interactive=False)
|
| 334 |
+
|
| 335 |
+
with gr.Tab(label=i18n("状态")):
|
| 336 |
+
openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
|
| 337 |
+
openai_cancel_all_jobs_btn = gr.Button(i18n("取消所有任务"))
|
| 338 |
+
add_to_models_btn = gr.Button(i18n("添加训练好的模型到模型列表"), interactive=False)
|
| 339 |
|
| 340 |
|
| 341 |
gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
|
|
|
|
| 557 |
[status_display],
|
| 558 |
show_progress=True,
|
| 559 |
)
|
| 560 |
+
historySelectBtn.click(
|
| 561 |
+
fn=load_chat_history,
|
| 562 |
+
inputs=[current_model, historyFileSelectDropdown, user_name],
|
| 563 |
+
outputs=[saveFileName, systemPromptTxt, chatbot],
|
| 564 |
+
_js='(a,b,c)=>{return bgSelectHistory(a,b,c);}'
|
| 565 |
+
)
|
| 566 |
|
| 567 |
logging.info(
|
| 568 |
colorama.Back.GREEN
|
web_assets/html/func_nav.html
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<button id="chuanhu-setting-btn" onclick="openSettingBox()" style="width: 60px; height: 60px;">
|
| 2 |
+
setting(暂无图标)
|
| 3 |
+
</button>
|
| 4 |
+
|
| 5 |
+
<button id="chuanhu-training-btn" onclick="openTrainingBox()" style="width: 60px; height: 60px;">
|
| 6 |
+
training(暂无图标)
|
| 7 |
+
</button>
|
| 8 |
+
|
| 9 |
+
<button id="" onclick="" style="width: 60px; height: 60px;">
|
| 10 |
+
darklight switch(暂无图标)
|
| 11 |
+
</button>
|
web_assets/html/header_title.html
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div class="gb_hd gb_7c gb_8c"
|
| 2 |
+
style="display:inline-flex;">
|
| 3 |
+
<buttom id="chuanhu-menu-btn" onclick='menuClick()' class="gb_Ec" aria-expanded="false" aria-label="Main menu" role="button" tabindex="0"
|
| 4 |
+
style="visibility: visible; width:32px; height:32px; margin-right:5px;"><svg focusable="false" viewBox="0 0 24 24">
|
| 5 |
+
<path d="M3 18h18v-2H3v2zm0-5h18v-2H3v2zm0-7v2h18V6H3z"></path>
|
| 6 |
+
</svg>
|
| 7 |
+
</div>
|
| 8 |
+
<!-- <buttom class="gb_Ec gb_Ic gb_p" aria-label="Go back" title="Go back" role="button" tabindex="0">
|
| 9 |
+
<svg focusable="false" viewBox="0 0 24 24"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"></path>
|
| 10 |
+
</svg>
|
| 11 |
+
</buttom>
|
| 12 |
+
<div class="gb_Ec gb_Jc gb_p" aria-label="Close" role="button" tabindex="0"><svg viewBox="0 0 24 24">
|
| 13 |
+
<path
|
| 14 |
+
d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z">
|
| 15 |
+
</path>
|
| 16 |
+
</svg></div> -->
|
| 17 |
+
<div class="gb_xc">
|
| 18 |
+
<div class="gb_yc">{app_title}
|
| 19 |
+
</div>
|
| 20 |
+
</div>
|
| 21 |
+
<div class="gb_hd gb_p gb_5c gb_6c"><span class="gb_9c" aria-level="1" role="heading"></span></div>
|
| 22 |
+
</div>
|
web_assets/javascript/ChuanhuChat.js
CHANGED
|
@@ -25,6 +25,11 @@ var sliders = null;
|
|
| 25 |
var updateChuanhuBtn = null;
|
| 26 |
var statusDisplay = null;
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
var isInIframe = (window.self !== window.top);
|
| 29 |
var currentTime = new Date().getTime();
|
| 30 |
var initialized = false;
|
|
@@ -62,6 +67,12 @@ function initialize() {
|
|
| 62 |
updateChuanhuBtn = gradioApp().getElementById("update-chuanhu-btn");
|
| 63 |
statusDisplay = gradioApp().querySelector('#status-display');
|
| 64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 65 |
if (loginUserForm) {
|
| 66 |
localStorage.setItem("userLogged", true);
|
| 67 |
userLogged = true;
|
|
@@ -91,6 +102,10 @@ function initialize() {
|
|
| 91 |
if (longTimeNoCheck && !updateInfoGotten && !isLatestVersion || isLatestVersion && !updateInfoGotten) {
|
| 92 |
updateLatestVersion();
|
| 93 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
}
|
| 95 |
}
|
| 96 |
|
|
@@ -194,6 +209,13 @@ function adjustDarkMode() {
|
|
| 194 |
});
|
| 195 |
}
|
| 196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 197 |
function setChatbotHeight() {
|
| 198 |
const screenWidth = window.innerWidth;
|
| 199 |
const statusDisplay = document.querySelector('#status-display');
|
|
|
|
| 25 |
var updateChuanhuBtn = null;
|
| 26 |
var statusDisplay = null;
|
| 27 |
|
| 28 |
+
var historySelector = null;
|
| 29 |
+
var chuanhuPopup = null;
|
| 30 |
+
var settingBox = null;
|
| 31 |
+
var trainingBox = null;
|
| 32 |
+
|
| 33 |
var isInIframe = (window.self !== window.top);
|
| 34 |
var currentTime = new Date().getTime();
|
| 35 |
var initialized = false;
|
|
|
|
| 67 |
updateChuanhuBtn = gradioApp().getElementById("update-chuanhu-btn");
|
| 68 |
statusDisplay = gradioApp().querySelector('#status-display');
|
| 69 |
|
| 70 |
+
historySelector = gradioApp().querySelector('#history-select-dropdown');
|
| 71 |
+
chuanhuPopup = gradioApp().querySelector('#chuanhu-popup');
|
| 72 |
+
settingBox = gradioApp().querySelector('#chuanhu-setting');
|
| 73 |
+
trainingBox = gradioApp().querySelector('#chuanhu-training');
|
| 74 |
+
|
| 75 |
+
|
| 76 |
if (loginUserForm) {
|
| 77 |
localStorage.setItem("userLogged", true);
|
| 78 |
userLogged = true;
|
|
|
|
| 102 |
if (longTimeNoCheck && !updateInfoGotten && !isLatestVersion || isLatestVersion && !updateInfoGotten) {
|
| 103 |
updateLatestVersion();
|
| 104 |
}
|
| 105 |
+
|
| 106 |
+
// setHistroyPanel();
|
| 107 |
+
settingBox.classList.add('hideBox');
|
| 108 |
+
trainingBox.classList.add('hideBox');
|
| 109 |
}
|
| 110 |
}
|
| 111 |
|
|
|
|
| 209 |
});
|
| 210 |
}
|
| 211 |
|
| 212 |
+
function setChatAreaWidth() {
|
| 213 |
+
const screenWidth = window.innerWidth;
|
| 214 |
+
const menuWidth = gradioApp().querySelector('.menu').offsetWidth;
|
| 215 |
+
const chatAreaWidth = chatArea.offsetWidth
|
| 216 |
+
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
function setChatbotHeight() {
|
| 220 |
const screenWidth = window.innerWidth;
|
| 221 |
const statusDisplay = document.querySelector('#status-display');
|
web_assets/javascript/webui.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
function openSettingBox() {
|
| 2 |
+
chuanhuPopup.classList.add('showBox');
|
| 3 |
+
settingBox.classList.remove('hideBox');
|
| 4 |
+
showMask();
|
| 5 |
+
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
function openTrainingBox() {
|
| 9 |
+
chuanhuPopup.classList.add('showBox');
|
| 10 |
+
trainingBox.classList.remove('hideBox');
|
| 11 |
+
showMask();
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
function showMask() {
|
| 15 |
+
const mask = document.createElement('div');
|
| 16 |
+
mask.classList.add('chuanhu-mask');
|
| 17 |
+
document.body.appendChild(mask);
|
| 18 |
+
mask.addEventListener('click', () => {
|
| 19 |
+
chuanhuPopup.classList.remove('showBox');
|
| 20 |
+
trainingBox.classList.add('hideBox');
|
| 21 |
+
settingBox.classList.add('hideBox');
|
| 22 |
+
mask.remove();
|
| 23 |
+
});
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
function menuClick() {
|
| 27 |
+
var menu = gradioApp().querySelector('#menu-area');
|
| 28 |
+
// var menuBtn = gradioApp().querySelector('.menu-btn');
|
| 29 |
+
if (menu.classList.contains('hideSide')) {
|
| 30 |
+
menu.classList.remove('hideSide');
|
| 31 |
+
// menuBtn.classList.add('active');
|
| 32 |
+
} else {
|
| 33 |
+
menu.classList.add('hideSide');
|
| 34 |
+
// menuBtn.classList.remove('active');
|
| 35 |
+
}
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
function setHistroyPanel() {
|
| 39 |
+
const historySelectorInput = gradioApp().querySelector('#history-select-dropdown input');
|
| 40 |
+
const historyPanel = document.createElement('div');
|
| 41 |
+
historyPanel.classList.add('chuanhu-history-panel');
|
| 42 |
+
historySelector.parentNode.insertBefore(historyPanel, historySelector);
|
| 43 |
+
var historyList=null;
|
| 44 |
+
|
| 45 |
+
historySelectorInput.addEventListener('click', (e) => {
|
| 46 |
+
e.stopPropagation();
|
| 47 |
+
historyList = gradioApp().querySelector('#history-select-dropdown ul.options');
|
| 48 |
+
|
| 49 |
+
if (historyList) {
|
| 50 |
+
// gradioApp().querySelector('.chuanhu-history-panel')?.remove();
|
| 51 |
+
historyPanel.innerHTML = '';
|
| 52 |
+
let historyListClone = historyList.cloneNode(true);
|
| 53 |
+
historyListClone.removeAttribute('style');
|
| 54 |
+
// historyList.classList.add('hidden');
|
| 55 |
+
historyList.classList.add('hideK');
|
| 56 |
+
historyPanel.appendChild(historyListClone);
|
| 57 |
+
addHistoryPanelListener(historyPanel);
|
| 58 |
+
// historySelector.parentNode.insertBefore(historyPanel, historySelector);
|
| 59 |
+
}
|
| 60 |
+
});
|
| 61 |
+
}
|
| 62 |
+
|
| 63 |
+
// function addHistoryPanelListener(historyPanel){
|
| 64 |
+
// historyPanel.querySelectorAll('ul.options > li').forEach((historyItem) => {
|
| 65 |
+
// historyItem.addEventListener('click', (e) => {
|
| 66 |
+
// const historySelectorInput = gradioApp().querySelector('#history-select-dropdown input');
|
| 67 |
+
// const historySelectBtn = gradioApp().querySelector('#history-select-btn');
|
| 68 |
+
// historySelectorInput.value = historyItem.innerText;
|
| 69 |
+
// historySelectBtn.click();
|
| 70 |
+
// });
|
| 71 |
+
// });
|
| 72 |
+
// }
|
| 73 |
+
|
| 74 |
+
// function bgSelectHistory(a,b,c){
|
| 75 |
+
// const historySelectorInput = gradioApp().querySelector('#history-select-dropdown input');
|
| 76 |
+
// let file = historySelectorInput.value;
|
| 77 |
+
// return [a,file,c]
|
| 78 |
+
// }
|
web_assets/stylesheet/ChuanhuChat.css
CHANGED
|
@@ -22,6 +22,8 @@
|
|
| 22 |
text-align: left;
|
| 23 |
margin-top: 6px;
|
| 24 |
white-space: nowrap;
|
|
|
|
|
|
|
| 25 |
}
|
| 26 |
#description {
|
| 27 |
text-align: center;
|
|
@@ -109,4 +111,56 @@
|
|
| 109 |
overflow: hidden;
|
| 110 |
text-overflow: ellipsis;
|
| 111 |
white-space: nowrap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
}
|
|
|
|
| 22 |
text-align: left;
|
| 23 |
margin-top: 6px;
|
| 24 |
white-space: nowrap;
|
| 25 |
+
flex-direction: row;
|
| 26 |
+
display: inline-flex;
|
| 27 |
}
|
| 28 |
#description {
|
| 29 |
text-align: center;
|
|
|
|
| 111 |
overflow: hidden;
|
| 112 |
text-overflow: ellipsis;
|
| 113 |
white-space: nowrap;
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
.chuanhu-mask {
|
| 117 |
+
background-color: gray;
|
| 118 |
+
opacity: 50%;
|
| 119 |
+
position: fixed;
|
| 120 |
+
top: 0;
|
| 121 |
+
left: 0;
|
| 122 |
+
width: 100%;
|
| 123 |
+
height: 100%;
|
| 124 |
+
z-index: 214748368;
|
| 125 |
+
}
|
| 126 |
+
#chuanhu-popup {
|
| 127 |
+
display: none;
|
| 128 |
+
z-index: 2147483689;
|
| 129 |
+
position: fixed;
|
| 130 |
+
top: 50%;
|
| 131 |
+
left: 50%;
|
| 132 |
+
transform: translate(-50%, -50%);
|
| 133 |
+
width: 800px;
|
| 134 |
+
height: 80%;
|
| 135 |
+
overflow: auto !important;
|
| 136 |
+
overflow-x: hidden !important;
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
#chuanhu-popup.showBox {
|
| 140 |
+
display: block;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.hideBox {
|
| 144 |
+
display: none;
|
| 145 |
+
}
|
| 146 |
+
.hideSide {
|
| 147 |
+
width: 0 !important;
|
| 148 |
+
display: none !important;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
#chatbot-area {
|
| 152 |
+
transition: width 0.3s ease-in-out;
|
| 153 |
+
}
|
| 154 |
+
.chuanhu-history-panel ul.options {
|
| 155 |
+
position: relative;
|
| 156 |
+
box-shadow: unset;
|
| 157 |
+
overflow: hidden;
|
| 158 |
+
}
|
| 159 |
+
.chuanhu-history-panel {
|
| 160 |
+
height: 500px;
|
| 161 |
+
overflow: auto;
|
| 162 |
+
box-shadow: var(--shadow-drop-lg);
|
| 163 |
+
}
|
| 164 |
+
#chuanhu-popup ul.options {
|
| 165 |
+
|
| 166 |
}
|