shibing624 JohnSmith9982 commited on
Commit
ad38f61
·
0 Parent(s):

Duplicate from JohnSmith9982/ChuanhuChatGPT

Browse files

Co-authored-by: John Smith <[email protected]>

This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +34 -0
  2. CITATION.cff +20 -0
  3. ChuanhuChatbot.py +473 -0
  4. Dockerfile +15 -0
  5. LICENSE +674 -0
  6. README.md +14 -0
  7. assets/Kelpy-Codos.js +76 -0
  8. assets/custom.css +468 -0
  9. assets/custom.js +502 -0
  10. assets/external-scripts.js +2 -0
  11. assets/favicon.ico +0 -0
  12. assets/favicon.png +0 -0
  13. assets/html/appearance_switcher.html +11 -0
  14. assets/html/footer.html +1 -0
  15. chatgpt - macOS.command +7 -0
  16. chatgpt - windows.bat +14 -0
  17. config.json +3 -0
  18. config_example.json +34 -0
  19. configs/ds_config_chatbot.json +17 -0
  20. custom.css +162 -0
  21. history/2023-06-14_15-05-04.json +0 -0
  22. locale/en_US.json +73 -0
  23. locale/extract_locale.py +26 -0
  24. locale/ja_JP.json +73 -0
  25. modules/__init__.py +0 -0
  26. modules/__pycache__/__init__.cpython-311.pyc +0 -0
  27. modules/__pycache__/__init__.cpython-39.pyc +0 -0
  28. modules/__pycache__/base_model.cpython-311.pyc +0 -0
  29. modules/__pycache__/base_model.cpython-39.pyc +0 -0
  30. modules/__pycache__/chat_func.cpython-39.pyc +0 -0
  31. modules/__pycache__/config.cpython-311.pyc +0 -0
  32. modules/__pycache__/config.cpython-39.pyc +0 -0
  33. modules/__pycache__/index_func.cpython-311.pyc +0 -0
  34. modules/__pycache__/index_func.cpython-39.pyc +0 -0
  35. modules/__pycache__/llama_func.cpython-311.pyc +0 -0
  36. modules/__pycache__/llama_func.cpython-39.pyc +0 -0
  37. modules/__pycache__/models.cpython-311.pyc +0 -0
  38. modules/__pycache__/models.cpython-39.pyc +0 -0
  39. modules/__pycache__/openai_func.cpython-39.pyc +0 -0
  40. modules/__pycache__/overwrites.cpython-311.pyc +0 -0
  41. modules/__pycache__/overwrites.cpython-39.pyc +0 -0
  42. modules/__pycache__/pdf_func.cpython-311.pyc +0 -0
  43. modules/__pycache__/pdf_func.cpython-39.pyc +0 -0
  44. modules/__pycache__/presets.cpython-311.pyc +0 -0
  45. modules/__pycache__/presets.cpython-39.pyc +0 -0
  46. modules/__pycache__/proxy_func.cpython-39.pyc +0 -0
  47. modules/__pycache__/shared.cpython-311.pyc +0 -0
  48. modules/__pycache__/shared.cpython-39.pyc +0 -0
  49. modules/__pycache__/utils.cpython-311.pyc +0 -0
  50. modules/__pycache__/utils.cpython-39.pyc +0 -0
