Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
52fd957
1
Parent(s):
6848520
WIP: make setting like box
Browse files- ChuanhuChatbot.py +168 -162
- web_assets/html/close_box_btn.html +3 -0
- web_assets/javascript/ChuanhuChat.js +14 -3
- web_assets/javascript/webui.js +8 -4
- web_assets/stylesheet/ChuanhuChat.css +71 -5
ChuanhuChatbot.py
CHANGED
|
@@ -167,175 +167,181 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
| 167 |
|
| 168 |
with gr.Box(elem_id="chuanhu-popup"):
|
| 169 |
with gr.Box(elem_id="chuanhu-setting"):
|
| 170 |
-
gr.
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 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"
|
| 279 |
-
|
| 280 |
-
|
| 281 |
-
|
|
|
|
| 282 |
)
|
| 283 |
-
|
| 284 |
-
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
)
|
| 290 |
-
|
| 291 |
-
|
| 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 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
value=
|
| 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.
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
with gr.Tab(label=i18n("
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
|
|
|
|
|
|
|
|
|
| 339 |
|
| 340 |
|
| 341 |
gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
|
|
|
|
| 167 |
|
| 168 |
with gr.Box(elem_id="chuanhu-popup"):
|
| 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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
show_label=True,
|
| 177 |
+
placeholder=f"Your API-key...",
|
| 178 |
+
value=hide_middle_chars(user_api_key.value),
|
| 179 |
+
type="password",
|
| 180 |
+
visible=not HIDE_MY_KEY,
|
| 181 |
+
label="API-Key",
|
| 182 |
)
|
| 183 |
+
if multi_api_key:
|
| 184 |
+
usageTxt = gr.Markdown(i18n("多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
| 185 |
+
else:
|
| 186 |
+
usageTxt = gr.Markdown(i18n("**发送消息** 或 **提交key** 以显示额度"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
| 187 |
+
model_select_dropdown = gr.Dropdown(
|
| 188 |
+
label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
|
| 189 |
)
|
| 190 |
+
lora_select_dropdown = gr.Dropdown(
|
| 191 |
+
label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
)
|
| 193 |
+
with gr.Row():
|
| 194 |
+
single_turn_checkbox = gr.Checkbox(label=i18n("单轮对话"), value=False, elem_classes="switch-checkbox")
|
| 195 |
+
use_websearch_checkbox = gr.Checkbox(label=i18n("使用在线搜索"), value=False, elem_classes="switch-checkbox")
|
| 196 |
+
language_select_dropdown = gr.Dropdown(
|
| 197 |
+
label=i18n("选择回复语言(针对搜索&索引功能)"),
|
| 198 |
+
choices=REPLY_LANGUAGES,
|
| 199 |
+
multiselect=False,
|
| 200 |
+
value=REPLY_LANGUAGES[0],
|
|
|
|
|
|
|
|
|
|
|
|
|
| 201 |
)
|
| 202 |
+
index_files = gr.Files(label=i18n("上传"), type="file", elem_id="upload-index-file")
|
| 203 |
+
two_column = gr.Checkbox(label=i18n("双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
|
| 204 |
+
summarize_btn = gr.Button(i18n("总结"))
|
| 205 |
+
# TODO: 公式ocr
|
| 206 |
+
# formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
|
| 207 |
+
|
| 208 |
+
with gr.Tab(label=i18n("高级")):
|
| 209 |
+
gr.HTML(get_html("appearance_switcher.html").format(label=i18n("切换亮暗色主题")), elem_classes="insert-block")
|
| 210 |
+
use_streaming_checkbox = gr.Checkbox(
|
| 211 |
+
label=i18n("实时传输回答"), value=True, visible=ENABLE_STREAMING_OPTION, elem_classes="switch-checkbox"
|
| 212 |
+
)
|
| 213 |
+
checkUpdateBtn = gr.Button(i18n("🔄 检查更新..."), visible=check_update)
|
| 214 |
+
gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️"), elem_id="advanced-warning")
|
| 215 |
+
with gr.Accordion(i18n("参数"), open=False):
|
| 216 |
+
temperature_slider = gr.Slider(
|
| 217 |
+
minimum=-0,
|
| 218 |
+
maximum=2.0,
|
| 219 |
+
value=1.0,
|
| 220 |
+
step=0.1,
|
| 221 |
+
interactive=True,
|
| 222 |
+
label="temperature",
|
| 223 |
+
)
|
| 224 |
+
top_p_slider = gr.Slider(
|
| 225 |
+
minimum=-0,
|
| 226 |
+
maximum=1.0,
|
| 227 |
+
value=1.0,
|
| 228 |
+
step=0.05,
|
| 229 |
+
interactive=True,
|
| 230 |
+
label="top-p",
|
| 231 |
+
)
|
| 232 |
+
n_choices_slider = gr.Slider(
|
| 233 |
+
minimum=1,
|
| 234 |
+
maximum=10,
|
| 235 |
+
value=1,
|
| 236 |
+
step=1,
|
| 237 |
+
interactive=True,
|
| 238 |
+
label="n choices",
|
| 239 |
+
)
|
| 240 |
+
stop_sequence_txt = gr.Textbox(
|
| 241 |
+
show_label=True,
|
| 242 |
+
placeholder=i18n("停止符,用英文逗号隔开..."),
|
| 243 |
+
label="stop",
|
| 244 |
+
value="",
|
| 245 |
+
lines=1,
|
| 246 |
+
)
|
| 247 |
+
max_context_length_slider = gr.Slider(
|
| 248 |
+
minimum=1,
|
| 249 |
+
maximum=32768,
|
| 250 |
+
value=2000,
|
| 251 |
+
step=1,
|
| 252 |
+
interactive=True,
|
| 253 |
+
label="max context",
|
| 254 |
+
)
|
| 255 |
+
max_generation_slider = gr.Slider(
|
| 256 |
+
minimum=1,
|
| 257 |
+
maximum=32768,
|
| 258 |
+
value=1000,
|
| 259 |
+
step=1,
|
| 260 |
+
interactive=True,
|
| 261 |
+
label="max generations",
|
| 262 |
+
)
|
| 263 |
+
presence_penalty_slider = gr.Slider(
|
| 264 |
+
minimum=-2.0,
|
| 265 |
+
maximum=2.0,
|
| 266 |
+
value=0.0,
|
| 267 |
+
step=0.01,
|
| 268 |
+
interactive=True,
|
| 269 |
+
label="presence penalty",
|
| 270 |
+
)
|
| 271 |
+
frequency_penalty_slider = gr.Slider(
|
| 272 |
+
minimum=-2.0,
|
| 273 |
+
maximum=2.0,
|
| 274 |
+
value=0.0,
|
| 275 |
+
step=0.01,
|
| 276 |
+
interactive=True,
|
| 277 |
+
label="frequency penalty",
|
| 278 |
+
)
|
| 279 |
+
logit_bias_txt = gr.Textbox(
|
| 280 |
+
show_label=True,
|
| 281 |
+
placeholder=f"word:likelihood",
|
| 282 |
+
label="logit bias",
|
| 283 |
+
value="",
|
| 284 |
+
lines=1,
|
| 285 |
+
)
|
| 286 |
+
user_identifier_txt = gr.Textbox(
|
| 287 |
+
show_label=True,
|
| 288 |
+
placeholder=i18n("用于定位滥用行为"),
|
| 289 |
+
label=i18n("用户名"),
|
| 290 |
+
value=user_name.value,
|
| 291 |
+
lines=1,
|
| 292 |
+
)
|
| 293 |
+
|
| 294 |
+
with gr.Accordion(i18n("网络参数"), open=False):
|
| 295 |
+
gr.Markdown(i18n("---\n⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置"), elem_id="netsetting-warning")
|
| 296 |
+
default_btn = gr.Button(i18n("🔙 恢复默认网络设置"))
|
| 297 |
+
# 网络代理
|
| 298 |
+
proxyTxt = gr.Textbox(
|
| 299 |
+
show_label=True,
|
| 300 |
+
placeholder=i18n("未设置代理..."),
|
| 301 |
+
label=i18n("代理地址"),
|
| 302 |
+
value=config.http_proxy,
|
| 303 |
+
lines=1,
|
| 304 |
+
interactive=False,
|
| 305 |
+
# container=False,
|
| 306 |
+
elem_classes="view-only-textbox no-container",
|
| 307 |
+
)
|
| 308 |
+
# changeProxyBtn = gr.Button(i18n("🔄 设置代理地址"))
|
| 309 |
+
|
| 310 |
+
# 优先展示自定义的api_host
|
| 311 |
+
apihostTxt = gr.Textbox(
|
| 312 |
+
show_label=True,
|
| 313 |
+
placeholder="api.openai.com",
|
| 314 |
+
label="OpenAI API-Host",
|
| 315 |
+
value=config.api_host or shared.API_HOST,
|
| 316 |
+
lines=1,
|
| 317 |
+
interactive=False,
|
| 318 |
+
# container=False,
|
| 319 |
+
elem_classes="view-only-textbox no-container",
|
| 320 |
+
)
|
| 321 |
|
| 322 |
with gr.Box(elem_id="chuanhu-training"):
|
| 323 |
+
with gr.Row():
|
| 324 |
+
gr.Markdown("## Training")
|
| 325 |
+
gr.HTML(get_html("close_box_btn.html"),elem_classes="close-box-btn")
|
| 326 |
+
with gr.Tabs(elem_id="chuanhu-training-tabs"):
|
| 327 |
+
with gr.Tab(label=i18n("OpenAI 微调")):
|
| 328 |
+
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)"))
|
| 329 |
+
|
| 330 |
+
with gr.Tab(label=i18n("准备数据集")):
|
| 331 |
+
dataset_preview_json = gr.JSON(label=i18n("数据集预览"), readonly=True)
|
| 332 |
+
dataset_selection = gr.Files(label = i18n("选择数据集"), file_types=[".xlsx", ".jsonl"], file_count="single")
|
| 333 |
+
upload_to_openai_btn = gr.Button(i18n("上传到OpenAI"), variant="primary", interactive=False)
|
| 334 |
+
|
| 335 |
+
with gr.Tab(label=i18n("训练")):
|
| 336 |
+
openai_ft_file_id = gr.Textbox(label=i18n("文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动填充"))
|
| 337 |
+
openai_ft_suffix = gr.Textbox(label=i18n("模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
|
| 338 |
+
openai_train_epoch_slider = gr.Slider(label=i18n("训练轮数(Epochs)"), minimum=1, maximum=100, value=3, step=1, interactive=True)
|
| 339 |
+
openai_start_train_btn = gr.Button(i18n("开始训练"), variant="primary", interactive=False)
|
| 340 |
+
|
| 341 |
+
with gr.Tab(label=i18n("状态")):
|
| 342 |
+
openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
|
| 343 |
+
openai_cancel_all_jobs_btn = gr.Button(i18n("取消所有任务"))
|
| 344 |
+
add_to_models_btn = gr.Button(i18n("添加训练好的模型到模型列表"), interactive=False)
|
| 345 |
|
| 346 |
|
| 347 |
gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
|
web_assets/html/close_box_btn.html
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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/javascript/ChuanhuChat.js
CHANGED
|
@@ -48,7 +48,7 @@ function gradioLoaded(mutations) {
|
|
| 48 |
}
|
| 49 |
|
| 50 |
function initialize() {
|
| 51 |
-
var needInit = {gradioContainer, apSwitch, user_input_tb, userInfoDiv, appTitleDiv, chatbot, chatbotIndicator, chatbotWrap, statusDisplay, sliders, updateChuanhuBtn};
|
| 52 |
initialized = true;
|
| 53 |
|
| 54 |
loginUserForm = gradioApp().querySelector(".gradio-container > .main > .wrap > .panel > .form")
|
|
@@ -91,6 +91,7 @@ function initialize() {
|
|
| 91 |
setTimeout(showOrHideUserInfo(), 2000);
|
| 92 |
setChatbotHeight();
|
| 93 |
setChatbotScroll();
|
|
|
|
| 94 |
setSlider();
|
| 95 |
setAvatar();
|
| 96 |
if (!historyLoaded) loadHistoryHtml();
|
|
@@ -216,6 +217,16 @@ function setChatAreaWidth() {
|
|
| 216 |
|
| 217 |
}
|
| 218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 219 |
function setChatbotHeight() {
|
| 220 |
const screenWidth = window.innerWidth;
|
| 221 |
const statusDisplay = document.querySelector('#status-display');
|
|
@@ -303,8 +314,8 @@ window.addEventListener("DOMContentLoaded", function () {
|
|
| 303 |
isInIframe = (window.self !== window.top);
|
| 304 |
historyLoaded = false;
|
| 305 |
});
|
| 306 |
-
window.addEventListener('resize', setChatbotHeight);
|
| 307 |
-
window.addEventListener('scroll',
|
| 308 |
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", adjustDarkMode);
|
| 309 |
|
| 310 |
// console suprise
|
|
|
|
| 48 |
}
|
| 49 |
|
| 50 |
function initialize() {
|
| 51 |
+
var needInit = {gradioContainer, apSwitch, user_input_tb, userInfoDiv, appTitleDiv, chatbot, chatbotIndicator, chatbotWrap, statusDisplay, sliders, updateChuanhuBtn, chuanhuPopup};
|
| 52 |
initialized = true;
|
| 53 |
|
| 54 |
loginUserForm = gradioApp().querySelector(".gradio-container > .main > .wrap > .panel > .form")
|
|
|
|
| 91 |
setTimeout(showOrHideUserInfo(), 2000);
|
| 92 |
setChatbotHeight();
|
| 93 |
setChatbotScroll();
|
| 94 |
+
setPopupBoxPosition();
|
| 95 |
setSlider();
|
| 96 |
setAvatar();
|
| 97 |
if (!historyLoaded) loadHistoryHtml();
|
|
|
|
| 217 |
|
| 218 |
}
|
| 219 |
|
| 220 |
+
function setPopupBoxPosition() {
|
| 221 |
+
const screenWidth = window.innerWidth;
|
| 222 |
+
const screenHeight = window.innerHeight;
|
| 223 |
+
|
| 224 |
+
const popupBoxWidth = 680;
|
| 225 |
+
const popupBoxHeight = 400;
|
| 226 |
+
chuanhuPopup.style.left = `${(screenWidth - popupBoxWidth) / 2}px`;
|
| 227 |
+
chuanhuPopup.style.top = `${(screenHeight - popupBoxHeight) / 2}px`;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
function setChatbotHeight() {
|
| 231 |
const screenWidth = window.innerWidth;
|
| 232 |
const statusDisplay = document.querySelector('#status-display');
|
|
|
|
| 314 |
isInIframe = (window.self !== window.top);
|
| 315 |
historyLoaded = false;
|
| 316 |
});
|
| 317 |
+
window.addEventListener('resize', ()=>{setChatbotHeight();setPopupBoxPosition()});
|
| 318 |
+
window.addEventListener('scroll', ()=>{setChatbotHeight(); setUpdateWindowHeight();setPopupBoxPosition();});
|
| 319 |
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", adjustDarkMode);
|
| 320 |
|
| 321 |
// console suprise
|
web_assets/javascript/webui.js
CHANGED
|
@@ -16,13 +16,17 @@ function showMask() {
|
|
| 16 |
mask.classList.add('chuanhu-mask');
|
| 17 |
document.body.appendChild(mask);
|
| 18 |
mask.addEventListener('click', () => {
|
| 19 |
-
|
| 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');
|
|
|
|
| 16 |
mask.classList.add('chuanhu-mask');
|
| 17 |
document.body.appendChild(mask);
|
| 18 |
mask.addEventListener('click', () => {
|
| 19 |
+
closeBox();
|
|
|
|
|
|
|
|
|
|
| 20 |
});
|
| 21 |
}
|
| 22 |
|
| 23 |
+
function closeBox() {
|
| 24 |
+
chuanhuPopup.classList.remove('showBox');
|
| 25 |
+
trainingBox.classList.add('hideBox');
|
| 26 |
+
settingBox.classList.add('hideBox');
|
| 27 |
+
document.querySelector('.chuanhu-mask')?.remove();
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
function menuClick() {
|
| 31 |
var menu = gradioApp().querySelector('#menu-area');
|
| 32 |
// var menuBtn = gradioApp().querySelector('.menu-btn');
|
web_assets/stylesheet/ChuanhuChat.css
CHANGED
|
@@ -127,19 +127,27 @@
|
|
| 127 |
display: none;
|
| 128 |
z-index: 2147483689;
|
| 129 |
position: fixed;
|
|
|
|
|
|
|
|
|
|
| 130 |
top: 50%;
|
| 131 |
left: 50%;
|
| 132 |
transform: translate(-50%, -50%);
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
|
|
|
|
|
|
| 137 |
}
|
| 138 |
|
| 139 |
#chuanhu-popup.showBox {
|
| 140 |
display: block;
|
| 141 |
}
|
| 142 |
|
|
|
|
|
|
|
|
|
|
| 143 |
.hideBox {
|
| 144 |
display: none;
|
| 145 |
}
|
|
@@ -161,6 +169,64 @@
|
|
| 161 |
overflow: auto;
|
| 162 |
box-shadow: var(--shadow-drop-lg);
|
| 163 |
}
|
| 164 |
-
#chuanhu-popup ul.options {
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
}
|
|
|
|
| 127 |
display: none;
|
| 128 |
z-index: 2147483689;
|
| 129 |
position: fixed;
|
| 130 |
+
top: 20px;
|
| 131 |
+
left: 20px;
|
| 132 |
+
/*
|
| 133 |
top: 50%;
|
| 134 |
left: 50%;
|
| 135 |
transform: translate(-50%, -50%);
|
| 136 |
+
*/
|
| 137 |
+
width: 680px;
|
| 138 |
+
height: 400px;
|
| 139 |
+
/* overflow: hidden!important; */
|
| 140 |
+
/* overflow-x: hidden !important; */
|
| 141 |
+
padding: 0;
|
| 142 |
}
|
| 143 |
|
| 144 |
#chuanhu-popup.showBox {
|
| 145 |
display: block;
|
| 146 |
}
|
| 147 |
|
| 148 |
+
#chuanhu-popup > .gradio-box {
|
| 149 |
+
padding: 0;
|
| 150 |
+
}
|
| 151 |
.hideBox {
|
| 152 |
display: none;
|
| 153 |
}
|
|
|
|
| 169 |
overflow: auto;
|
| 170 |
box-shadow: var(--shadow-drop-lg);
|
| 171 |
}
|
|
|
|
| 172 |
|
| 173 |
+
#chuanhu-popup > .gradio-box > .gradio-row:first-of-type {
|
| 174 |
+
padding: 24px !important;
|
| 175 |
+
border-bottom: 1.8px solid var(--border-color-primary);
|
| 176 |
+
}
|
| 177 |
+
#chuanhu-popup > .gradio-box > .gradio-row > .close-box-btn {
|
| 178 |
+
max-width: 28px;
|
| 179 |
+
display: flex;
|
| 180 |
+
justify-content: flex-end;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
#chuanhu-popup > .gradio-box > .gradio-tabs {
|
| 184 |
+
display: block;
|
| 185 |
+
height: 324px;
|
| 186 |
+
/* margin: 16px 24px; */
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
#chuanhu-popup > .gradio-box > .gradio-tabs > div.tabitem {
|
| 190 |
+
border: none;
|
| 191 |
+
border-radius: 0;
|
| 192 |
+
overflow: auto;
|
| 193 |
+
height: 100%;
|
| 194 |
+
padding: 16px 24px;
|
| 195 |
+
}
|
| 196 |
+
#chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav {
|
| 197 |
+
float: left;
|
| 198 |
+
display: block;
|
| 199 |
+
border: none;
|
| 200 |
+
padding: 16px;
|
| 201 |
+
width: 180px;
|
| 202 |
+
height: 100%;
|
| 203 |
+
overflow: auto;
|
| 204 |
+
background: var(--background-fill-secondary);
|
| 205 |
+
border-bottom-left-radius: var(--block-radius);
|
| 206 |
+
border-right: 1px solid var(--border-color-primary);
|
| 207 |
+
}
|
| 208 |
+
#chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav > button {
|
| 209 |
+
display: block;
|
| 210 |
+
border: none;
|
| 211 |
+
border-radius: 6px;
|
| 212 |
+
text-align: left;
|
| 213 |
+
white-space: initial;
|
| 214 |
+
width: 100%;
|
| 215 |
+
/* height: 32px; */
|
| 216 |
+
padding: 7px 12px;
|
| 217 |
+
}
|
| 218 |
+
#chuanhu-popup > .gradio-box > .gradio-tabs > div.tab-nav > button.selected {
|
| 219 |
+
background-color: var(--button-primary-background-fill);
|
| 220 |
+
/* font-weight: bold; */
|
| 221 |
+
color: var(--button-primary-text-color);
|
| 222 |
+
}
|
| 223 |
+
/* #chuanhu-popup ul.options {
|
| 224 |
+
transform: translate(-50%, -50%);
|
| 225 |
+
} */
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
#history-select-wrap {
|
| 229 |
+
height: 400px;
|
| 230 |
+
overflow: auto;
|
| 231 |
+
overflow-x: hidden;
|
| 232 |
}
|