.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
CITATION.cff ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ cff-version: 1.2.0
2
+ title: ChuanhuChatGPT
3
+ message: >-
4
+ If you use this software, please cite it using these
5
+ metadata.
6
+ type: software
7
+ authors:
8
+ - given-names: Chuanhu
9
+ orcid: https://orcid.org/0000-0001-8954-8598
10
+ - given-names: MZhao
11
+ orcid: https://orcid.org/0000-0003-2298-6213
12
+ - given-names: Keldos
13
+ orcid: https://orcid.org/0009-0005-0357-272X
14
+ repository-code: 'https://github.com/GaiZhenbiao/ChuanhuChatGPT'
15
+ url: 'https://github.com/GaiZhenbiao/ChuanhuChatGPT'
16
+ abstract: Provided a light and easy to use interface for ChatGPT API
17
+ license: GPL-3.0
18
+ commit: bd0034c37e5af6a90bd9c2f7dd073f6cd27c61af
19
+ version: '20230405'
20
+ date-released: '2023-04-05'
ChuanhuChatbot.py ADDED
@@ -0,0 +1,473 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding:utf-8 -*-
2
+ import os
3
+ import logging
4
+ import sys
5
+
6
+ import gradio as gr
7
+
8
+ from modules import config
9
+ from modules.config import *
10
+ from modules.utils import *
11
+ from modules.presets import *
12
+ from modules.overwrites import *
13
+ from modules.models.models import get_model
14
+
15
+ logging.getLogger("httpx").setLevel(logging.WARNING)
16
+
17
+ gr.Chatbot._postprocess_chat_messages = postprocess_chat_messages
18
+ gr.Chatbot.postprocess = postprocess
19
+
20
+ with open("assets/custom.css", "r", encoding="utf-8") as f:
21
+ customCSS = f.read()
22
+
23
+ def create_new_model():
24
+ return get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
25
+
26
+ with gr.Blocks(css=customCSS, theme=small_and_beautiful_theme) as demo:
27
+ user_name = gr.State("")
28
+ promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
29
+ user_question = gr.State("")
30
+ assert type(my_api_key)==str
31
+ user_api_key = gr.State(my_api_key)
32
+ current_model = gr.State(create_new_model)
33
+
34
+ topic = gr.State(i18n("未命名对话历史记录"))
35
+
36
+ with gr.Row():
37
+ gr.HTML(CHUANHU_TITLE, elem_id="app_title")
38
+ status_display = gr.Markdown(get_geoip(), elem_id="status_display")
39
+ with gr.Row(elem_id="float_display"):
40
+ user_info = gr.Markdown(value="getting user info...", elem_id="user_info")
41
+
42
+ with gr.Row().style(equal_height=True):
43
+ with gr.Column(scale=5):
44
+ with gr.Row():
45
+ chatbot = gr.Chatbot(label="Chuanhu Chat", elem_id="chuanhu_chatbot").style(height="100%")
46
+ with gr.Row():
47
+ with gr.Column(min_width=225, scale=12):
48
+ user_input = gr.Textbox(
49
+ elem_id="user_input_tb",
50
+ show_label=False, placeholder=i18n("在这里输入")
51
+ ).style(container=False)
52
+ with gr.Column(min_width=42, scale=1):
53
+ submitBtn = gr.Button(value="", variant="primary", elem_id="submit_btn")
54
+ cancelBtn = gr.Button(value="", variant="secondary", visible=False, elem_id="cancel_btn")
55
+ with gr.Row():
56
+ emptyBtn = gr.Button(
57
+ i18n("🧹 新的对话"), elem_id="empty_btn"
58
+ )
59
+ retryBtn = gr.Button(i18n("🔄 重新生成"))
60
+ delFirstBtn = gr.Button(i18n("🗑️ 删除最旧对话"))
61
+ delLastBtn = gr.Button(i18n("🗑️ 删除最新对话"))
62
+ with gr.Row(visible=False) as like_dislike_area:
63
+ with gr.Column(min_width=20, scale=1):
64
+ likeBtn = gr.Button(i18n("👍"))
65
+ with gr.Column(min_width=20, scale=1):
66
+ dislikeBtn = gr.Button(i18n("👎"))
67
+
68
+ with gr.Column():
69
+ with gr.Column(min_width=50, scale=1):
70
+ with gr.Tab(label=i18n("模型")):
71
+ keyTxt = gr.Textbox(
72
+ show_label=True,
73
+ placeholder=f"Your API-key...",
74
+ value=hide_middle_chars(user_api_key.value),
75
+ type="password",
76
+ visible=not HIDE_MY_KEY,
77
+ label="API-Key",
78
+ )
79
+ if multi_api_key:
80
+ usageTxt = gr.Markdown(i18n("多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage_display", elem_classes="insert_block")
81
+ else:
82
+ usageTxt = gr.Markdown(i18n("**发送消息** 或 **提交key** 以显示额度"), elem_id="usage_display", elem_classes="insert_block")
83
+ model_select_dropdown = gr.Dropdown(
84
+ label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
85
+ )
86
+ lora_select_dropdown = gr.Dropdown(
87
+ label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
88
+ )
89
+ with gr.Row():
90
+ single_turn_checkbox = gr.Checkbox(label=i18n("单轮对话"), value=False)
91
+ use_websearch_checkbox = gr.Checkbox(label=i18n("使用在线搜索"), value=False)
92
+ language_select_dropdown = gr.Dropdown(
93
+ label=i18n("选择回复语言(针对搜索&索引功能)"),
94
+ choices=REPLY_LANGUAGES,
95
+ multiselect=False,
96
+ value=REPLY_LANGUAGES[0],
97
+ )
98
+ index_files = gr.Files(label=i18n("上传"), type="file")
99
+ two_column = gr.Checkbox(label=i18n("双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
100
+ summarize_btn = gr.Button(i18n("总结"))
101
+ # TODO: 公式ocr
102
+ # formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
103
+
104
+ with gr.Tab(label="Prompt"):
105
+ systemPromptTxt = gr.Textbox(
106
+ show_label=True,
107
+ placeholder=i18n("在这里输入System Prompt..."),
108
+ label="System prompt",
109
+ value=INITIAL_SYSTEM_PROMPT,
110
+ lines=10,
111
+ ).style(container=False)
112
+ with gr.Accordion(label=i18n("加载Prompt模板"), open=True):
113
+ with gr.Column():
114
+ with gr.Row():
115
+ with gr.Column(scale=6):
116
+ templateFileSelectDropdown = gr.Dropdown(
117
+ label=i18n("选择Prompt模板集合文件"),
118
+ choices=get_template_names(plain=True),
119
+ multiselect=False,
120
+ value=get_template_names(plain=True)[0],
121
+ ).style(container=False)
122
+ with gr.Column(scale=1):
123
+ templateRefreshBtn = gr.Button(i18n("🔄 刷新"))
124
+ with gr.Row():
125
+ with gr.Column():
126
+ templateSelectDropdown = gr.Dropdown(
127
+ label=i18n("从Prompt模板中加载"),
128
+ choices=load_template(
129
+ get_template_names(plain=True)[0], mode=1
130
+ ),
131
+ multiselect=False,
132
+ ).style(container=False)
133
+
134
+ with gr.Tab(label=i18n("保存/加载")):
135
+ with gr.Accordion(label=i18n("保存/加载对话历史记录"), open=True):
136
+ with gr.Column():
137
+ with gr.Row():
138
+ with gr.Column(scale=6):
139
+ historyFileSelectDropdown = gr.Dropdown(
140
+ label=i18n("从列表中加载对话"),
141
+ choices=get_history_names(plain=True),
142
+ multiselect=False
143
+ )
144
+ with gr.Column(scale=1):
145
+ historyRefreshBtn = gr.Button(i18n("🔄 刷新"))
146
+ with gr.Row():
147
+ with gr.Column(scale=6):
148
+ saveFileName = gr.Textbox(
149
+ show_label=True,
150
+ placeholder=i18n("设置文件名: 默认为.json,可选为.md"),
151
+ label=i18n("设置保存文件名"),
152
+ value=i18n("对话历史记录"),
153
+ ).style(container=True)
154
+ with gr.Column(scale=1):
155
+ saveHistoryBtn = gr.Button(i18n("💾 保存对话"))
156
+ exportMarkdownBtn = gr.Button(i18n("📝 导出为Markdown"))
157
+ gr.Markdown(i18n("默认保存于history文件夹"))
158
+ with gr.Row():
159
+ with gr.Column():
160
+ downloadFile = gr.File(interactive=True)
161
+
162
+ with gr.Tab(label=i18n("高级")):
163
+ gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️\n\n如果无法使用请恢复默认设置"))
164
+ gr.HTML(get_html("appearance_switcher.html").format(label=i18n("切换亮暗色主题")), elem_classes="insert_block")
165
+ use_streaming_checkbox = gr.Checkbox(
166
+ label=i18n("实时传输回答"), value=True, visible=ENABLE_STREAMING_OPTION
167
+ )
168
+ with gr.Accordion(i18n("参数"), open=False):
169
+ temperature_slider = gr.Slider(
170
+ minimum=-0,
171
+ maximum=2.0,
172
+ value=1.0,
173
+ step=0.1,
174
+ interactive=True,
175
+ label="temperature",
176
+ )
177
+ top_p_slider = gr.Slider(
178
+ minimum=-0,
179
+ maximum=1.0,
180
+ value=1.0,
181
+ step=0.05,
182
+ interactive=True,
183
+ label="top-p",
184
+ )
185
+ n_choices_slider = gr.Slider(
186
+ minimum=1,
187
+ maximum=10,
188
+ value=1,
189
+ step=1,
190
+ interactive=True,
191
+ label="n choices",
192
+ )
193
+ stop_sequence_txt = gr.Textbox(
194
+ show_label=True,
195
+ placeholder=i18n("在这里输入停止符,用英文逗号隔开..."),
196
+ label="stop",
197
+ value="",
198
+ lines=1,
199
+ )
200
+ max_context_length_slider = gr.Slider(
201
+ minimum=1,
202
+ maximum=32768,
203
+ value=2000,
204
+ step=1,
205
+ interactive=True,
206
+ label="max context",
207
+ )
208
+ max_generation_slider = gr.Slider(
209
+ minimum=1,
210
+ maximum=32768,
211
+ value=1000,
212
+ step=1,
213
+ interactive=True,
214
+ label="max generations",
215
+ )
216
+ presence_penalty_slider = gr.Slider(
217
+ minimum=-2.0,
218
+ maximum=2.0,
219
+ value=0.0,
220
+ step=0.01,
221
+ interactive=True,
222
+ label="presence penalty",
223
+ )
224
+ frequency_penalty_slider = gr.Slider(
225
+ minimum=-2.0,
226
+ maximum=2.0,
227
+ value=0.0,
228
+ step=0.01,
229
+ interactive=True,
230
+ label="frequency penalty",
231
+ )
232
+ logit_bias_txt = gr.Textbox(
233
+ show_label=True,
234
+ placeholder=f"word:likelihood",
235
+ label="logit bias",
236
+ value="",
237
+ lines=1,
238
+ )
239
+ user_identifier_txt = gr.Textbox(
240
+ show_label=True,
241
+ placeholder=i18n("用于定位滥用行为"),
242
+ label=i18n("用户名"),
243
+ value=user_name.value,
244
+ lines=1,
245
+ )
246
+
247
+ with gr.Accordion(i18n("网络设置"), open=False, visible=False):
248
+ # 优先展示自定义的api_host
249
+ apihostTxt = gr.Textbox(
250
+ show_label=True,
251
+ placeholder=i18n("在这里输入API-Host..."),
252
+ label="API-Host",
253
+ value=config.api_host or shared.API_HOST,
254
+ lines=1,
255
+ )
256
+ changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
257
+ proxyTxt = gr.Textbox(
258
+ show_label=True,
259
+ placeholder=i18n("在这里输入代理地址..."),
260
+ label=i18n("代理地址(示例:http://127.0.0.1:10809)"),
261
+ value="",
262
+ lines=2,
263
+ )
264
+ changeProxyBtn = gr.Button(i18n("🔄 设置代理地址"))
265
+ default_btn = gr.Button(i18n("🔙 恢复默认设置"))
266
+
267
+ gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
268
+ gr.HTML(get_html("footer.html").format(versions=versions_html()), elem_id="footer")
269
+
270
+ # https://github.com/gradio-app/gradio/pull/3296
271
+ def create_greeting(request: gr.Request):
272
+ if hasattr(request, "username") and request.username: # is not None or is not ""
273
+ logging.info(f"Get User Name: {request.username}")
274
+ user_info, user_name = gr.Markdown.update(value=f"User: {request.username}"), request.username
275
+ else:
276
+ user_info, user_name = gr.Markdown.update(value=f"", visible=False), ""
277
+ current_model = get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
278
+ current_model.set_user_identifier(user_name)
279
+ chatbot = gr.Chatbot.update(label=MODELS[DEFAULT_MODEL])
280
+ return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), *current_model.auto_load(), get_history_names(False, user_name), chatbot
281
+ demo.load(create_greeting, inputs=None, outputs=[user_info, user_name, current_model, like_dislike_area, systemPromptTxt, chatbot, historyFileSelectDropdown, chatbot], api_name="load")
282
+ chatgpt_predict_args = dict(
283
+ fn=predict,
284
+ inputs=[
285
+ current_model,
286
+ user_question,
287
+ chatbot,
288
+ use_streaming_checkbox,
289
+ use_websearch_checkbox,
290
+ index_files,
291
+ language_select_dropdown,
292
+ ],
293
+ outputs=[chatbot, status_display],
294
+ show_progress=True,
295
+ )
296
+
297
+ start_outputing_args = dict(
298
+ fn=start_outputing,
299
+ inputs=[],
300
+ outputs=[submitBtn, cancelBtn],
301
+ show_progress=True,
302
+ )
303
+
304
+ end_outputing_args = dict(
305
+ fn=end_outputing, inputs=[], outputs=[submitBtn, cancelBtn]
306
+ )
307
+
308
+ reset_textbox_args = dict(
309
+ fn=reset_textbox, inputs=[], outputs=[user_input]
310
+ )
311
+
312
+ transfer_input_args = dict(
313
+ fn=transfer_input, inputs=[user_input], outputs=[user_question, user_input, submitBtn, cancelBtn], show_progress=True
314
+ )
315
+
316
+ get_usage_args = dict(
317
+ fn=billing_info, inputs=[current_model], outputs=[usageTxt], show_progress=False
318
+ )
319
+
320
+ load_history_from_file_args = dict(
321
+ fn=load_chat_history,
322
+ inputs=[current_model, historyFileSelectDropdown, user_name],
323
+ outputs=[saveFileName, systemPromptTxt, chatbot]
324
+ )
325
+
326
+
327
+ # Chatbot
328
+ cancelBtn.click(interrupt, [current_model], [])
329
+
330
+ user_input.submit(**transfer_input_args).then(**chatgpt_predict_args).then(**end_outputing_args)
331
+ user_input.submit(**get_usage_args)
332
+
333
+ submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args, api_name="predict").then(**end_outputing_args)
334
+ submitBtn.click(**get_usage_args)
335
+
336
+ index_files.change(handle_file_upload, [current_model, index_files, chatbot, language_select_dropdown], [index_files, chatbot, status_display])
337
+ summarize_btn.click(handle_summarize_index, [current_model, index_files, chatbot, language_select_dropdown], [chatbot, status_display])
338
+
339
+ emptyBtn.click(
340
+ reset,
341
+ inputs=[current_model],
342
+ outputs=[chatbot, status_display],
343
+ show_progress=True,
344
+ )
345
+
346
+ retryBtn.click(**start_outputing_args).then(
347
+ retry,
348
+ [
349
+ current_model,
350
+ chatbot,
351
+ use_streaming_checkbox,
352
+ use_websearch_checkbox,
353
+ index_files,
354
+ language_select_dropdown,
355
+ ],
356
+ [chatbot, status_display],
357
+ show_progress=True,
358
+ ).then(**end_outputing_args)
359
+ retryBtn.click(**get_usage_args)
360
+
361
+ delFirstBtn.click(
362
+ delete_first_conversation,
363
+ [current_model],
364
+ [status_display],
365
+ )
366
+
367
+ delLastBtn.click(
368
+ delete_last_conversation,
369
+ [current_model, chatbot],
370
+ [chatbot, status_display],
371
+ show_progress=False
372
+ )
373
+
374
+ likeBtn.click(
375
+ like,
376
+ [current_model],
377
+ [status_display],
378
+ show_progress=False
379
+ )
380
+
381
+ dislikeBtn.click(
382
+ dislike,
383
+ [current_model],
384
+ [status_display],
385
+ show_progress=False
386
+ )
387
+
388
+ two_column.change(update_doc_config, [two_column], None)
389
+
390
+ # LLM Models
391
+ keyTxt.change(set_key, [current_model, keyTxt], [user_api_key, status_display], api_name="set_key").then(**get_usage_args)
392
+ keyTxt.submit(**get_usage_args)
393
+ single_turn_checkbox.change(set_single_turn, [current_model, single_turn_checkbox], None)
394
+ model_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider, top_p_slider, systemPromptTxt, user_name], [current_model, status_display, chatbot, lora_select_dropdown], show_progress=True, api_name="get_model")
395
+ model_select_dropdown.change(toggle_like_btn_visibility, [model_select_dropdown], [like_dislike_area], show_progress=False)
396
+ lora_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider, top_p_slider, systemPromptTxt, user_name], [current_model, status_display, chatbot], show_progress=True)
397
+
398
+ # Template
399
+ systemPromptTxt.change(set_system_prompt, [current_model, systemPromptTxt], None)
400
+ templateRefreshBtn.click(get_template_names, None, [templateFileSelectDropdown])
401
+ templateFileSelectDropdown.change(
402
+ load_template,
403
+ [templateFileSelectDropdown],
404
+ [promptTemplates, templateSelectDropdown],
405
+ show_progress=True,
406
+ )
407
+ templateSelectDropdown.change(
408
+ get_template_content,
409
+ [promptTemplates, templateSelectDropdown, systemPromptTxt],
410
+ [systemPromptTxt],
411
+ show_progress=True,
412
+ )
413
+
414
+ # S&L
415
+ saveHistoryBtn.click(
416
+ save_chat_history,
417
+ [current_model, saveFileName, chatbot, user_name],
418
+ downloadFile,
419
+ show_progress=True,
420
+ )
421
+ saveHistoryBtn.click(get_history_names, [gr.State(False), user_name], [historyFileSelectDropdown])
422
+ exportMarkdownBtn.click(
423
+ export_markdown,
424
+ [current_model, saveFileName, chatbot, user_name],
425
+ downloadFile,
426
+ show_progress=True,
427
+ )
428
+ historyRefreshBtn.click(get_history_names, [gr.State(False), user_name], [historyFileSelectDropdown])
429
+ historyFileSelectDropdown.change(**load_history_from_file_args)
430
+ downloadFile.change(upload_chat_history, [current_model, downloadFile, user_name], [saveFileName, systemPromptTxt, chatbot])
431
+
432
+ # Advanced
433
+ max_context_length_slider.change(set_token_upper_limit, [current_model, max_context_length_slider], None)
434
+ temperature_slider.change(set_temperature, [current_model, temperature_slider], None)
435
+ top_p_slider.change(set_top_p, [current_model, top_p_slider], None)
436
+ n_choices_slider.change(set_n_choices, [current_model, n_choices_slider], None)
437
+ stop_sequence_txt.change(set_stop_sequence, [current_model, stop_sequence_txt], None)
438
+ max_generation_slider.change(set_max_tokens, [current_model, max_generation_slider], None)
439
+ presence_penalty_slider.change(set_presence_penalty, [current_model, presence_penalty_slider], None)
440
+ frequency_penalty_slider.change(set_frequency_penalty, [current_model, frequency_penalty_slider], None)
441
+ logit_bias_txt.change(set_logit_bias, [current_model, logit_bias_txt], None)
442
+ user_identifier_txt.change(set_user_identifier, [current_model, user_identifier_txt], None)
443
+
444
+ default_btn.click(
445
+ reset_default, [], [apihostTxt, proxyTxt, status_display], show_progress=True
446
+ )
447
+ changeAPIURLBtn.click(
448
+ change_api_host,
449
+ [apihostTxt],
450
+ [status_display],
451
+ show_progress=True,
452
+ )
453
+ changeProxyBtn.click(
454
+ change_proxy,
455
+ [proxyTxt],
456
+ [status_display],
457
+ show_progress=True,
458
+ )
459
+
460
+ logging.info(
461
+ colorama.Back.GREEN
462
+ + "\n川虎的温馨提示:访问 http://localhost:7860 查看界面"
463
+ + colorama.Style.RESET_ALL
464
+ )
465
+ # 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
466
+ demo.title = i18n("川虎Chat 🚀")
467
+
468
+ if __name__ == "__main__":
469
+ reload_javascript()
470
+ demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
471
+ blocked_paths=["config.json"],
472
+ favicon_path="./assets/favicon.ico"
473
+ )
Dockerfile ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.9 as builder
2
+ RUN apt-get update && apt-get install -y build-essential
3
+ COPY requirements.txt .
4
+ COPY requirements_advanced.txt .
5
+ RUN pip install --user -r requirements.txt
6
+ # RUN pip install --user -r requirements_advanced.txt
7
+
8
+ FROM python:3.9
9
+ MAINTAINER iskoldt
10
+ COPY --from=builder /root/.local /root/.local
11
+ ENV PATH=/root/.local/bin:$PATH
12
+ COPY . /app
13
+ WORKDIR /app
14
+ ENV dockerrun yes
15
+ CMD ["python3", "-u", "ChuanhuChatbot.py", "2>&1", "|", "tee", "/var/log/application.log"]
LICENSE ADDED
@@ -0,0 +1,674 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
+
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
+
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
+
68
+ The precise terms and conditions for copying, distribution and
69
+ modification follow.
70
+
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
+ this License.
486
+
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
+ otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
567
+ be similar in spirit to the present version, but may differ in detail to
568
+ address new problems or concerns.
569
+
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <https://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <https://www.gnu.org/licenses/why-not-lgpl.html>.
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: ChuanhuChatGPT
3
+ emoji: 🐯
4
+ colorFrom: green
5
+ colorTo: red
6
+ sdk: gradio
7
+ sdk_version: 3.33.1
8
+ app_file: ChuanhuChatbot.py
9
+ pinned: false
10
+ license: gpl-3.0
11
+ duplicated_from: JohnSmith9982/ChuanhuChatGPT
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
assets/Kelpy-Codos.js ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // ==UserScript==
2
+ // @name Kelpy Codos
3
+ // @namespace https://github.com/Keldos-Li/Kelpy-Codos
4
+ // @version 1.0.5
5
+ // @author Keldos; https://keldos.me/
6
+ // @description Add copy button to PRE tags before CODE tag, for Chuanhu ChatGPT especially.
7
+ // Based on Chuanhu ChatGPT version: ac04408 (2023-3-22)
8
+ // @license GPL-3.0
9
+ // @grant none
10
+ // ==/UserScript==
11
+
12
+ (function () {
13
+ 'use strict';
14
+
15
+ function addCopyButton(pre) {
16
+ var code = pre.querySelector('code');
17
+ if (!code) {
18
+ return; // 如果没有找到 <code> 元素,则不添加按钮
19
+ }
20
+ var firstChild = code.firstChild;
21
+ if (!firstChild) {
22
+ return; // 如果 <code> 元素没有子节点,则不添加按钮
23
+ }
24
+ var button = document.createElement('button');
25
+ button.textContent = '\uD83D\uDCCE'; // 使用 📎 符号作为“复制”按钮的文本
26
+ button.style.position = 'relative';
27
+ button.style.float = 'right';
28
+ button.style.fontSize = '1em'; // 可选:调整按钮大小
29
+ button.style.background = 'none'; // 可选:去掉背景颜色
30
+ button.style.border = 'none'; // 可选:去掉边框
31
+ button.style.cursor = 'pointer'; // 可选:显示指针样式
32
+ button.addEventListener('click', function () {
33
+ var range = document.createRange();
34
+ range.selectNodeContents(code);
35
+ range.setStartBefore(firstChild); // 将范围设置为第一个子节点之前
36
+ var selection = window.getSelection();
37
+ selection.removeAllRanges();
38
+ selection.addRange(range);
39
+
40
+ try {
41
+ var success = document.execCommand('copy');
42
+ if (success) {
43
+ button.textContent = '\u2714';
44
+ setTimeout(function () {
45
+ button.textContent = '\uD83D\uDCCE'; // 恢复按钮为“复制”
46
+ }, 2000);
47
+ } else {
48
+ button.textContent = '\u2716';
49
+ }
50
+ } catch (e) {
51
+ console.error(e);
52
+ button.textContent = '\u2716';
53
+ }
54
+
55
+ selection.removeAllRanges();
56
+ });
57
+ code.insertBefore(button, firstChild); // 将按钮插入到第一个子元素之前
58
+ }
59
+
60
+ function handleNewElements(mutationsList, observer) {
61
+ for (var mutation of mutationsList) {
62
+ if (mutation.type === 'childList') {
63
+ for (var node of mutation.addedNodes) {
64
+ if (node.nodeName === 'PRE') {
65
+ addCopyButton(node);
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+
72
+ var observer = new MutationObserver(handleNewElements);
73
+ observer.observe(document.documentElement, { childList: true, subtree: true });
74
+
75
+ document.querySelectorAll('pre').forEach(addCopyButton);
76
+ })();
assets/custom.css ADDED
@@ -0,0 +1,468 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --chatbot-color-light: #000000;
3
+ --chatbot-color-dark: #FFFFFF;
4
+ --chatbot-background-color-light: #F3F3F3;
5
+ --chatbot-background-color-dark: #121111;
6
+ --message-user-background-color-light: #95EC69;
7
+ --message-user-background-color-dark: #26B561;
8
+ --message-bot-background-color-light: #FFFFFF;
9
+ --message-bot-background-color-dark: #2C2C2C;
10
+ }
11
+
12
+ #app_title {
13
+ font-weight: var(--prose-header-text-weight);
14
+ font-size: var(--text-xxl);
15
+ line-height: 1.3;
16
+ text-align: left;
17
+ margin-top: 6px;
18
+ white-space: nowrap;
19
+ }
20
+ #description {
21
+ text-align: center;
22
+ margin: 32px 0 4px 0;
23
+ }
24
+
25
+ /* gradio的页脚信息 */
26
+ footer {
27
+ /* display: none !important; */
28
+ margin-top: .2em !important;
29
+ font-size: 85%;
30
+ }
31
+ #footer {
32
+ text-align: center;
33
+ }
34
+ #footer div {
35
+ display: inline-block;
36
+ }
37
+ #footer .versions{
38
+ font-size: 85%;
39
+ opacity: 0.60;
40
+ }
41
+
42
+ #float_display {
43
+ position: absolute;
44
+ max-height: 30px;
45
+ }
46
+ /* user_info */
47
+ #user_info {
48
+ white-space: nowrap;
49
+ position: absolute; left: 8em; top: .2em;
50
+ z-index: var(--layer-2);
51
+ box-shadow: var(--block-shadow);
52
+ border: none; border-radius: var(--block-label-radius);
53
+ background: var(--color-accent);
54
+ padding: var(--block-label-padding);
55
+ font-size: var(--block-label-text-size); line-height: var(--line-sm);
56
+ width: auto; min-height: 30px!important;
57
+ opacity: 1;
58
+ transition: opacity 0.3s ease-in-out;
59
+ }
60
+ #user_info .wrap {
61
+ opacity: 0;
62
+ }
63
+ #user_info p {
64
+ color: white;
65
+ font-weight: var(--block-label-text-weight);
66
+ }
67
+ #user_info.hideK {
68
+ opacity: 0;
69
+ transition: opacity 1s ease-in-out;
70
+ }
71
+
72
+ /* status_display */
73
+ #status_display {
74
+ display: flex;
75
+ min-height: 2em;
76
+ align-items: flex-end;
77
+ justify-content: flex-end;
78
+ }
79
+ #status_display p {
80
+ font-size: .85em;
81
+ font-family: ui-monospace, "SF Mono", "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", "Microsoft Yahei UI", "Microsoft Yahei", monospace;
82
+ /* Windows下中文的monospace会fallback为新宋体,实在太丑,这里折中使用微软雅黑 */
83
+ color: var(--body-text-color-subdued);
84
+ }
85
+
86
+ #status_display {
87
+ transition: all 0.6s;
88
+ }
89
+ #chuanhu_chatbot {
90
+ transition: height 0.3s ease;
91
+ }
92
+
93
+ /* usage_display */
94
+ .insert_block {
95
+ position: relative;
96
+ margin: 0;
97
+ padding: .5em 1em;
98
+ box-shadow: var(--block-shadow);
99
+ border-width: var(--block-border-width);
100
+ border-color: var(--block-border-color);
101
+ border-radius: var(--block-radius);
102
+ background: var(--block-background-fill);
103
+ width: 100%;
104
+ line-height: var(--line-sm);
105
+ min-height: 2em;
106
+ }
107
+ #usage_display p, #usage_display span {
108
+ margin: 0;
109
+ font-size: .85em;
110
+ color: var(--body-text-color-subdued);
111
+ }
112
+ .progress-bar {
113
+ background-color: var(--input-background-fill);;
114
+ margin: .5em 0 !important;
115
+ height: 20px;
116
+ border-radius: 10px;
117
+ overflow: hidden;
118
+ }
119
+ .progress {
120
+ background-color: var(--block-title-background-fill);
121
+ height: 100%;
122
+ border-radius: 10px;
123
+ text-align: right;
124
+ transition: width 0.5s ease-in-out;
125
+ }
126
+ .progress-text {
127
+ /* color: white; */
128
+ color: var(--color-accent) !important;
129
+ font-size: 1em !important;
130
+ font-weight: bold;
131
+ padding-right: 10px;
132
+ line-height: 20px;
133
+ }
134
+
135
+ .apSwitch {
136
+ top: 2px;
137
+ display: inline-block;
138
+ height: 24px;
139
+ position: relative;
140
+ width: 48px;
141
+ border-radius: 12px;
142
+ }
143
+ .apSwitch input {
144
+ display: none !important;
145
+ }
146
+ .apSlider {
147
+ background-color: var(--neutral-200);
148
+ bottom: 0;
149
+ cursor: pointer;
150
+ left: 0;
151
+ position: absolute;
152
+ right: 0;
153
+ top: 0;
154
+ transition: .4s;
155
+ font-size: 18px;
156
+ border-radius: 12px;
157
+ }
158
+ .apSlider::before {
159
+ bottom: -1.5px;
160
+ left: 1px;
161
+ position: absolute;
162
+ transition: .4s;
163
+ content: "🌞";
164
+ }
165
+ input:checked + .apSlider {
166
+ background-color: var(--primary-600);
167
+ }
168
+ input:checked + .apSlider::before {
169
+ transform: translateX(23px);
170
+ content:"🌚";
171
+ }
172
+
173
+ /* Override Slider Styles (for webkit browsers like Safari and Chrome)
174
+ * 好希望这份提案能早日实现 https://github.com/w3c/csswg-drafts/issues/4410
175
+ * 进度滑块在各个平台还是太不统一了
176
+ */
177
+ input[type="range"] {
178
+ -webkit-appearance: none;
179
+ height: 4px;
180
+ background: var(--input-background-fill);
181
+ border-radius: 5px;
182
+ background-image: linear-gradient(var(--primary-500),var(--primary-500));
183
+ background-size: 0% 100%;
184
+ background-repeat: no-repeat;
185
+ }
186
+ input[type="range"]::-webkit-slider-thumb {
187
+ -webkit-appearance: none;
188
+ height: 20px;
189
+ width: 20px;
190
+ border-radius: 50%;
191
+ border: solid 0.5px #ddd;
192
+ background-color: white;
193
+ cursor: ew-resize;
194
+ box-shadow: var(--input-shadow);
195
+ transition: background-color .1s ease;
196
+ }
197
+ input[type="range"]::-webkit-slider-thumb:hover {
198
+ background: var(--neutral-50);
199
+ }
200
+ input[type=range]::-webkit-slider-runnable-track {
201
+ -webkit-appearance: none;
202
+ box-shadow: none;
203
+ border: none;
204
+ background: transparent;
205
+ }
206
+
207
+ #submit_btn, #cancel_btn {
208
+ height: 42px !important;
209
+ }
210
+ #submit_btn::before {
211
+ content: url("data:image/svg+xml, %3Csvg width='21px' height='20px' viewBox='0 0 21 20' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='page' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='send' transform='translate(0.435849, 0.088463)' fill='%23FFFFFF' fill-rule='nonzero'%3E %3Cpath d='M0.579148261,0.0428666046 C0.301105539,-0.0961547561 -0.036517765,0.122307382 0.0032026237,0.420210298 L1.4927172,18.1553639 C1.5125774,18.4334066 1.79062012,18.5922882 2.04880264,18.4929872 L8.24518329,15.8913017 L11.6412765,19.7441794 C11.8597387,19.9825018 12.2370824,19.8832008 12.3165231,19.5852979 L13.9450591,13.4882182 L19.7839562,11.0255541 C20.0619989,10.8865327 20.0818591,10.4694687 19.7839562,10.3105871 L0.579148261,0.0428666046 Z M11.6138902,17.0883151 L9.85385903,14.7195502 L0.718169621,0.618812241 L12.69945,12.9346347 L11.6138902,17.0883151 Z' id='shape'%3E%3C/path%3E %3C/g%3E %3C/g%3E %3C/svg%3E");
212
+ height: 21px;
213
+ }
214
+ #cancel_btn::before {
215
+ content: url("data:image/svg+xml,%3Csvg width='21px' height='21px' viewBox='0 0 21 21' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3E %3Cg id='pg' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cpath d='M10.2072007,20.088463 C11.5727865,20.088463 12.8594566,19.8259823 14.067211,19.3010209 C15.2749653,18.7760595 16.3386126,18.0538087 17.2581528,17.1342685 C18.177693,16.2147282 18.8982283,15.1527965 19.4197586,13.9484733 C19.9412889,12.7441501 20.202054,11.4557644 20.202054,10.0833163 C20.202054,8.71773046 19.9395733,7.43106036 19.4146119,6.22330603 C18.8896505,5.01555169 18.1673997,3.95018885 17.2478595,3.0272175 C16.3283192,2.10424615 15.2646719,1.3837109 14.0569176,0.865611739 C12.8491633,0.34751258 11.5624932,0.088463 10.1969073,0.088463 C8.83132146,0.088463 7.54636692,0.34751258 6.34204371,0.865611739 C5.1377205,1.3837109 4.07407321,2.10424615 3.15110186,3.0272175 C2.22813051,3.95018885 1.5058797,5.01555169 0.984349419,6.22330603 C0.46281914,7.43106036 0.202054,8.71773046 0.202054,10.0833163 C0.202054,11.4557644 0.4645347,12.7441501 0.9894961,13.9484733 C1.5144575,15.1527965 2.23670831,16.2147282 3.15624854,17.1342685 C4.07578877,18.0538087 5.1377205,18.7760595 6.34204371,19.3010209 C7.54636692,19.8259823 8.83475258,20.088463 10.2072007,20.088463 Z M10.2072007,18.2562448 C9.07493099,18.2562448 8.01471483,18.0452309 7.0265522,17.6232031 C6.03838956,17.2011753 5.17031614,16.6161693 4.42233192,15.8681851 C3.6743477,15.1202009 3.09105726,14.2521274 2.67246059,13.2639648 C2.25386392,12.2758022 2.04456558,11.215586 2.04456558,10.0833163 C2.04456558,8.95104663 2.25386392,7.89083047 2.67246059,6.90266784 C3.09105726,5.9145052 3.6743477,5.04643178 4.42233192,4.29844756 C5.17031614,3.55046334 6.036674,2.9671729 7.02140552,2.54857623 C8.00613703,2.12997956 9.06463763,1.92068122 10.1969073,1.92068122 C11.329177,1.92068122 12.3911087,2.12997956 13.3827025,2.54857623 C14.3742962,2.9671729 15.2440852,3.55046334 15.9920694,4.29844756 C16.7400537,5.04643178 17.3233441,5.9145052 17.7419408,6.90266784 C18.1605374,7.89083047 18.3698358,8.95104663 18.3698358,10.0833163 C18.3698358,11.215586 18.1605374,12.2758022 17.7419408,13.2639648 C17.3233441,14.2521274 16.7400537,15.1202009 15.9920694,15.8681851 C15.2440852,16.6161693 14.3760118,17.2011753 13.3878492,17.6232031 C12.3996865,18.0452309 11.3394704,18.2562448 10.2072007,18.2562448 Z M7.65444721,13.6242324 L12.7496608,13.6242324 C13.0584616,13.6242324 13.3003556,13.5384544 13.4753427,13.3668984 C13.6503299,13.1953424 13.7378234,12.9585951 13.7378234,12.6566565 L13.7378234,7.49968276 C13.7378234,7.19774418 13.6503299,6.96099688 13.4753427,6.78944087 C13.3003556,6.61788486 13.0584616,6.53210685 12.7496608,6.53210685 L7.65444721,6.53210685 C7.33878414,6.53210685 7.09345904,6.61788486 6.91847191,6.78944087 C6.74348478,6.96099688 6.65599121,7.19774418 6.65599121,7.49968276 L6.65599121,12.6566565 C6.65599121,12.9585951 6.74348478,13.1953424 6.91847191,13.3668984 C7.09345904,13.5384544 7.33878414,13.6242324 7.65444721,13.6242324 Z' id='shape' fill='%23FF3B30' fill-rule='nonzero'%3E%3C/path%3E %3C/g%3E %3C/svg%3E");
216
+ height: 21px;
217
+ }
218
+ /* list */
219
+ ol:not(.options), ul:not(.options) {
220
+ padding-inline-start: 2em !important;
221
+ }
222
+
223
+ /* 亮色(默认) */
224
+ #chuanhu_chatbot {
225
+ background-color: var(--chatbot-background-color-light) !important;
226
+ color: var(--chatbot-color-light) !important;
227
+ }
228
+ [data-testid = "bot"] {
229
+ background-color: var(--message-bot-background-color-light) !important;
230
+ }
231
+ [data-testid = "user"] {
232
+ background-color: var(--message-user-background-color-light) !important;
233
+ }
234
+ /* 暗色 */
235
+ .dark #chuanhu_chatbot {
236
+ background-color: var(--chatbot-background-color-dark) !important;
237
+ color: var(--chatbot-color-dark) !important;
238
+ }
239
+ .dark [data-testid = "bot"] {
240
+ background-color: var(--message-bot-background-color-dark) !important;
241
+ }
242
+ .dark [data-testid = "user"] {
243
+ background-color: var(--message-user-background-color-dark) !important;
244
+ }
245
+
246
+ /* 屏幕宽度大于等于500px的设备 */
247
+ /* update on 2023.4.8: 高度的细致调整已写入JavaScript */
248
+ @media screen and (min-width: 500px) {
249
+ #chuanhu_chatbot {
250
+ height: calc(100vh - 200px);
251
+ }
252
+ #chuanhu_chatbot .wrap {
253
+ max-height: calc(100vh - 200px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
254
+ }
255
+ }
256
+ /* 屏幕宽度小于500px的设备 */
257
+ @media screen and (max-width: 499px) {
258
+ #chuanhu_chatbot {
259
+ height: calc(100vh - 140px);
260
+ }
261
+ #chuanhu_chatbot .wrap {
262
+ max-height: calc(100vh - 140px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
263
+ }
264
+ [data-testid = "bot"] {
265
+ max-width: 95% !important;
266
+ }
267
+ #app_title h1{
268
+ letter-spacing: -1px; font-size: 22px;
269
+ }
270
+ }
271
+ #chuanhu_chatbot .wrap {
272
+ overflow-x: hidden;
273
+ }
274
+ /* 对话气泡 */
275
+ .message {
276
+ border-radius: var(--radius-xl) !important;
277
+ border: none;
278
+ padding: var(--spacing-xl) !important;
279
+ font-size: var(--text-md) !important;
280
+ line-height: var(--line-md) !important;
281
+ min-height: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl));
282
+ min-width: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl));
283
+ }
284
+ [data-testid = "bot"] {
285
+ max-width: 85%;
286
+ border-bottom-left-radius: 0 !important;
287
+ }
288
+ [data-testid = "user"] {
289
+ max-width: 85%;
290
+ width: auto !important;
291
+ border-bottom-right-radius: 0 !important;
292
+ }
293
+
294
+ .message.user p {
295
+ white-space: pre-wrap;
296
+ }
297
+ .message .user-message {
298
+ display: block;
299
+ padding: 0 !important;
300
+ white-space: pre-wrap;
301
+ }
302
+
303
+ .message .md-message p {
304
+ margin-top: 0.6em !important;
305
+ margin-bottom: 0.6em !important;
306
+ }
307
+ .message .md-message p:first-child { margin-top: 0 !important; }
308
+ .message .md-message p:last-of-type { margin-bottom: 0 !important; }
309
+
310
+ .message .md-message {
311
+ display: block;
312
+ padding: 0 !important;
313
+ }
314
+ .message .raw-message p {
315
+ margin:0 !important;
316
+ }
317
+ .message .raw-message {
318
+ display: block;
319
+ padding: 0 !important;
320
+ white-space: pre-wrap;
321
+ }
322
+ .raw-message.hideM, .md-message.hideM {
323
+ display: none;
324
+ }
325
+
326
+ /* custom buttons */
327
+ .chuanhu-btn {
328
+ border-radius: 5px;
329
+ /* background-color: #E6E6E6 !important; */
330
+ color: rgba(120, 120, 120, 0.64) !important;
331
+ padding: 4px !important;
332
+ position: absolute;
333
+ right: -22px;
334
+ cursor: pointer !important;
335
+ transition: color .2s ease, background-color .2s ease;
336
+ }
337
+ .chuanhu-btn:hover {
338
+ background-color: rgba(167, 167, 167, 0.25) !important;
339
+ color: unset !important;
340
+ }
341
+ .chuanhu-btn:active {
342
+ background-color: rgba(167, 167, 167, 0.5) !important;
343
+ }
344
+ .chuanhu-btn:focus {
345
+ outline: none;
346
+ }
347
+ .copy-bot-btn {
348
+ /* top: 18px; */
349
+ bottom: 0;
350
+ }
351
+ .toggle-md-btn {
352
+ /* top: 0; */
353
+ bottom: 20px;
354
+ }
355
+ .copy-code-btn {
356
+ position: relative;
357
+ float: right;
358
+ font-size: 1em;
359
+ cursor: pointer;
360
+ }
361
+
362
+ .message-wrap>div img{
363
+ border-radius: 10px !important;
364
+ }
365
+
366
+ /* history message */
367
+ .wrap>.history-message {
368
+ padding: 10px !important;
369
+ }
370
+ .history-message {
371
+ /* padding: 0 !important; */
372
+ opacity: 80%;
373
+ display: flex;
374
+ flex-direction: column;
375
+ }
376
+ .history-message>.history-message {
377
+ padding: 0 !important;
378
+ }
379
+ .history-message>.message-wrap {
380
+ padding: 0 !important;
381
+ margin-bottom: 16px;
382
+ }
383
+ .history-message>.message {
384
+ margin-bottom: 16px;
385
+ }
386
+ .wrap>.history-message::after {
387
+ content: "";
388
+ display: block;
389
+ height: 2px;
390
+ background-color: var(--body-text-color-subdued);
391
+ margin-bottom: 10px;
392
+ margin-top: -10px;
393
+ clear: both;
394
+ }
395
+ .wrap>.history-message>:last-child::after {
396
+ content: "仅供查看";
397
+ display: block;
398
+ text-align: center;
399
+ color: var(--body-text-color-subdued);
400
+ font-size: 0.8em;
401
+ }
402
+
403
+ /* 表格 */
404
+ table {
405
+ margin: 1em 0;
406
+ border-collapse: collapse;
407
+ empty-cells: show;
408
+ }
409
+ td,th {
410
+ border: 1.2px solid var(--border-color-primary) !important;
411
+ padding: 0.2em;
412
+ }
413
+ thead {
414
+ background-color: rgba(175,184,193,0.2);
415
+ }
416
+ thead th {
417
+ padding: .5em .2em;
418
+ }
419
+ /* 行内代码 */
420
+ .message :not(pre) code {
421
+ display: inline;
422
+ white-space: break-spaces;
423
+ font-family: var(--font-mono);
424
+ border-radius: 6px;
425
+ margin: 0 2px 0 2px;
426
+ padding: .2em .4em .1em .4em;
427
+ background-color: rgba(175,184,193,0.2);
428
+ }
429
+ /* 代码块 */
430
+ .message pre,
431
+ .message pre[class*=language-] {
432
+ color: #fff;
433
+ overflow-x: auto;
434
+ overflow-y: hidden;
435
+ margin: .8em 1em 1em 0em !important;
436
+ padding: var(--spacing-xl) 1.2em !important;
437
+ border-radius: var(--radius-lg) !important;
438
+ }
439
+ .message pre code,
440
+ .message pre code[class*=language-] {
441
+ color: #fff;
442
+ padding: 0;
443
+ margin: 0;
444
+ background-color: unset;
445
+ text-shadow: none;
446
+ font-family: var(--font-mono);
447
+ }
448
+ /* 覆盖 gradio 丑陋���复制按钮样式 */
449
+ pre button[title="copy"] {
450
+ border-radius: 5px;
451
+ transition: background-color .2s ease;
452
+ }
453
+ pre button[title="copy"]:hover {
454
+ background-color: #333232;
455
+ }
456
+ pre button .check {
457
+ color: #fff !important;
458
+ background: var(--neutral-950) !important;
459
+ }
460
+
461
+ /* 覆盖prism.css */
462
+ .language-css .token.string,
463
+ .style .token.string,
464
+ .token.entity,
465
+ .token.operator,
466
+ .token.url {
467
+ background: none !important;
468
+ }
assets/custom.js ADDED
@@ -0,0 +1,502 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ // custom javascript here
3
+
4
+ const MAX_HISTORY_LENGTH = 32;
5
+
6
+ var key_down_history = [];
7
+ var currentIndex = -1;
8
+ var user_input_ta;
9
+
10
+ var gradioContainer = null;
11
+ var user_input_ta = null;
12
+ var user_input_tb = null;
13
+ var userInfoDiv = null;
14
+ var appTitleDiv = null;
15
+ var chatbot = null;
16
+ var chatbotWrap = null;
17
+ var apSwitch = null;
18
+ var empty_botton = null;
19
+ var messageBotDivs = null;
20
+ var loginUserForm = null;
21
+ var logginUser = null;
22
+
23
+ var userLogged = false;
24
+ var usernameGotten = false;
25
+ var historyLoaded = false;
26
+
27
+ var ga = document.getElementsByTagName("gradio-app");
28
+ var targetNode = ga[0];
29
+ var isInIframe = (window.self !== window.top);
30
+ var language = navigator.language.slice(0,2);
31
+
32
+ var forView_i18n = {
33
+ 'zh': "仅供查看",
34
+ 'en': "For viewing only",
35
+ 'ja': "閲覧専用",
36
+ 'fr': "Pour consultation seulement",
37
+ 'es': "Solo para visualización",
38
+ };
39
+
40
+ // gradio 页面加载好了么??? 我能动你的元素了么??
41
+ function gradioLoaded(mutations) {
42
+ for (var i = 0; i < mutations.length; i++) {
43
+ if (mutations[i].addedNodes.length) {
44
+ loginUserForm = document.querySelector(".gradio-container > .main > .wrap > .panel > .form")
45
+ gradioContainer = document.querySelector(".gradio-container");
46
+ user_input_tb = document.getElementById('user_input_tb');
47
+ userInfoDiv = document.getElementById("user_info");
48
+ appTitleDiv = document.getElementById("app_title");
49
+ chatbot = document.querySelector('#chuanhu_chatbot');
50
+ chatbotWrap = document.querySelector('#chuanhu_chatbot > .wrap');
51
+ apSwitch = document.querySelector('.apSwitch input[type="checkbox"]');
52
+ empty_botton = document.getElementById("empty_btn")
53
+
54
+ if (loginUserForm) {
55
+ localStorage.setItem("userLogged", true);
56
+ userLogged = true;
57
+ }
58
+
59
+ if (gradioContainer && apSwitch) { // gradioCainter 加载出来了没?
60
+ adjustDarkMode();
61
+ }
62
+ if (user_input_tb) { // user_input_tb 加载出来了没?
63
+ selectHistory();
64
+ }
65
+ if (userInfoDiv && appTitleDiv) { // userInfoDiv 和 appTitleDiv 加载出来了没?
66
+ if (!usernameGotten) {
67
+ getUserInfo();
68
+ }
69
+ setTimeout(showOrHideUserInfo(), 2000);
70
+ }
71
+ if (chatbot) { // chatbot 加载出来了没?
72
+ setChatbotHeight();
73
+ }
74
+ if (chatbotWrap) {
75
+ if (!historyLoaded) {
76
+ loadHistoryHtml();
77
+ }
78
+ setChatbotScroll();
79
+ }
80
+ if (empty_botton) {
81
+ emptyHistory();
82
+ }
83
+ }
84
+ }
85
+ }
86
+
87
+ function webLocale() {
88
+ console.log("webLocale", language);
89
+ if (forView_i18n.hasOwnProperty(language)) {
90
+ var forView = forView_i18n[language];
91
+ var forViewStyle = document.createElement('style');
92
+ forViewStyle.innerHTML = '.wrap>.history-message>:last-child::after { content: "' + forView + '"!important; }';
93
+ document.head.appendChild(forViewStyle);
94
+ // console.log("added forViewStyle", forView);
95
+ }
96
+ }
97
+
98
+ function selectHistory() {
99
+ user_input_ta = user_input_tb.querySelector("textarea");
100
+ if (user_input_ta) {
101
+ observer.disconnect(); // 停止监听
102
+ // 在 textarea 上监听 keydown 事件
103
+ user_input_ta.addEventListener("keydown", function (event) {
104
+ var value = user_input_ta.value.trim();
105
+ // 判断按下的是否为方向键
106
+ if (event.code === 'ArrowUp' || event.code === 'ArrowDown') {
107
+ // 如果按下的是方向键,且输入框中有内容,且历史记录中没有该内容,则不执行操作
108
+ if (value && key_down_history.indexOf(value) === -1)
109
+ return;
110
+ // 对于需要响应的动作,阻止默认行为。
111
+ event.preventDefault();
112
+ var length = key_down_history.length;
113
+ if (length === 0) {
114
+ currentIndex = -1; // 如果历史记录为空,直接将当前选中的记录重置
115
+ return;
116
+ }
117
+ if (currentIndex === -1) {
118
+ currentIndex = length;
119
+ }
120
+ if (event.code === 'ArrowUp' && currentIndex > 0) {
121
+ currentIndex--;
122
+ user_input_ta.value = key_down_history[currentIndex];
123
+ } else if (event.code === 'ArrowDown' && currentIndex < length - 1) {
124
+ currentIndex++;
125
+ user_input_ta.value = key_down_history[currentIndex];
126
+ }
127
+ user_input_ta.selectionStart = user_input_ta.value.length;
128
+ user_input_ta.selectionEnd = user_input_ta.value.length;
129
+ const input_event = new InputEvent("input", { bubbles: true, cancelable: true });
130
+ user_input_ta.dispatchEvent(input_event);
131
+ } else if (event.code === "Enter") {
132
+ if (value) {
133
+ currentIndex = -1;
134
+ if (key_down_history.indexOf(value) === -1) {
135
+ key_down_history.push(value);
136
+ if (key_down_history.length > MAX_HISTORY_LENGTH) {
137
+ key_down_history.shift();
138
+ }
139
+ }
140
+ }
141
+ }
142
+ });
143
+ }
144
+ }
145
+
146
+ var username = null;
147
+ function getUserInfo() {
148
+ if (usernameGotten) {
149
+ return;
150
+ }
151
+ userLogged = localStorage.getItem('userLogged');
152
+ if (userLogged) {
153
+ username = userInfoDiv.innerText;
154
+ if (username) {
155
+ if (username.includes("getting user info…")) {
156
+ setTimeout(getUserInfo, 500);
157
+ return;
158
+ } else if (username === " ") {
159
+ localStorage.removeItem("username");
160
+ localStorage.removeItem("userLogged")
161
+ userLogged = false;
162
+ usernameGotten = true;
163
+ return;
164
+ } else {
165
+ username = username.match(/User:\s*(.*)/)[1] || username;
166
+ localStorage.setItem("username", username);
167
+ usernameGotten = true;
168
+ clearHistoryHtml();
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ function toggleUserInfoVisibility(shouldHide) {
175
+ if (userInfoDiv) {
176
+ if (shouldHide) {
177
+ userInfoDiv.classList.add("hideK");
178
+ } else {
179
+ userInfoDiv.classList.remove("hideK");
180
+ }
181
+ }
182
+ }
183
+ function showOrHideUserInfo() {
184
+ var sendBtn = document.getElementById("submit_btn");
185
+
186
+ // Bind mouse/touch events to show/hide user info
187
+ appTitleDiv.addEventListener("mouseenter", function () {
188
+ toggleUserInfoVisibility(false);
189
+ });
190
+ userInfoDiv.addEventListener("mouseenter", function () {
191
+ toggleUserInfoVisibility(false);
192
+ });
193
+ sendBtn.addEventListener("mouseenter", function () {
194
+ toggleUserInfoVisibility(false);
195
+ });
196
+
197
+ appTitleDiv.addEventListener("mouseleave", function () {
198
+ toggleUserInfoVisibility(true);
199
+ });
200
+ userInfoDiv.addEventListener("mouseleave", function () {
201
+ toggleUserInfoVisibility(true);
202
+ });
203
+ sendBtn.addEventListener("mouseleave", function () {
204
+ toggleUserInfoVisibility(true);
205
+ });
206
+
207
+ appTitleDiv.ontouchstart = function () {
208
+ toggleUserInfoVisibility(false);
209
+ };
210
+ userInfoDiv.ontouchstart = function () {
211
+ toggleUserInfoVisibility(false);
212
+ };
213
+ sendBtn.ontouchstart = function () {
214
+ toggleUserInfoVisibility(false);
215
+ };
216
+
217
+ appTitleDiv.ontouchend = function () {
218
+ setTimeout(function () {
219
+ toggleUserInfoVisibility(true);
220
+ }, 3000);
221
+ };
222
+ userInfoDiv.ontouchend = function () {
223
+ setTimeout(function () {
224
+ toggleUserInfoVisibility(true);
225
+ }, 3000);
226
+ };
227
+ sendBtn.ontouchend = function () {
228
+ setTimeout(function () {
229
+ toggleUserInfoVisibility(true);
230
+ }, 3000); // Delay 1 second to hide user info
231
+ };
232
+
233
+ // Hide user info after 2 second
234
+ setTimeout(function () {
235
+ toggleUserInfoVisibility(true);
236
+ }, 2000);
237
+ }
238
+
239
+ function toggleDarkMode(isEnabled) {
240
+ if (isEnabled) {
241
+ document.body.classList.add("dark");
242
+ document.body.style.setProperty("background-color", "var(--neutral-950)", "important");
243
+ } else {
244
+ document.body.classList.remove("dark");
245
+ document.body.style.backgroundColor = "";
246
+ }
247
+ }
248
+ function adjustDarkMode() {
249
+ const darkModeQuery = window.matchMedia("(prefers-color-scheme: dark)");
250
+
251
+ // 根据当前颜色模式设置初始状态
252
+ apSwitch.checked = darkModeQuery.matches;
253
+ toggleDarkMode(darkModeQuery.matches);
254
+ // 监听颜色模式变化
255
+ darkModeQuery.addEventListener("change", (e) => {
256
+ apSwitch.checked = e.matches;
257
+ toggleDarkMode(e.matches);
258
+ });
259
+ // apSwitch = document.querySelector('.apSwitch input[type="checkbox"]');
260
+ apSwitch.addEventListener("change", (e) => {
261
+ toggleDarkMode(e.target.checked);
262
+ });
263
+ }
264
+
265
+ function setChatbotHeight() {
266
+ const screenWidth = window.innerWidth;
267
+ const statusDisplay = document.querySelector('#status_display');
268
+ const statusDisplayHeight = statusDisplay ? statusDisplay.offsetHeight : 0;
269
+ const wrap = chatbot.querySelector('.wrap');
270
+ const vh = window.innerHeight * 0.01;
271
+ document.documentElement.style.setProperty('--vh', `${vh}px`);
272
+ if (isInIframe) {
273
+ chatbot.style.height = `700px`;
274
+ wrap.style.maxHeight = `calc(700px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`
275
+ } else {
276
+ if (screenWidth <= 320) {
277
+ chatbot.style.height = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 150}px)`;
278
+ wrap.style.maxHeight = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 150}px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`;
279
+ } else if (screenWidth <= 499) {
280
+ chatbot.style.height = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 100}px)`;
281
+ wrap.style.maxHeight = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 100}px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`;
282
+ } else {
283
+ chatbot.style.height = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 160}px)`;
284
+ wrap.style.maxHeight = `calc(var(--vh, 1vh) * 100 - ${statusDisplayHeight + 160}px - var(--line-sm) * 1rem - 2 * var(--block-label-margin))`;
285
+ }
286
+ }
287
+ }
288
+ function setChatbotScroll() {
289
+ var scrollHeight = chatbotWrap.scrollHeight;
290
+ chatbotWrap.scrollTo(0,scrollHeight)
291
+ }
292
+ var rangeInputs = null;
293
+ var numberInputs = null;
294
+ function setSlider() {
295
+ rangeInputs = document.querySelectorAll('input[type="range"]');
296
+ numberInputs = document.querySelectorAll('input[type="number"]')
297
+ setSliderRange();
298
+ rangeInputs.forEach(rangeInput => {
299
+ rangeInput.addEventListener('input', setSliderRange);
300
+ });
301
+ numberInputs.forEach(numberInput => {
302
+ numberInput.addEventListener('input', setSliderRange);
303
+ })
304
+ }
305
+ function setSliderRange() {
306
+ var range = document.querySelectorAll('input[type="range"]');
307
+ range.forEach(range => {
308
+ range.style.backgroundSize = (range.value - range.min) / (range.max - range.min) * 100 + '% 100%';
309
+ });
310
+ }
311
+
312
+ function addChuanhuButton(botElement) {
313
+ var rawMessage = null;
314
+ var mdMessage = null;
315
+ rawMessage = botElement.querySelector('.raw-message');
316
+ mdMessage = botElement.querySelector('.md-message');
317
+ if (!rawMessage) {
318
+ var buttons = botElement.querySelectorAll('button.chuanhu-btn');
319
+ for (var i = 0; i < buttons.length; i++) {
320
+ buttons[i].parentNode.removeChild(buttons[i]);
321
+ }
322
+ return;
323
+ }
324
+ var copyButton = null;
325
+ var toggleButton = null;
326
+ copyButton = botElement.querySelector('button.copy-bot-btn');
327
+ toggleButton = botElement.querySelector('button.toggle-md-btn');
328
+ if (copyButton) copyButton.remove();
329
+ if (toggleButton) toggleButton.remove();
330
+
331
+ // Copy bot button
332
+ var copyButton = document.createElement('button');
333
+ copyButton.classList.add('chuanhu-btn');
334
+ copyButton.classList.add('copy-bot-btn');
335
+ copyButton.setAttribute('aria-label', 'Copy');
336
+ copyButton.innerHTML = copyIcon;
337
+ copyButton.addEventListener('click', () => {
338
+ const textToCopy = rawMessage.innerText;
339
+ navigator.clipboard
340
+ .writeText(textToCopy)
341
+ .then(() => {
342
+ copyButton.innerHTML = copiedIcon;
343
+ setTimeout(() => {
344
+ copyButton.innerHTML = copyIcon;
345
+ }, 1500);
346
+ })
347
+ .catch(() => {
348
+ console.error("copy failed");
349
+ });
350
+ });
351
+ botElement.appendChild(copyButton);
352
+
353
+ // Toggle button
354
+ var toggleButton = document.createElement('button');
355
+ toggleButton.classList.add('chuanhu-btn');
356
+ toggleButton.classList.add('toggle-md-btn');
357
+ toggleButton.setAttribute('aria-label', 'Toggle');
358
+ var renderMarkdown = mdMessage.classList.contains('hideM');
359
+ toggleButton.innerHTML = renderMarkdown ? mdIcon : rawIcon;
360
+ toggleButton.addEventListener('click', () => {
361
+ renderMarkdown = mdMessage.classList.contains('hideM');
362
+ if (renderMarkdown){
363
+ renderMarkdownText(botElement);
364
+ toggleButton.innerHTML=rawIcon;
365
+ } else {
366
+ removeMarkdownText(botElement);
367
+ toggleButton.innerHTML=mdIcon;
368
+ }
369
+ });
370
+ botElement.insertBefore(toggleButton, copyButton);
371
+ }
372
+
373
+ function renderMarkdownText(message) {
374
+ var mdDiv = message.querySelector('.md-message');
375
+ if (mdDiv) mdDiv.classList.remove('hideM');
376
+ var rawDiv = message.querySelector('.raw-message');
377
+ if (rawDiv) rawDiv.classList.add('hideM');
378
+ }
379
+ function removeMarkdownText(message) {
380
+ var rawDiv = message.querySelector('.raw-message');
381
+ if (rawDiv) rawDiv.classList.remove('hideM');
382
+ var mdDiv = message.querySelector('.md-message');
383
+ if (mdDiv) mdDiv.classList.add('hideM');
384
+ }
385
+
386
+ let timeoutId;
387
+ let isThrottled = false;
388
+ var mmutation
389
+ // 监听所有元素中 bot message 的变化,为 bot 消息添加复制按钮。
390
+ var mObserver = new MutationObserver(function (mutationsList) {
391
+ for (mmutation of mutationsList) {
392
+ if (mmutation.type === 'childList') {
393
+ for (var node of mmutation.addedNodes) {
394
+ if (node.nodeType === 1 && node.classList.contains('message') && node.getAttribute('data-testid') === 'bot') {
395
+ saveHistoryHtml();
396
+ document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
397
+ }
398
+ if (node.tagName === 'INPUT' && node.getAttribute('type') === 'range') {
399
+ setSlider();
400
+ }
401
+ }
402
+ for (var node of mmutation.removedNodes) {
403
+ if (node.nodeType === 1 && node.classList.contains('message') && node.getAttribute('data-testid') === 'bot') {
404
+ saveHistoryHtml();
405
+ document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
406
+ }
407
+ }
408
+ } else if (mmutation.type === 'attributes') {
409
+ if (mmutation.target.nodeType === 1 && mmutation.target.classList.contains('message') && mmutation.target.getAttribute('data-testid') === 'bot') {
410
+ if (isThrottled) break; // 为了防止重复不断疯狂渲染,加上等待_(:з」∠)_
411
+ isThrottled = true;
412
+ clearTimeout(timeoutId);
413
+ timeoutId = setTimeout(() => {
414
+ isThrottled = false;
415
+ document.querySelectorAll('#chuanhu_chatbot>.wrap>.message-wrap .message.bot').forEach(addChuanhuButton);
416
+ saveHistoryHtml();
417
+ }, 500);
418
+ }
419
+ }
420
+ }
421
+ });
422
+ mObserver.observe(document.documentElement, { attributes: true, childList: true, subtree: true });
423
+
424
+ var loadhistorytime = 0; // for debugging
425
+ function saveHistoryHtml() {
426
+ var historyHtml = document.querySelector('#chuanhu_chatbot > .wrap');
427
+ localStorage.setItem('chatHistory', historyHtml.innerHTML);
428
+ // console.log("History Saved")
429
+ historyLoaded = false;
430
+ }
431
+ function loadHistoryHtml() {
432
+ var historyHtml = localStorage.getItem('chatHistory');
433
+ if (!historyHtml) {
434
+ historyLoaded = true;
435
+ return; // no history, do nothing
436
+ }
437
+ userLogged = localStorage.getItem('userLogged');
438
+ if (userLogged){
439
+ historyLoaded = true;
440
+ return; // logged in, do nothing
441
+ }
442
+ if (!historyLoaded) {
443
+ var tempDiv = document.createElement('div');
444
+ tempDiv.innerHTML = historyHtml;
445
+ var buttons = tempDiv.querySelectorAll('button.chuanhu-btn');
446
+ var gradioCopyButtons = tempDiv.querySelectorAll('button.copy_code_button');
447
+ for (var i = 0; i < buttons.length; i++) {
448
+ buttons[i].parentNode.removeChild(buttons[i]);
449
+ }
450
+ for (var i = 0; i < gradioCopyButtons.length; i++) {
451
+ gradioCopyButtons[i].parentNode.removeChild(gradioCopyButtons[i]);
452
+ }
453
+ var fakeHistory = document.createElement('div');
454
+ fakeHistory.classList.add('history-message');
455
+ fakeHistory.innerHTML = tempDiv.innerHTML;
456
+ webLocale();
457
+ chatbotWrap.insertBefore(fakeHistory, chatbotWrap.firstChild);
458
+ // var fakeHistory = document.createElement('div');
459
+ // fakeHistory.classList.add('history-message');
460
+ // fakeHistory.innerHTML = historyHtml;
461
+ // chatbotWrap.insertBefore(fakeHistory, chatbotWrap.firstChild);
462
+ historyLoaded = true;
463
+ console.log("History Loaded");
464
+ loadhistorytime += 1; // for debugging
465
+ } else {
466
+ historyLoaded = false;
467
+ }
468
+ }
469
+ function clearHistoryHtml() {
470
+ localStorage.removeItem("chatHistory");
471
+ historyMessages = chatbotWrap.querySelector('.history-message');
472
+ if (historyMessages) {
473
+ chatbotWrap.removeChild(historyMessages);
474
+ console.log("History Cleared");
475
+ }
476
+ }
477
+ function emptyHistory() {
478
+ empty_botton.addEventListener("click", function () {
479
+ clearHistoryHtml();
480
+ });
481
+ }
482
+
483
+ // 监视页面内部 DOM 变动
484
+ var observer = new MutationObserver(function (mutations) {
485
+ gradioLoaded(mutations);
486
+ });
487
+ observer.observe(targetNode, { childList: true, subtree: true });
488
+
489
+ // 监视页面变化
490
+ window.addEventListener("DOMContentLoaded", function () {
491
+ isInIframe = (window.self !== window.top);
492
+ historyLoaded = false;
493
+ });
494
+ window.addEventListener('resize', setChatbotHeight);
495
+ window.addEventListener('scroll', setChatbotHeight);
496
+ window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", adjustDarkMode);
497
+
498
+ // button svg code
499
+ const copyIcon = '<span><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" height=".8em" width=".8em" xmlns="http://www.w3.org/2000/svg"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></span>';
500
+ const copiedIcon = '<span><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" height=".8em" width=".8em" xmlns="http://www.w3.org/2000/svg"><polyline points="20 6 9 17 4 12"></polyline></svg></span>';
501
+ const mdIcon = '<span><svg stroke="currentColor" fill="none" stroke-width="1" viewBox="0 0 14 18" stroke-linecap="round" stroke-linejoin="round" height=".8em" width=".8em" xmlns="http://www.w3.org/2000/svg"><g transform-origin="center" transform="scale(0.85)"><path d="M1.5,0 L12.5,0 C13.3284271,-1.52179594e-16 14,0.671572875 14,1.5 L14,16.5 C14,17.3284271 13.3284271,18 12.5,18 L1.5,18 C0.671572875,18 1.01453063e-16,17.3284271 0,16.5 L0,1.5 C-1.01453063e-16,0.671572875 0.671572875,1.52179594e-16 1.5,0 Z" stroke-width="1.8"></path><line x1="3.5" y1="3.5" x2="10.5" y2="3.5"></line><line x1="3.5" y1="6.5" x2="8" y2="6.5"></line></g><path d="M4,9 L10,9 C10.5522847,9 11,9.44771525 11,10 L11,13.5 C11,14.0522847 10.5522847,14.5 10,14.5 L4,14.5 C3.44771525,14.5 3,14.0522847 3,13.5 L3,10 C3,9.44771525 3.44771525,9 4,9 Z" stroke="none" fill="currentColor"></path></svg></span>';
502
+ const rawIcon = '<span><svg stroke="currentColor" fill="none" stroke-width="1.8" viewBox="0 0 18 14" stroke-linecap="round" stroke-linejoin="round" height=".8em" width=".8em" xmlns="http://www.w3.org/2000/svg"><g transform-origin="center" transform="scale(0.85)"><polyline points="4 3 0 7 4 11"></polyline><polyline points="14 3 18 7 14 11"></polyline><line x1="12" y1="0" x2="6" y2="14"></line></g></svg></span>';
assets/external-scripts.js ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+
2
+ // external javascript here
assets/favicon.ico ADDED
assets/favicon.png ADDED
assets/html/appearance_switcher.html ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div style="display: flex; justify-content: space-between;">
2
+ <span style="margin-top: 4px !important;">
3
+ {label}
4
+ </span>
5
+ <span>
6
+ <label class="apSwitch" for="checkbox">
7
+ <input type="checkbox" id="checkbox">
8
+ <div class="apSlider"></div>
9
+ </label>
10
+ </span>
11
+ </div>
assets/html/footer.html ADDED
@@ -0,0 +1 @@
 
 
1
+ <div class="versions">{versions}</div>
chatgpt - macOS.command ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ echo Opening ChuanhuChatGPT...
3
+ cd "$(dirname "${BASH_SOURCE[0]}")"
4
+ nohup python3 ChuanhuChatbot.py >/dev/null 2>&1 &
5
+ sleep 5
6
+ open http://127.0.0.1:7860
7
+ echo Finished opening ChuanhuChatGPT (http://127.0.0.1:7860/). If you kill ChuanhuChatbot, Use "pkill -f 'ChuanhuChatbot'" command in terminal.
chatgpt - windows.bat ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @echo off
2
+ echo Opening ChuanhuChatGPT...
3
+
4
+ REM Open powershell via bat
5
+ start powershell.exe -NoExit -Command "python ./ChuanhuChatbot.py"
6
+
7
+ REM The web page can be accessed with delayed start http://127.0.0.1:7860/
8
+ ping -n 5 127.0.0.1>nul
9
+
10
+ REM access chargpt via your default browser
11
+ start "" "http://127.0.0.1:7860/"
12
+
13
+
14
+ echo Finished opening ChuanhuChatGPT (http://127.0.0.1:7860/).
config.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ {
2
+ "hide_history_when_not_logged_in": true
3
+ }
config_example.json ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ // 你的OpenAI API Key,一般必填,
3
+ // 若缺省填为 "openai_api_key": "" 则必须再在图形界面中填入API Key
4
+ "openai_api_key": "",
5
+ // 你的xmchat API Key,与OpenAI API Key不同
6
+ "xmchat_api_key": "",
7
+ "language": "auto",
8
+ // 如果使用代理,请取消注释下面的两行,并替换代理URL
9
+ // "https_proxy": "http://127.0.0.1:1079",
10
+ // "http_proxy": "http://127.0.0.1:1079",
11
+ "users": [], // 用户列表,[[用户名1, 密码1], [用户名2, 密码2], ...]
12
+ "local_embedding": false, //是否在本地编制索引
13
+ "default_model": "gpt-3.5-turbo", // 默认模型
14
+ "advance_docs": {
15
+ "pdf": {
16
+ // 是否认为PDF是双栏的
17
+ "two_column": false,
18
+ // 是否使用OCR识别PDF中的公式
19
+ "formula_ocr": true
20
+ }
21
+ },
22
+ // 是否多个API Key轮换使用
23
+ "multi_api_key": false,
24
+ "api_key_list": [
25
+ "sk-xxxxxxxxxxxxxxxxxxxxxxxx1",
26
+ "sk-xxxxxxxxxxxxxxxxxxxxxxxx2",
27
+ "sk-xxxxxxxxxxxxxxxxxxxxxxxx3"
28
+ ],
29
+ // 如果使用自定义端口、自定义ip,请取消注释并替换对应内容
30
+ // "server_name": "0.0.0.0",
31
+ // "server_port": 7860,
32
+ // 如果要share到gradio,设置为true
33
+ // "share": false,
34
+ }
configs/ds_config_chatbot.json ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "fp16": {
3
+ "enabled": false
4
+ },
5
+ "bf16": {
6
+ "enabled": true
7
+ },
8
+ "comms_logger": {
9
+ "enabled": false,
10
+ "verbose": false,
11
+ "prof_all": false,
12
+ "debug": false
13
+ },
14
+ "steps_per_print": 20000000000000000,
15
+ "train_micro_batch_size_per_gpu": 1,
16
+ "wall_clock_breakdown": false
17
+ }
custom.css ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ :root {
2
+ --chatbot-color-light: #F3F3F3;
3
+ --chatbot-color-dark: #121111;
4
+ }
5
+
6
+ /* status_display */
7
+ #status_display {
8
+ display: flex;
9
+ min-height: 2.5em;
10
+ align-items: flex-end;
11
+ justify-content: flex-end;
12
+ }
13
+ #status_display p {
14
+ font-size: .85em;
15
+ font-family: monospace;
16
+ color: var(--body-text-color-subdued);
17
+ }
18
+
19
+ #chuanhu_chatbot, #status_display {
20
+ transition: all 0.6s;
21
+ }
22
+ /* list */
23
+ ol:not(.options), ul:not(.options) {
24
+ padding-inline-start: 2em !important;
25
+ }
26
+
27
+ /* 亮色 */
28
+ #chuanhu_chatbot {
29
+ background-color: var(--chatbot-color-light) !important;
30
+ }
31
+ [data-testid = "bot"] {
32
+ background-color: #FFFFFF !important;
33
+ }
34
+ [data-testid = "user"] {
35
+ background-color: #95EC69 !important;
36
+ }
37
+ /* 对话气泡 */
38
+ [class *= "message"] {
39
+ border-radius: var(--radius-xl) !important;
40
+ border: none;
41
+ padding: var(--spacing-xl) !important;
42
+ font-size: var(--text-md) !important;
43
+ line-height: var(--line-md) !important;
44
+ min-height: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl));
45
+ min-width: calc(var(--text-md)*var(--line-md) + 2*var(--spacing-xl));
46
+ }
47
+ [data-testid = "bot"] {
48
+ max-width: 85%;
49
+ border-bottom-left-radius: 0 !important;
50
+ }
51
+ [data-testid = "user"] {
52
+ max-width: 85%;
53
+ width: auto !important;
54
+ border-bottom-right-radius: 0 !important;
55
+ }
56
+ /* 表格 */
57
+ table {
58
+ margin: 1em 0;
59
+ border-collapse: collapse;
60
+ empty-cells: show;
61
+ }
62
+ td,th {
63
+ border: 1.2px solid var(--border-color-primary) !important;
64
+ padding: 0.2em;
65
+ }
66
+ thead {
67
+ background-color: rgba(175,184,193,0.2);
68
+ }
69
+ thead th {
70
+ padding: .5em .2em;
71
+ }
72
+ /* 行内代码 */
73
+ code {
74
+ display: inline;
75
+ white-space: break-spaces;
76
+ border-radius: 6px;
77
+ margin: 0 2px 0 2px;
78
+ padding: .2em .4em .1em .4em;
79
+ background-color: rgba(175,184,193,0.2);
80
+ }
81
+ /* 代码块 */
82
+ pre code {
83
+ display: block;
84
+ overflow: auto;
85
+ white-space: pre;
86
+ background-color: hsla(0, 0%, 0%, 80%)!important;
87
+ border-radius: 10px;
88
+ padding: 1.4em 1.2em 0em 1.4em;
89
+ margin: 1.2em 2em 1.2em 0.5em;
90
+ color: #FFF;
91
+ box-shadow: 6px 6px 16px hsla(0, 0%, 0%, 0.2);
92
+ }
93
+ /* 代码高亮样式 */
94
+ .highlight .hll { background-color: #49483e }
95
+ .highlight .c { color: #75715e } /* Comment */
96
+ .highlight .err { color: #960050; background-color: #1e0010 } /* Error */
97
+ .highlight .k { color: #66d9ef } /* Keyword */
98
+ .highlight .l { color: #ae81ff } /* Literal */
99
+ .highlight .n { color: #f8f8f2 } /* Name */
100
+ .highlight .o { color: #f92672 } /* Operator */
101
+ .highlight .p { color: #f8f8f2 } /* Punctuation */
102
+ .highlight .ch { color: #75715e } /* Comment.Hashbang */
103
+ .highlight .cm { color: #75715e } /* Comment.Multiline */
104
+ .highlight .cp { color: #75715e } /* Comment.Preproc */
105
+ .highlight .cpf { color: #75715e } /* Comment.PreprocFile */
106
+ .highlight .c1 { color: #75715e } /* Comment.Single */
107
+ .highlight .cs { color: #75715e } /* Comment.Special */
108
+ .highlight .gd { color: #f92672 } /* Generic.Deleted */
109
+ .highlight .ge { font-style: italic } /* Generic.Emph */
110
+ .highlight .gi { color: #a6e22e } /* Generic.Inserted */
111
+ .highlight .gs { font-weight: bold } /* Generic.Strong */
112
+ .highlight .gu { color: #75715e } /* Generic.Subheading */
113
+ .highlight .kc { color: #66d9ef } /* Keyword.Constant */
114
+ .highlight .kd { color: #66d9ef } /* Keyword.Declaration */
115
+ .highlight .kn { color: #f92672 } /* Keyword.Namespace */
116
+ .highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
117
+ .highlight .kr { color: #66d9ef } /* Keyword.Reserved */
118
+ .highlight .kt { color: #66d9ef } /* Keyword.Type */
119
+ .highlight .ld { color: #e6db74 } /* Literal.Date */
120
+ .highlight .m { color: #ae81ff } /* Literal.Number */
121
+ .highlight .s { color: #e6db74 } /* Literal.String */
122
+ .highlight .na { color: #a6e22e } /* Name.Attribute */
123
+ .highlight .nb { color: #f8f8f2 } /* Name.Builtin */
124
+ .highlight .nc { color: #a6e22e } /* Name.Class */
125
+ .highlight .no { color: #66d9ef } /* Name.Constant */
126
+ .highlight .nd { color: #a6e22e } /* Name.Decorator */
127
+ .highlight .ni { color: #f8f8f2 } /* Name.Entity */
128
+ .highlight .ne { color: #a6e22e } /* Name.Exception */
129
+ .highlight .nf { color: #a6e22e } /* Name.Function */
130
+ .highlight .nl { color: #f8f8f2 } /* Name.Label */
131
+ .highlight .nn { color: #f8f8f2 } /* Name.Namespace */
132
+ .highlight .nx { color: #a6e22e } /* Name.Other */
133
+ .highlight .py { color: #f8f8f2 } /* Name.Property */
134
+ .highlight .nt { color: #f92672 } /* Name.Tag */
135
+ .highlight .nv { color: #f8f8f2 } /* Name.Variable */
136
+ .highlight .ow { color: #f92672 } /* Operator.Word */
137
+ .highlight .w { color: #f8f8f2 } /* Text.Whitespace */
138
+ .highlight .mb { color: #ae81ff } /* Literal.Number.Bin */
139
+ .highlight .mf { color: #ae81ff } /* Literal.Number.Float */
140
+ .highlight .mh { color: #ae81ff } /* Literal.Number.Hex */
141
+ .highlight .mi { color: #ae81ff } /* Literal.Number.Integer */
142
+ .highlight .mo { color: #ae81ff } /* Literal.Number.Oct */
143
+ .highlight .sa { color: #e6db74 } /* Literal.String.Affix */
144
+ .highlight .sb { color: #e6db74 } /* Literal.String.Backtick */
145
+ .highlight .sc { color: #e6db74 } /* Literal.String.Char */
146
+ .highlight .dl { color: #e6db74 } /* Literal.String.Delimiter */
147
+ .highlight .sd { color: #e6db74 } /* Literal.String.Doc */
148
+ .highlight .s2 { color: #e6db74 } /* Literal.String.Double */
149
+ .highlight .se { color: #ae81ff } /* Literal.String.Escape */
150
+ .highlight .sh { color: #e6db74 } /* Literal.String.Heredoc */
151
+ .highlight .si { color: #e6db74 } /* Literal.String.Interpol */
152
+ .highlight .sx { color: #e6db74 } /* Literal.String.Other */
153
+ .highlight .sr { color: #e6db74 } /* Literal.String.Regex */
154
+ .highlight .s1 { color: #e6db74 } /* Literal.String.Single */
155
+ .highlight .ss { color: #e6db74 } /* Literal.String.Symbol */
156
+ .highlight .bp { color: #f8f8f2 } /* Name.Builtin.Pseudo */
157
+ .highlight .fm { color: #a6e22e } /* Name.Function.Magic */
158
+ .highlight .vc { color: #f8f8f2 } /* Name.Variable.Class */
159
+ .highlight .vg { color: #f8f8f2 } /* Name.Variable.Global */
160
+ .highlight .vi { color: #f8f8f2 } /* Name.Variable.Instance */
161
+ .highlight .vm { color: #f8f8f2 } /* Name.Variable.Magic */
162
+ .highlight .il { color: #ae81ff } /* Literal.Number.Integer.Long */
history/2023-06-14_15-05-04.json ADDED
File without changes
locale/en_US.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "未命名对话历史记录": "Unnamed Dialog History",
3
+ "在这里输入": "Type in here",
4
+ "🧹 新的对话": "🧹 New Dialogue",
5
+ "🔄 重新生成": "🔄 Regeneration",
6
+ "🗑️ 删除最旧对话": "🗑️ Delete oldest dialog",
7
+ "🗑️ 删除最新对话": "🗑️ Delete latest dialog",
8
+ "模型": "Model",
9
+ "多账号模式已开启,无需输入key,可直接开始对话": "Multi-account mode is enabled, no need to enter key, you can start the dialogue directly",
10
+ "**发送消息** 或 **提交key** 以显示额度": "**Send message** or **Submit key** to display credit",
11
+ "选择模型": "Select Model",
12
+ "选择LoRA模型": "Select LoRA Model",
13
+ "实时传输回答": "Stream output",
14
+ "单轮对话": "Single-turn dialogue",
15
+ "使用在线搜索": "Use online search",
16
+ "选择回复语言(针对搜索&索引功能)": "Select reply language (for search & index)",
17
+ "上传索引文件": "Upload",
18
+ "双栏pdf": "Two-column pdf",
19
+ "识别公式": "formula OCR",
20
+ "在这里输入System Prompt...": "Type in System Prompt here...",
21
+ "加载Prompt模板": "Load Prompt Template",
22
+ "选择Prompt模板集合文件": "Select Prompt Template Collection File",
23
+ "🔄 刷新": "🔄 Refresh",
24
+ "从Prompt模板中加载": "Load from Prompt Template",
25
+ "保存/加载": "Save/Load",
26
+ "保存/加载对话历史记录": "Save/Load Dialog History",
27
+ "从列表中加载对话": "Load dialog from list",
28
+ "设置文件名: 默认为.json,可选为.md": "Set file name: default is .json, optional is .md",
29
+ "设置保存文件名": "Set save file name",
30
+ "对话历史记录": "Dialog History",
31
+ "💾 保存对话": "💾 Save Dialog",
32
+ "📝 导出为Markdown": "📝 Export as Markdown",
33
+ "默认保存于history文件夹": "Default save in history folder",
34
+ "高级": "Advanced",
35
+ "# ⚠️ 务必谨慎更改 ⚠️\n\n如果无法使用请恢复默认设置": "# ⚠️ Caution: Changes require care. ⚠️\n\nIf unable to use, restore default settings.",
36
+ "参数": "Parameters",
37
+ "在这里输入停止符,用英文逗号隔开...": "Type in stop token here, separated by comma...",
38
+ "用于定位滥用行为": "Used to locate abuse",
39
+ "用户名": "Username",
40
+ "网络设置": "Network Settings",
41
+ "在这里输入API-Host...": "Type in API-Host here...",
42
+ "🔄 切换API地址": "🔄 Switch API Address",
43
+ "在这里输入代理地址...": "Type in proxy address here...",
44
+ "代理地址(示例:http://127.0.0.1:10809)": "Proxy address (example: http://127.0.0.1:10809)",
45
+ "🔄 设置代理地址": "🔄 Set Proxy Address",
46
+ "🔙 恢复默认设置": "🔙 Restore Default Settings",
47
+ "川虎Chat 🚀": "Chuanhu Chat 🚀",
48
+ "开始实时传输回答……": "Start streaming output...",
49
+ "Token 计数: ": "Token Count: ",
50
+ ",本次对话累计消耗了 ": ",Total cost for this dialogue is ",
51
+ "**获取API使用情况失败**": "**Failed to get API usage**",
52
+ "**本月使用金额** ": "**Monthly usage** ",
53
+ "获取API使用情况失败:": "Failed to get API usage:",
54
+ "API密钥更改为了": "The API key is changed to",
55
+ "JSON解析错误,收到的内容: ": "JSON parsing error, received content: ",
56
+ "模型设置为了:": "Model is set to: ",
57
+ "☹️发生了错误:": "☹️Error: ",
58
+ "获取对话时发生错误,请查看后台日志": "Error occurred when getting dialogue, check the background log",
59
+ "请检查网络连接,或者API-Key是否有效。": "Check the network connection or whether the API-Key is valid.",
60
+ "连接超时,无法获取对话。": "Connection timed out, unable to get dialogue.",
61
+ "读取超时,无法获取对话。": "Read timed out, unable to get dialogue.",
62
+ "代理错误,无法获取对话。": "Proxy error, unable to get dialogue.",
63
+ "SSL错误,无法获取对话。": "SSL error, unable to get dialogue.",
64
+ "API key为空,请检查是否输入正确。": "API key is empty, check whether it is entered correctly.",
65
+ "请输入对话内容。": "Enter the content of the conversation.",
66
+ "账单信息不适用": "Billing information is not applicable",
67
+ "由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) 和 [明昭MZhao](https://space.bilibili.com/24807452)开发<br />访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本": "developor: Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) and [明昭MZhao](https://space.bilibili.com/24807452)\n\nDownload latest code from [GitHub](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
68
+ "切换亮暗色主题": "Switch light/dark theme",
69
+ "您的IP区域:未知。": "Your IP region: Unknown.",
70
+ "获取IP地理位置失败。原因:": "Failed to get IP location. Reason: ",
71
+ "。你仍然可以使用聊天功能。": ". You can still use the chat function.",
72
+ "您的IP区域:": "Your IP region: "
73
+ }
locale/extract_locale.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import json
3
+ import re
4
+
5
+ # Define regular expression patterns
6
+ pattern = r'i18n\((\"{3}.*?\"{3}|\".*?\")\)'
7
+
8
+ # Load the .py file
9
+ with open('ChuanhuChatbot.py', 'r', encoding='utf-8') as f:
10
+ contents = f.read()
11
+
12
+ # Load the .py files in the modules folder
13
+ for filename in os.listdir("modules"):
14
+ if filename.endswith(".py"):
15
+ with open(os.path.join("modules", filename), "r", encoding="utf-8") as f:
16
+ contents += f.read()
17
+
18
+ # Matching with regular expressions
19
+ matches = re.findall(pattern, contents, re.DOTALL)
20
+
21
+ # Convert to key/value pairs
22
+ data = {match.strip('()"'): '' for match in matches}
23
+
24
+ # Save as a JSON file
25
+ with open('labels.json', 'w', encoding='utf-8') as f:
26
+ json.dump(data, f, ensure_ascii=False, indent=4)
locale/ja_JP.json ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "未命名对话历史记录": "名無しの会話履歴",
3
+ "在这里输入": "ここに入力",
4
+ "🧹 新的对话": "🧹 新しい会話",
5
+ "🔄 重新生成": "🔄 再生成",
6
+ "🗑️ 删除最旧对话": "🗑️ 最古の会話削除",
7
+ "🗑️ 删除最新对话": "🗑️ 最新の会話削除",
8
+ "模型": "LLMモデル",
9
+ "多账号模式已开启,无需输入key,可直接开始对话": "複数アカウントモードがオンになっています。キーを入力する必要はありません。会話を開始できます",
10
+ "**发送消息** 或 **提交key** 以显示额度": "**メッセージを送信** または **キーを送信** して、クレジットを表示します",
11
+ "选择模型": "LLMモデルを選択",
12
+ "选择LoRA模型": "LoRAモデルを選択",
13
+ "实时传输回答": "ストリーム出力",
14
+ "单轮对话": "単発会話",
15
+ "使用在线搜索": "オンライン検索を使用",
16
+ "选择回复语言(针对搜索&索引功能)": "回答言語を選択(検索とインデックス機能に対して)",
17
+ "上传索引文件": "アップロード",
18
+ "双栏pdf": "2カラムpdf",
19
+ "识别公式": "formula OCR",
20
+ "在这里输入System Prompt...": "System Promptを入力してください...",
21
+ "加载Prompt模板": "Promptテンプレートを読込",
22
+ "选择Prompt模板集合文件": "Promptテンプレートコレクションを選択",
23
+ "🔄 刷新": "🔄 更新",
24
+ "从Prompt模板中加载": "Promptテンプレートから読込",
25
+ "保存/加载": "保存/読込",
26
+ "保存/加载对话历史记录": "会話履歴を保存/読込",
27
+ "从列表中加载对话": "リストから会話を読込",
28
+ "设置文件名: 默认为.json,可选为.md": "ファイル名を設定: デフォルトは.json、.mdを選択できます",
29
+ "设置保存文件名": "保存ファイル名を設定",
30
+ "对话历史记录": "会話履歴",
31
+ "💾 保存对话": "💾 会話を保存",
32
+ "📝 导出为Markdown": "📝 Markdownでエクスポート",
33
+ "默认保存于history文件夹": "デフォルトでhistoryフォルダに保存されます",
34
+ "高级": "Advanced",
35
+ "# ⚠️ 务必谨慎更改 ⚠️\n\n如果无法使用请恢复默认设置": "# ⚠️ 変更には慎重に ⚠️\n\nもし動作しない場合は、デフォルト設定に戻してください。",
36
+ "参数": "パラメータ",
37
+ "在这里输入停止符,用英文逗号隔开...": "ここにストップ文字を英語のカンマで区切って入力してください...",
38
+ "用于定位滥用行为": "不正行為を特定するために使用されます",
39
+ "用户名": "ユーザー名",
40
+ "网络设置": "ネットワーク設定",
41
+ "在这里输入API-Host...": "API-Hostを入力してください...",
42
+ "🔄 切换API地址": "🔄 APIアドレスを切り替え",
43
+ "在这里输入代理地址...": "プロキシアドレスを入力してください...",
44
+ "代理地址(示例:http://127.0.0.1:10809)": "プロキシアドレス(例:http://127.0.0.1:10809)",
45
+ "🔄 设置代理地址": "🔄 プロキシアドレスを設定",
46
+ "🔙 恢复默认设置": "🔙 デフォルト設定に戻す",
47
+ "川虎Chat 🚀": "川虎Chat 🚀",
48
+ "开始实时传输回答……": "ストリーム出力開始……",
49
+ "Token 计数: ": "Token数: ",
50
+ ",本次对话累计消耗了 ": ", 今の会話で消費合計 ",
51
+ "**获取API使用情况失败**": "**API使用状況の取得に失敗しました**",
52
+ "**本月使用金额** ": "**今月の使用料金** ",
53
+ "获取API使用情况失败:": "API使用状況の取得に失敗しました:",
54
+ "API密钥更改为了": "APIキーが変更されました",
55
+ "JSON解析错误,收到的内容: ": "JSON解析エラー、受信内容: ",
56
+ "模型设置为了:": "LLMモデルを設定しました: ",
57
+ "☹️发生了错误:": "エラーが発生しました: ",
58
+ "获取对话时发生错误,请查看后台日志": "会話取得時にエラー発生、あとのログを確認してください",
59
+ "请检查网络连接,或者API-Key是否有效。": "ネットワーク接続を確認するか、APIキーが有効かどうかを確認してください。",
60
+ "连接超时,无法获取对话。": "接続タイムアウト、会話を取得できません。",
61
+ "读取超时,无法获取对话。": "読み込みタイムアウト、会話を取得できません。",
62
+ "代理错误,无法获取对话。": "プロキシエラー、会話を取得できません。",
63
+ "SSL错误,无法获取对话。": "SSLエラー、会話を取得できません。",
64
+ "API key为空,请检查是否输入正确。": "APIキーが入力されていません。正しく入力されているか確認してください。",
65
+ "请输入对话内容。": "会話内容を入力してください。",
66
+ "账单信息不适用": "課金情報は対象外です",
67
+ "由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) 和 [明昭MZhao](https://space.bilibili.com/24807452)开发<br />访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本": "開発:Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) と [明昭MZhao](https://space.bilibili.com/24807452)\n\n最新コードは川虎Chatのサイトへ [GitHubプロジェクト](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
68
+ "切换亮暗色主题": "テーマの明暗切替",
69
+ "您的IP区域:未知。": "あなたのIPアドレス地域:不明",
70
+ "获取IP地理位置失败。原因:": "IPアドレス地域の取得に失敗しました。理由:",
71
+ "。你仍然可以使用聊天功能。": "。あなたはまだチャット機能を使用できます。",
72
+ "您的IP区域:": "あなたのIPアドレス地域:"
73
+ }
modules/__init__.py ADDED
File without changes
modules/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (172 Bytes). View file
 
modules/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (154 Bytes). View file
 
modules/__pycache__/base_model.cpython-311.pyc ADDED
Binary file (28.7 kB). View file
 
modules/__pycache__/base_model.cpython-39.pyc ADDED
Binary file (16.3 kB). View file
 
modules/__pycache__/chat_func.cpython-39.pyc ADDED
Binary file (10.1 kB). View file
 
modules/__pycache__/config.cpython-311.pyc ADDED
Binary file (9.27 kB). View file
 
modules/__pycache__/config.cpython-39.pyc ADDED
Binary file (4.39 kB). View file
 
modules/__pycache__/index_func.cpython-311.pyc ADDED
Binary file (8.86 kB). View file
 
modules/__pycache__/index_func.cpython-39.pyc ADDED
Binary file (4.56 kB). View file
 
modules/__pycache__/llama_func.cpython-311.pyc ADDED
Binary file (9.44 kB). View file
 
modules/__pycache__/llama_func.cpython-39.pyc ADDED
Binary file (4.85 kB). View file
 
modules/__pycache__/models.cpython-311.pyc ADDED
Binary file (31.2 kB). View file
 
modules/__pycache__/models.cpython-39.pyc ADDED
Binary file (17.5 kB). View file
 
modules/__pycache__/openai_func.cpython-39.pyc ADDED
Binary file (2.16 kB). View file
 
modules/__pycache__/overwrites.cpython-311.pyc ADDED
Binary file (5.23 kB). View file
 
modules/__pycache__/overwrites.cpython-39.pyc ADDED
Binary file (3.31 kB). View file
 
modules/__pycache__/pdf_func.cpython-311.pyc ADDED
Binary file (10.4 kB). View file
 
modules/__pycache__/pdf_func.cpython-39.pyc ADDED
Binary file (6.13 kB). View file
 
modules/__pycache__/presets.cpython-311.pyc ADDED
Binary file (7.68 kB). View file
 
modules/__pycache__/presets.cpython-39.pyc ADDED
Binary file (6.49 kB). View file
 
modules/__pycache__/proxy_func.cpython-39.pyc ADDED
Binary file (718 Bytes). View file
 
modules/__pycache__/shared.cpython-311.pyc ADDED
Binary file (3.78 kB). View file
 
modules/__pycache__/shared.cpython-39.pyc ADDED
Binary file (2.32 kB). View file
 
modules/__pycache__/utils.cpython-311.pyc ADDED
Binary file (39 kB). View file
 
modules/__pycache__/utils.cpython-39.pyc ADDED
Binary file (22.1 kB). View file