JohnSmith9982 commited on
Commit
0cc999a
·
1 Parent(s): f1812bf

Upload 98 files

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. ChuanhuChatbot.py +552 -307
  2. README.md +4 -2
  3. config_example.json +15 -8
  4. locale/en_US.json +126 -72
  5. locale/extract_locale.py +132 -20
  6. locale/ja_JP.json +126 -72
  7. locale/ko_KR.json +126 -74
  8. locale/ru_RU.json +141 -0
  9. locale/sv_SE.json +141 -0
  10. locale/vi_VN.json +141 -0
  11. locale/zh_CN.json +1 -0
  12. modules/config.py +28 -6
  13. modules/index_func.py +7 -8
  14. modules/models/Azure.py +18 -0
  15. modules/models/ChatGLM.py +84 -0
  16. modules/models/ChuanhuAgent.py +18 -2
  17. modules/models/Claude.py +55 -0
  18. modules/models/GooglePaLM.py +29 -0
  19. modules/models/LLaMA.py +126 -0
  20. modules/models/OpenAI.py +279 -0
  21. modules/models/OpenAIInstruct.py +27 -0
  22. modules/models/OpenAIVision.py +328 -0
  23. modules/models/Qwen.py +57 -0
  24. modules/models/XMChat.py +149 -0
  25. modules/models/base_model.py +178 -79
  26. modules/models/midjourney.py +6 -7
  27. modules/models/models.py +49 -543
  28. modules/models/spark.py +166 -0
  29. modules/overwrites.py +29 -26
  30. modules/presets.py +97 -31
  31. modules/repo.py +129 -42
  32. modules/shared.py +7 -5
  33. modules/utils.py +105 -62
  34. modules/webui.py +14 -1
  35. modules/webui_locale.py +9 -2
  36. readme/README_en.md +86 -36
  37. readme/README_ja.md +76 -28
  38. readme/README_ru.md +186 -0
  39. requirements.txt +10 -5
  40. requirements_advanced.txt +5 -4
  41. templates/6 Russian Prompts.json +0 -0
  42. web_assets/.DS_Store +0 -0
  43. web_assets/html/chatbot_header_btn.html +72 -0
  44. web_assets/html/chatbot_more.html +72 -0
  45. web_assets/html/close_btn.html +5 -0
  46. web_assets/html/func_nav.html +78 -0
  47. web_assets/html/header_title.html +20 -0
  48. web_assets/html/web_config.html +21 -0
  49. web_assets/icon/any-icon-512.png +0 -0
  50. web_assets/icon/mask-icon-512.png +0 -0
ChuanhuChatbot.py CHANGED
@@ -5,18 +5,18 @@ logging.basicConfig(
5
  format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s",
6
  )
7
 
8
- import colorama
 
 
 
 
 
 
 
 
9
  import gradio as gr
 
10
 
11
- from modules import config
12
- from modules.config import *
13
- from modules.utils import *
14
- from modules.presets import *
15
- from modules.overwrites import *
16
- from modules.webui import *
17
- from modules.repo import *
18
- from modules.train_func import *
19
- from modules.models.models import get_model
20
 
21
  logging.getLogger("httpx").setLevel(logging.WARNING)
22
 
@@ -26,25 +26,28 @@ gr.Chatbot.postprocess = postprocess
26
  # with open("web_assets/css/ChuanhuChat.css", "r", encoding="utf-8") as f:
27
  # ChuanhuChatCSS = f.read()
28
 
 
29
  def create_new_model():
30
- return get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
 
31
 
32
  with gr.Blocks(theme=small_and_beautiful_theme) as demo:
33
- user_name = gr.State("")
34
- promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
35
  user_question = gr.State("")
36
- assert type(my_api_key)==str
37
  user_api_key = gr.State(my_api_key)
38
- current_model = gr.State(create_new_model)
39
 
40
  topic = gr.State(i18n("未命名对话历史记录"))
41
 
42
- with gr.Row():
43
- gr.HTML(CHUANHU_TITLE, elem_id="app-title")
 
44
  status_display = gr.Markdown(get_geoip(), elem_id="status-display")
45
  with gr.Row(elem_id="float-display"):
46
- user_info = gr.Markdown(value="getting user info...", elem_id="user-info")
47
- config_info = gr.HTML(get_html("config_info.html").format(bot_avatar=config.bot_avatar, user_avatar=config.user_avatar), visible=False, elem_id="config-info")
48
  update_info = gr.HTML(get_html("update.html").format(
49
  current_version=repo_tag_html(),
50
  version_time=version_time(),
@@ -52,248 +55,339 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
52
  update_btn=i18n("更新"),
53
  seenew_btn=i18n("详情"),
54
  ok_btn=i18n("好"),
55
- ), visible=check_update)
56
-
57
- with gr.Row(equal_height=True):
58
- with gr.Column(scale=5):
59
- with gr.Row():
60
- chatbot = gr.Chatbot(label="Chuanhu Chat", elem_id="chuanhu-chatbot", latex_delimiters=latex_delimiters_set, height=700)
61
- with gr.Row():
62
- with gr.Column(min_width=225, scale=12):
63
- user_input = gr.Textbox(
64
- elem_id="user-input-tb",
65
- show_label=False, placeholder=i18n("在这里输入"),
66
- container=False
67
- )
68
- with gr.Column(min_width=42, scale=1):
69
- submitBtn = gr.Button(value="", variant="primary", elem_id="submit-btn")
70
- cancelBtn = gr.Button(value="", variant="secondary", visible=False, elem_id="cancel-btn")
71
- with gr.Row(elem_id="chatbot-buttons"):
72
- with gr.Column(min_width=120, scale=1):
73
- emptyBtn = gr.Button(
74
- i18n("🧹 新的对话"), elem_id="empty-btn"
75
- )
76
- with gr.Column(min_width=120, scale=1):
77
- retryBtn = gr.Button(i18n("🔄 重新生成"))
78
- with gr.Column(min_width=120, scale=1):
79
- delFirstBtn = gr.Button(i18n("🗑️ 删除最旧对话"))
80
- with gr.Column(min_width=120, scale=1):
81
- delLastBtn = gr.Button(i18n("🗑️ 删除最新对话"))
82
- with gr.Row(visible=False) as like_dislike_area:
83
- with gr.Column(min_width=20, scale=1):
84
- likeBtn = gr.Button(i18n("👍"))
85
- with gr.Column(min_width=20, scale=1):
86
- dislikeBtn = gr.Button(i18n("👎"))
87
-
88
- with gr.Column():
89
- with gr.Column(min_width=50, scale=1):
90
- with gr.Tab(label=i18n("模型")):
91
- keyTxt = gr.Textbox(
92
- show_label=True,
93
- placeholder=f"Your API-key...",
94
- value=hide_middle_chars(user_api_key.value),
95
- type="password",
96
- visible=not HIDE_MY_KEY,
97
- label="API-Key",
98
- )
99
- if multi_api_key:
100
- usageTxt = gr.Markdown(i18n("多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
101
- else:
102
- usageTxt = gr.Markdown(i18n("**发送消息** 或 **提交key** 以显示额度"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  model_select_dropdown = gr.Dropdown(
104
- label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
 
105
  )
106
  lora_select_dropdown = gr.Dropdown(
107
- label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
 
108
  )
109
- with gr.Row():
110
- single_turn_checkbox = gr.Checkbox(label=i18n("单轮对话"), value=False, elem_classes="switch-checkbox")
111
- use_websearch_checkbox = gr.Checkbox(label=i18n("使用在线搜索"), value=False, elem_classes="switch-checkbox")
112
- language_select_dropdown = gr.Dropdown(
113
- label=i18n("选择回复语言(针对搜索&索引功能)"),
114
- choices=REPLY_LANGUAGES,
115
- multiselect=False,
116
- value=REPLY_LANGUAGES[0],
 
 
 
 
 
117
  )
118
- index_files = gr.Files(label=i18n("上传"), type="file", elem_id="upload-index-file")
119
- two_column = gr.Checkbox(label=i18n("双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
120
- summarize_btn = gr.Button(i18n("总结"))
121
- # TODO: 公式ocr
122
- # formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
123
-
124
- with gr.Tab(label="Prompt"):
125
- systemPromptTxt = gr.Textbox(
126
- show_label=True,
127
- placeholder=i18n("在这里输入System Prompt..."),
128
- label="System prompt",
129
- value=INITIAL_SYSTEM_PROMPT,
130
- lines=10
131
- )
132
- with gr.Accordion(label=i18n("加载Prompt模板"), open=True):
133
- with gr.Column():
134
- with gr.Row():
135
- with gr.Column(scale=6):
136
- templateFileSelectDropdown = gr.Dropdown(
137
- label=i18n("选择Prompt模板集合文件"),
138
- choices=get_template_names(plain=True),
139
- multiselect=False,
140
- value=get_template_names(plain=True)[0],
141
- container=False,
142
- )
143
- with gr.Column(scale=1):
144
- templateRefreshBtn = gr.Button(i18n("🔄 刷新"))
145
- with gr.Row():
146
- with gr.Column():
147
- templateSelectDropdown = gr.Dropdown(
148
- label=i18n("从Prompt模板中加载"),
149
- choices=load_template(
150
- get_template_names(plain=True)[0], mode=1
151
- ),
152
- multiselect=False,
153
- container=False,
154
- )
155
-
156
- with gr.Tab(label=i18n("保存/加载")):
157
- with gr.Accordion(label=i18n("保存/加载对话历史记录"), open=True):
158
- with gr.Column():
159
- with gr.Row():
160
- with gr.Column(scale=6):
161
- historyFileSelectDropdown = gr.Dropdown(
162
- label=i18n("从列表中加载对话"),
163
- choices=get_history_names(plain=True),
164
- multiselect=False,
165
- container=False,
166
  )
167
- with gr.Row():
168
- with gr.Column(min_width=42, scale=1):
169
- historyRefreshBtn = gr.Button(i18n("🔄 刷新"))
170
- with gr.Column(min_width=42, scale=1):
171
- historyDeleteBtn = gr.Button(i18n("🗑️ 删除"))
172
- with gr.Row():
173
- with gr.Column(scale=6):
174
- saveFileName = gr.Textbox(
175
- show_label=True,
176
- placeholder=i18n("设置文件名: 默认为.json,可选为.md"),
177
- label=i18n("设置保存文件名"),
178
- value=i18n("对话历史记录"),
179
- elem_classes="no-container"
180
- # container=False,
181
- )
182
- with gr.Column(scale=1):
183
- saveHistoryBtn = gr.Button(i18n("💾 保存对话"))
184
- exportMarkdownBtn = gr.Button(i18n("📝 导出为Markdown"))
185
- gr.Markdown(i18n("默认保存于history文件夹"))
186
- with gr.Row():
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  with gr.Column():
188
- downloadFile = gr.File(interactive=True)
189
-
190
- with gr.Tab(label=i18n("微调")):
191
- openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n("在这里[查看使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B#%E5%BE%AE%E8%B0%83-gpt-35)"))
192
-
193
- with gr.Tab(label=i18n("准备数据集")):
194
- dataset_preview_json = gr.JSON(label=i18n("数据集预览"), readonly=True)
195
- dataset_selection = gr.Files(label = i18n("选择数据集"), file_types=[".xlsx", ".jsonl"], file_count="single")
196
- upload_to_openai_btn = gr.Button(i18n("上传到OpenAI"), variant="primary", interactive=False)
197
-
198
- with gr.Tab(label=i18n("训练")):
199
- openai_ft_file_id = gr.Textbox(label=i18n("文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动填充"))
200
- openai_ft_suffix = gr.Textbox(label=i18n("模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
201
- openai_train_epoch_slider = gr.Slider(label=i18n("训练轮数(Epochs)"), minimum=1, maximum=100, value=3, step=1, interactive=True)
202
- openai_start_train_btn = gr.Button(i18n("开始训练"), variant="primary", interactive=False)
203
-
204
- with gr.Tab(label=i18n("状态")):
205
- openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
206
- openai_cancel_all_jobs_btn = gr.Button(i18n("取消所有任务"))
207
- add_to_models_btn = gr.Button(i18n("添加训练好的模型到模型列表"), interactive=False)
208
-
209
- with gr.Tab(label=i18n("高级")):
210
- gr.HTML(get_html("appearance_switcher.html").format(label=i18n("切换亮暗色主题")), elem_classes="insert-block")
211
- use_streaming_checkbox = gr.Checkbox(
212
- label=i18n("实时传输回答"), value=True, visible=ENABLE_STREAMING_OPTION, elem_classes="switch-checkbox"
213
- )
214
- checkUpdateBtn = gr.Button(i18n("🔄 检查更新..."), visible=check_update)
215
- gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️"), elem_id="advanced-warning")
216
- with gr.Accordion(i18n("参数"), open=False):
217
- temperature_slider = gr.Slider(
218
- minimum=-0,
219
- maximum=2.0,
220
- value=1.0,
221
- step=0.1,
222
- interactive=True,
223
- label="temperature",
224
- )
225
- top_p_slider = gr.Slider(
226
- minimum=-0,
227
- maximum=1.0,
228
- value=1.0,
229
- step=0.05,
230
- interactive=True,
231
- label="top-p",
232
- )
233
- n_choices_slider = gr.Slider(
234
- minimum=1,
235
- maximum=10,
236
- value=1,
237
- step=1,
238
- interactive=True,
239
- label="n choices",
240
- )
241
- stop_sequence_txt = gr.Textbox(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  show_label=True,
243
- placeholder=i18n("停止符,用英文逗号隔开..."),
244
- label="stop",
245
- value="",
246
- lines=1,
 
247
  )
248
- max_context_length_slider = gr.Slider(
249
- minimum=1,
250
- maximum=32768,
251
- value=2000,
252
- step=1,
253
- interactive=True,
254
- label="max context",
 
 
 
 
 
 
 
 
 
 
 
 
255
  )
256
- max_generation_slider = gr.Slider(
257
- minimum=1,
258
- maximum=32768,
259
- value=1000,
260
- step=1,
261
- interactive=True,
262
- label="max generations",
263
- )
264
- presence_penalty_slider = gr.Slider(
265
- minimum=-2.0,
266
- maximum=2.0,
267
- value=0.0,
268
- step=0.01,
269
- interactive=True,
270
- label="presence penalty",
271
  )
272
- frequency_penalty_slider = gr.Slider(
273
- minimum=-2.0,
274
- maximum=2.0,
275
- value=0.0,
276
- step=0.01,
277
  interactive=True,
278
- label="frequency penalty",
279
- )
280
- logit_bias_txt = gr.Textbox(
281
- show_label=True,
282
- placeholder=f"word:likelihood",
283
- label="logit bias",
284
- value="",
285
- lines=1,
286
- )
287
- user_identifier_txt = gr.Textbox(
288
- show_label=True,
289
- placeholder=i18n("用于定位滥用行为"),
290
- label=i18n("用户名"),
291
- value=user_name.value,
292
- lines=1,
293
  )
 
 
 
294
 
295
- with gr.Accordion(i18n("网络参数"), open=False):
296
- gr.Markdown(i18n("---\n⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置"), elem_id="netsetting-warning")
 
297
  default_btn = gr.Button(i18n("🔙 恢复默认网络设置"))
298
  # 网络代理
299
  proxyTxt = gr.Textbox(
@@ -319,25 +413,99 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
319
  # container=False,
320
  elem_classes="view-only-textbox no-container",
321
  )
322
- # changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
323
- updateChuanhuBtn = gr.Button(visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
324
 
325
-
326
- gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
327
- gr.HTML(get_html("footer.html").format(versions=versions_html()), elem_id="footer")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
 
329
  # https://github.com/gradio-app/gradio/pull/3296
 
330
  def create_greeting(request: gr.Request):
331
- if hasattr(request, "username") and request.username: # is not None or is not ""
332
  logging.info(f"Get User Name: {request.username}")
333
- user_info, user_name = gr.Markdown.update(value=f"User: {request.username}"), request.username
 
334
  else:
335
- user_info, user_name = gr.Markdown.update(value=f"", visible=False), ""
336
- current_model = get_model(model_name = MODELS[DEFAULT_MODEL], access_key = my_api_key)[0]
 
 
337
  current_model.set_user_identifier(user_name)
338
- chatbot = gr.Chatbot.update(label=MODELS[DEFAULT_MODEL])
339
- return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), *current_model.auto_load(), get_history_names(False, user_name), chatbot
340
- demo.load(create_greeting, inputs=None, outputs=[user_info, user_name, current_model, like_dislike_area, systemPromptTxt, chatbot, historyFileSelectDropdown, chatbot], api_name="load")
 
 
 
 
 
 
341
  chatgpt_predict_args = dict(
342
  fn=predict,
343
  inputs=[
@@ -369,42 +537,58 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
369
  )
370
 
371
  transfer_input_args = dict(
372
- fn=transfer_input, inputs=[user_input], outputs=[user_question, user_input, submitBtn, cancelBtn], show_progress=True
 
373
  )
374
 
375
  get_usage_args = dict(
376
- fn=billing_info, inputs=[current_model], outputs=[usageTxt], show_progress=False
 
377
  )
378
 
379
  load_history_from_file_args = dict(
380
  fn=load_chat_history,
381
- inputs=[current_model, historyFileSelectDropdown, user_name],
382
  outputs=[saveFileName, systemPromptTxt, chatbot]
383
  )
384
 
385
  refresh_history_args = dict(
386
- fn=get_history_names, inputs=[gr.State(False), user_name], outputs=[historyFileSelectDropdown]
387
  )
388
 
 
 
 
 
 
 
389
 
390
  # Chatbot
391
  cancelBtn.click(interrupt, [current_model], [])
392
 
393
- user_input.submit(**transfer_input_args).then(**chatgpt_predict_args).then(**end_outputing_args)
 
394
  user_input.submit(**get_usage_args)
395
 
396
- submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args, api_name="predict").then(**end_outputing_args)
 
 
 
397
  submitBtn.click(**get_usage_args)
398
 
399
- index_files.change(handle_file_upload, [current_model, index_files, chatbot, language_select_dropdown], [index_files, chatbot, status_display])
400
- summarize_btn.click(handle_summarize_index, [current_model, index_files, chatbot, language_select_dropdown], [chatbot, status_display])
 
 
 
 
401
 
402
  emptyBtn.click(
403
  reset,
404
- inputs=[current_model],
405
- outputs=[chatbot, status_display],
406
  show_progress=True,
407
- _js='clearChatbot',
408
  )
409
 
410
  retryBtn.click(**start_outputing_args).then(
@@ -452,17 +636,24 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
452
  two_column.change(update_doc_config, [two_column], None)
453
 
454
  # LLM Models
455
- keyTxt.change(set_key, [current_model, keyTxt], [user_api_key, status_display], api_name="set_key").then(**get_usage_args)
 
456
  keyTxt.submit(**get_usage_args)
457
- single_turn_checkbox.change(set_single_turn, [current_model, single_turn_checkbox], None)
458
- 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, user_api_key, keyTxt], show_progress=True, api_name="get_model")
459
- model_select_dropdown.change(toggle_like_btn_visibility, [model_select_dropdown], [like_dislike_area], show_progress=False)
460
- 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)
 
 
 
 
461
 
462
  # Template
463
- systemPromptTxt.change(set_system_prompt, [current_model, systemPromptTxt], None)
464
- templateRefreshBtn.click(get_template_names, None, [templateFileSelectDropdown])
465
- templateFileSelectDropdown.change(
 
 
466
  load_template,
467
  [templateFileSelectDropdown],
468
  [promptTemplates, templateSelectDropdown],
@@ -476,47 +667,80 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
476
  )
477
 
478
  # S&L
479
- saveHistoryBtn.click(
480
- save_chat_history,
481
  [current_model, saveFileName, chatbot, user_name],
482
- downloadFile,
483
  show_progress=True,
 
484
  )
485
- saveHistoryBtn.click(get_history_names, [gr.State(False), user_name], [historyFileSelectDropdown])
486
  exportMarkdownBtn.click(
487
  export_markdown,
488
  [current_model, saveFileName, chatbot, user_name],
489
- downloadFile,
490
  show_progress=True,
491
  )
492
  historyRefreshBtn.click(**refresh_history_args)
493
- historyDeleteBtn.click(delete_chat_history, [current_model, historyFileSelectDropdown, user_name], [status_display, historyFileSelectDropdown, chatbot], _js='(a,b,c)=>{return showConfirmationDialog(a, b, c);}')
494
- historyFileSelectDropdown.change(**load_history_from_file_args)
495
- downloadFile.change(upload_chat_history, [current_model, downloadFile, user_name], [saveFileName, systemPromptTxt, chatbot])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
496
 
497
  # Train
498
- dataset_selection.upload(handle_dataset_selection, dataset_selection, [dataset_preview_json, upload_to_openai_btn, openai_train_status])
499
- dataset_selection.clear(handle_dataset_clear, [], [dataset_preview_json, upload_to_openai_btn])
500
- upload_to_openai_btn.click(upload_to_openai, [dataset_selection], [openai_ft_file_id, openai_train_status], show_progress=True)
501
-
502
- openai_ft_file_id.change(lambda x: gr.update(interactive=True) if len(x) > 0 else gr.update(interactive=False), [openai_ft_file_id], [openai_start_train_btn])
503
- openai_start_train_btn.click(start_training, [openai_ft_file_id, openai_ft_suffix, openai_train_epoch_slider], [openai_train_status])
504
-
505
- openai_status_refresh_btn.click(get_training_status, [], [openai_train_status, add_to_models_btn])
506
- add_to_models_btn.click(add_to_models, [], [model_select_dropdown, openai_train_status], show_progress=True)
507
- openai_cancel_all_jobs_btn.click(cancel_all_jobs, [], [openai_train_status], show_progress=True)
 
 
 
 
 
 
 
 
508
 
509
  # Advanced
510
- max_context_length_slider.change(set_token_upper_limit, [current_model, max_context_length_slider], None)
511
- temperature_slider.change(set_temperature, [current_model, temperature_slider], None)
 
 
512
  top_p_slider.change(set_top_p, [current_model, top_p_slider], None)
513
- n_choices_slider.change(set_n_choices, [current_model, n_choices_slider], None)
514
- stop_sequence_txt.change(set_stop_sequence, [current_model, stop_sequence_txt], None)
515
- max_generation_slider.change(set_max_tokens, [current_model, max_generation_slider], None)
516
- presence_penalty_slider.change(set_presence_penalty, [current_model, presence_penalty_slider], None)
517
- frequency_penalty_slider.change(set_frequency_penalty, [current_model, frequency_penalty_slider], None)
518
- logit_bias_txt.change(set_logit_bias, [current_model, logit_bias_txt], None)
519
- user_identifier_txt.change(set_user_identifier, [current_model, user_identifier_txt], None)
 
 
 
 
 
 
 
520
 
521
  default_btn.click(
522
  reset_default, [], [apihostTxt, proxyTxt, status_display], show_progress=True
@@ -533,7 +757,7 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
533
  # [status_display],
534
  # show_progress=True,
535
  # )
536
- checkUpdateBtn.click(fn=None, _js='manualCheckUpdate')
537
 
538
  # Invisible elements
539
  updateChuanhuBtn.click(
@@ -542,6 +766,25 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
542
  [status_display],
543
  show_progress=True,
544
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
545
 
546
  logging.info(
547
  colorama.Back.GREEN
@@ -554,6 +797,8 @@ demo.title = i18n("川虎Chat 🚀")
554
  if __name__ == "__main__":
555
  reload_javascript()
556
  demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
557
- blocked_paths=["config.json"],
 
558
  favicon_path="./web_assets/favicon.ico",
 
559
  )
 
5
  format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s",
6
  )
7
 
8
+ from modules.models.models import get_model
9
+ from modules.train_func import *
10
+ from modules.repo import *
11
+ from modules.webui import *
12
+ from modules.overwrites import *
13
+ from modules.presets import *
14
+ from modules.utils import *
15
+ from modules.config import *
16
+ from modules import config
17
  import gradio as gr
18
+ import colorama
19
 
 
 
 
 
 
 
 
 
 
20
 
21
  logging.getLogger("httpx").setLevel(logging.WARNING)
22
 
 
26
  # with open("web_assets/css/ChuanhuChat.css", "r", encoding="utf-8") as f:
27
  # ChuanhuChatCSS = f.read()
28
 
29
+
30
  def create_new_model():
31
+ return get_model(model_name=MODELS[DEFAULT_MODEL], access_key=my_api_key)[0]
32
+
33
 
34
  with gr.Blocks(theme=small_and_beautiful_theme) as demo:
35
+ user_name = gr.Textbox("", visible=False)
36
+ promptTemplates = gr.State(load_template(get_template_names()[0], mode=2))
37
  user_question = gr.State("")
38
+ assert type(my_api_key) == str
39
  user_api_key = gr.State(my_api_key)
40
+ current_model = gr.State()
41
 
42
  topic = gr.State(i18n("未命名对话历史记录"))
43
 
44
+ with gr.Row(elem_id="chuanhu-header"):
45
+ gr.HTML(get_html("header_title.html").format(
46
+ app_title=CHUANHU_TITLE), elem_id="app-title")
47
  status_display = gr.Markdown(get_geoip(), elem_id="status-display")
48
  with gr.Row(elem_id="float-display"):
49
+ user_info = gr.Markdown(
50
+ value="getting user info...", elem_id="user-info")
51
  update_info = gr.HTML(get_html("update.html").format(
52
  current_version=repo_tag_html(),
53
  version_time=version_time(),
 
55
  update_btn=i18n("更新"),
56
  seenew_btn=i18n("详情"),
57
  ok_btn=i18n("好"),
58
+ ), visible=check_update)
59
+
60
+ with gr.Row(equal_height=True, elem_id="chuanhu-body"):
61
+
62
+ with gr.Column(elem_id="menu-area"):
63
+ with gr.Column(elem_id="chuanhu-history"):
64
+ with gr.Box():
65
+ with gr.Row(elem_id="chuanhu-history-header"):
66
+ with gr.Row(elem_id="chuanhu-history-search-row"):
67
+ with gr.Column(min_width=150, scale=2):
68
+ historySearchTextbox = gr.Textbox(show_label=False, container=False, placeholder=i18n(
69
+ "搜索(支持正则)..."), lines=1, elem_id="history-search-tb")
70
+ with gr.Column(min_width=52, scale=1, elem_id="gr-history-header-btns"):
71
+ uploadFileBtn = gr.UploadButton(
72
+ interactive=True, label="", file_types=[".json"], elem_id="gr-history-upload-btn")
73
+ historyRefreshBtn = gr.Button("", elem_id="gr-history-refresh-btn")
74
+
75
+
76
+ with gr.Row(elem_id="chuanhu-history-body"):
77
+ with gr.Column(scale=6, elem_id="history-select-wrap"):
78
+ historySelectList = gr.Radio(
79
+ label=i18n("从列表中加载对话"),
80
+ choices=get_history_names(),
81
+ value=get_first_history_name(),
82
+ # multiselect=False,
83
+ container=False,
84
+ elem_id="history-select-dropdown"
85
+ )
86
+ with gr.Row(visible=False):
87
+ with gr.Column(min_width=42, scale=1):
88
+ historyDeleteBtn = gr.Button(
89
+ "🗑️", elem_id="gr-history-delete-btn")
90
+ with gr.Column(min_width=42, scale=1):
91
+ historyDownloadBtn = gr.Button(
92
+ "⏬", elem_id="gr-history-download-btn")
93
+ with gr.Column(min_width=42, scale=1):
94
+ historyMarkdownDownloadBtn = gr.Button(
95
+ "⤵️", elem_id="gr-history-mardown-download-btn")
96
+ with gr.Row(visible=False):
97
+ with gr.Column(scale=6):
98
+ saveFileName = gr.Textbox(
99
+ show_label=True,
100
+ placeholder=i18n("设置文件名: 默认为.json,可选为.md"),
101
+ label=i18n("设置保存文件名"),
102
+ value=i18n("对话历史记录"),
103
+ elem_classes="no-container"
104
+ # container=False,
105
+ )
106
+ with gr.Column(scale=1):
107
+ renameHistoryBtn = gr.Button(
108
+ i18n("💾 保存对话"), elem_id="gr-history-save-btn")
109
+ exportMarkdownBtn = gr.Button(
110
+ i18n("📝 导出为 Markdown"), elem_id="gr-markdown-export-btn")
111
+
112
+ with gr.Column(elem_id="chuanhu-menu-footer"):
113
+ with gr.Row(elem_id="chuanhu-func-nav"):
114
+ gr.HTML(get_html("func_nav.html"))
115
+ # gr.HTML(get_html("footer.html").format(versions=versions_html()), elem_id="footer")
116
+ # gr.Markdown(CHUANHU_DESCRIPTION, elem_id="chuanhu-author")
117
+
118
+ with gr.Column(elem_id="chuanhu-area", scale=5):
119
+ with gr.Column(elem_id="chatbot-area"):
120
+ with gr.Row(elem_id="chatbot-header"):
121
  model_select_dropdown = gr.Dropdown(
122
+ label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True,
123
+ show_label=False, container=False, elem_id="model-select-dropdown"
124
  )
125
  lora_select_dropdown = gr.Dropdown(
126
+ label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False,
127
+ container=False,
128
  )
129
+ gr.HTML(get_html("chatbot_header_btn.html").format(
130
+ json_label=i18n("历史记录(JSON)"),
131
+ md_label=i18n("导出为 Markdown")
132
+ ), elem_id="chatbot-header-btn-bar")
133
+ with gr.Row():
134
+ chatbot = gr.Chatbot(
135
+ label="Chuanhu Chat",
136
+ elem_id="chuanhu-chatbot",
137
+ latex_delimiters=latex_delimiters_set,
138
+ # height=700,
139
+ show_label=False,
140
+ avatar_images=[config.user_avatar, config.bot_avatar],
141
+ show_share_button=False,
142
  )
143
+ with gr.Row(elem_id="chatbot-footer"):
144
+ with gr.Box(elem_id="chatbot-input-box"):
145
+ with gr.Row(elem_id="chatbot-input-row"):
146
+ gr.HTML(get_html("chatbot_more.html").format(
147
+ single_turn_label=i18n("单轮对话"),
148
+ websearch_label=i18n("在线搜索"),
149
+ upload_file_label=i18n("上传文件"),
150
+ uploaded_files_label=i18n("知识库文件"),
151
+ uploaded_files_tip=i18n("在工具箱中管理知识库文件")
152
+ ))
153
+ with gr.Row(elem_id="chatbot-input-tb-row"):
154
+ with gr.Column(min_width=225, scale=12):
155
+ user_input = gr.Textbox(
156
+ elem_id="user-input-tb",
157
+ show_label=False,
158
+ placeholder=i18n("在这里输入"),
159
+ elem_classes="no-container",
160
+ max_lines=5,
161
+ # container=False
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
162
  )
163
+ with gr.Column(min_width=42, scale=1, elem_id="chatbot-ctrl-btns"):
164
+ submitBtn = gr.Button(
165
+ value="", variant="primary", elem_id="submit-btn")
166
+ cancelBtn = gr.Button(
167
+ value="", variant="secondary", visible=False, elem_id="cancel-btn")
168
+ # Note: Buttons below are set invisible in UI. But they are used in JS.
169
+ with gr.Row(elem_id="chatbot-buttons", visible=False):
170
+ with gr.Column(min_width=120, scale=1):
171
+ emptyBtn = gr.Button(
172
+ i18n("🧹 新的对话"), elem_id="empty-btn"
173
+ )
174
+ with gr.Column(min_width=120, scale=1):
175
+ retryBtn = gr.Button(
176
+ i18n("🔄 重新生成"), elem_id="gr-retry-btn")
177
+ with gr.Column(min_width=120, scale=1):
178
+ delFirstBtn = gr.Button(i18n("🗑️ 删除最旧对话"))
179
+ with gr.Column(min_width=120, scale=1):
180
+ delLastBtn = gr.Button(
181
+ i18n("🗑️ 删除最新对话"), elem_id="gr-dellast-btn")
182
+ with gr.Row(visible=False) as like_dislike_area:
183
+ with gr.Column(min_width=20, scale=1):
184
+ likeBtn = gr.Button(
185
+ "👍", elem_id="gr-like-btn")
186
+ with gr.Column(min_width=20, scale=1):
187
+ dislikeBtn = gr.Button(
188
+ "👎", elem_id="gr-dislike-btn")
189
+
190
+ with gr.Column(elem_id="toolbox-area", scale=1):
191
+ # For CSS setting, there is an extra box. Don't remove it.
192
+ with gr.Box(elem_id="chuanhu-toolbox"):
193
+ with gr.Row():
194
+ gr.Markdown("## "+i18n("工具箱"))
195
+ gr.HTML(get_html("close_btn.html").format(
196
+ obj="toolbox"), elem_classes="close-btn")
197
+ with gr.Tabs(elem_id="chuanhu-toolbox-tabs"):
198
+ with gr.Tab(label=i18n("对话")):
199
+ with gr.Accordion(label="Prompt", open=True):
200
+ systemPromptTxt = gr.Textbox(
201
+ show_label=True,
202
+ placeholder=i18n("在这里输入System Prompt..."),
203
+ label="System prompt",
204
+ value=INITIAL_SYSTEM_PROMPT,
205
+ lines=8
206
+ )
207
+ retain_system_prompt_checkbox = gr.Checkbox(
208
+ label=i18n("新建对话保留Prompt"), value=False, visible=True, elem_classes="switch-checkbox")
209
+ with gr.Accordion(label=i18n("加载Prompt模板"), open=False):
210
  with gr.Column():
211
+ with gr.Row():
212
+ with gr.Column(scale=6):
213
+ templateFileSelectDropdown = gr.Dropdown(
214
+ label=i18n("选择Prompt模板集合文件"),
215
+ choices=get_template_names(),
216
+ multiselect=False,
217
+ value=get_template_names()[0],
218
+ container=False,
219
+ )
220
+ with gr.Column(scale=1):
221
+ templateRefreshBtn = gr.Button(
222
+ i18n("🔄 刷新"))
223
+ with gr.Row():
224
+ with gr.Column():
225
+ templateSelectDropdown = gr.Dropdown(
226
+ label=i18n("从Prompt模板中加载"),
227
+ choices=load_template(
228
+ get_template_names()[
229
+ 0], mode=1
230
+ ),
231
+ multiselect=False,
232
+ container=False,
233
+ )
234
+ gr.Markdown("---", elem_classes="hr-line")
235
+ with gr.Accordion(label=i18n("知识库"), open=True):
236
+ use_websearch_checkbox = gr.Checkbox(label=i18n(
237
+ "使用在线搜索"), value=False, elem_classes="switch-checkbox", elem_id="gr-websearch-cb", visible=False)
238
+ index_files = gr.Files(label=i18n(
239
+ "上传"), type="file", elem_id="upload-index-file")
240
+ two_column = gr.Checkbox(label=i18n(
241
+ "双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
242
+ summarize_btn = gr.Button(i18n("总结"))
243
+ # TODO: 公式ocr
244
+ # formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
245
+
246
+ with gr.Tab(label=i18n("参数")):
247
+ gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️"),
248
+ elem_id="advanced-warning")
249
+ with gr.Accordion(i18n("参数"), open=True):
250
+ temperature_slider = gr.Slider(
251
+ minimum=-0,
252
+ maximum=2.0,
253
+ value=1.0,
254
+ step=0.1,
255
+ interactive=True,
256
+ label="temperature",
257
+ )
258
+ top_p_slider = gr.Slider(
259
+ minimum=-0,
260
+ maximum=1.0,
261
+ value=1.0,
262
+ step=0.05,
263
+ interactive=True,
264
+ label="top-p",
265
+ )
266
+ n_choices_slider = gr.Slider(
267
+ minimum=1,
268
+ maximum=10,
269
+ value=1,
270
+ step=1,
271
+ interactive=True,
272
+ label="n choices",
273
+ )
274
+ stop_sequence_txt = gr.Textbox(
275
+ show_label=True,
276
+ placeholder=i18n("停止符,用英文逗号隔开..."),
277
+ label="stop",
278
+ value="",
279
+ lines=1,
280
+ )
281
+ max_context_length_slider = gr.Slider(
282
+ minimum=1,
283
+ maximum=32768,
284
+ value=2000,
285
+ step=1,
286
+ interactive=True,
287
+ label="max context",
288
+ )
289
+ max_generation_slider = gr.Slider(
290
+ minimum=1,
291
+ maximum=32768,
292
+ value=1000,
293
+ step=1,
294
+ interactive=True,
295
+ label="max generations",
296
+ )
297
+ presence_penalty_slider = gr.Slider(
298
+ minimum=-2.0,
299
+ maximum=2.0,
300
+ value=0.0,
301
+ step=0.01,
302
+ interactive=True,
303
+ label="presence penalty",
304
+ )
305
+ frequency_penalty_slider = gr.Slider(
306
+ minimum=-2.0,
307
+ maximum=2.0,
308
+ value=0.0,
309
+ step=0.01,
310
+ interactive=True,
311
+ label="frequency penalty",
312
+ )
313
+ logit_bias_txt = gr.Textbox(
314
+ show_label=True,
315
+ placeholder=f"word:likelihood",
316
+ label="logit bias",
317
+ value="",
318
+ lines=1,
319
+ )
320
+ user_identifier_txt = gr.Textbox(
321
+ show_label=True,
322
+ placeholder=i18n("用于定位滥用行为"),
323
+ label=i18n("用户名"),
324
+ value=user_name.value,
325
+ lines=1,
326
+ )
327
+ with gr.Tab(label=i18n("拓展")):
328
+ gr.Markdown(
329
+ "Will be here soon...\n(We hope)\n\nAnd we hope you can help us to make more extensions!")
330
+
331
+ # changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
332
+
333
+ with gr.Row(elem_id="popup-wrapper"):
334
+ with gr.Box(elem_id="chuanhu-popup"):
335
+ with gr.Box(elem_id="chuanhu-setting"):
336
+ with gr.Row():
337
+ gr.Markdown("## "+i18n("设置"))
338
+ gr.HTML(get_html("close_btn.html").format(
339
+ obj="box"), elem_classes="close-btn")
340
+ with gr.Tabs(elem_id="chuanhu-setting-tabs"):
341
+ with gr.Tab(label=i18n("模型")):
342
+ keyTxt = gr.Textbox(
343
  show_label=True,
344
+ placeholder=f"Your API-key...",
345
+ value=hide_middle_chars(user_api_key.value),
346
+ type="password",
347
+ visible=not HIDE_MY_KEY,
348
+ label="API-Key",
349
  )
350
+ if multi_api_key:
351
+ usageTxt = gr.Markdown(i18n(
352
+ "多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
353
+ else:
354
+ usageTxt = gr.Markdown(i18n(
355
+ "**发送消息** 或 **提交key** 以显示额度"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
356
+ # model_select_dropdown = gr.Dropdown(
357
+ # label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
358
+ # )
359
+ # lora_select_dropdown = gr.Dropdown(
360
+ # label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
361
+ # )
362
+ # with gr.Row():
363
+
364
+ language_select_dropdown = gr.Dropdown(
365
+ label=i18n("选择回复语言(针对搜索&索引功能)"),
366
+ choices=REPLY_LANGUAGES,
367
+ multiselect=False,
368
+ value=REPLY_LANGUAGES[0],
369
  )
370
+
371
+ with gr.Tab(label=i18n("高级")):
372
+ gr.HTML(get_html("appearance_switcher.html").format(
373
+ label=i18n("切换亮暗色主题")), elem_classes="insert-block", visible=False)
374
+ use_streaming_checkbox = gr.Checkbox(
375
+ label=i18n("实时传输回答"), value=True, visible=ENABLE_STREAMING_OPTION, elem_classes="switch-checkbox"
 
 
 
 
 
 
 
 
 
376
  )
377
+ name_chat_method = gr.Dropdown(
378
+ label=i18n("对话命名方式"),
379
+ choices=HISTORY_NAME_METHODS,
380
+ multiselect=False,
 
381
  interactive=True,
382
+ value=HISTORY_NAME_METHODS[chat_name_method_index],
 
 
 
 
 
 
 
 
 
 
 
 
 
 
383
  )
384
+ single_turn_checkbox = gr.Checkbox(label=i18n(
385
+ "单轮对话"), value=False, elem_classes="switch-checkbox", elem_id="gr-single-session-cb", visible=False)
386
+ # checkUpdateBtn = gr.Button(i18n("🔄 检查更新..."), visible=check_update)
387
 
388
+ with gr.Tab(i18n("网络")):
389
+ gr.Markdown(
390
+ i18n("⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置"), elem_id="netsetting-warning")
391
  default_btn = gr.Button(i18n("🔙 恢复默认网络设置"))
392
  # 网络代理
393
  proxyTxt = gr.Textbox(
 
413
  # container=False,
414
  elem_classes="view-only-textbox no-container",
415
  )
 
 
416
 
417
+ with gr.Tab(label=i18n("关于"), elem_id="about-tab"):
418
+ gr.Markdown(
419
+ '<img alt="Chuanhu Chat logo" src="file=web_assets/icon/any-icon-512.png" style="max-width: 144px;">')
420
+ gr.Markdown("# "+i18n("川虎Chat"))
421
+ gr.HTML(get_html("footer.html").format(
422
+ versions=versions_html()), elem_id="footer")
423
+ gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
424
+
425
+ with gr.Box(elem_id="chuanhu-training"):
426
+ with gr.Row():
427
+ gr.Markdown("## "+i18n("训练"))
428
+ gr.HTML(get_html("close_btn.html").format(
429
+ obj="box"), elem_classes="close-btn")
430
+ with gr.Tabs(elem_id="chuanhu-training-tabs"):
431
+ with gr.Tab(label="OpenAI "+i18n("微调")):
432
+ openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n(
433
+ "查看[使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)"))
434
+
435
+ with gr.Tab(label=i18n("准备数据集")):
436
+ dataset_preview_json = gr.JSON(
437
+ label=i18n("数据集预览"))
438
+ dataset_selection = gr.Files(label=i18n("选择数据集"), file_types=[
439
+ ".xlsx", ".jsonl"], file_count="single")
440
+ upload_to_openai_btn = gr.Button(
441
+ i18n("上传到OpenAI"), variant="primary", interactive=False)
442
+
443
+ with gr.Tab(label=i18n("训练")):
444
+ openai_ft_file_id = gr.Textbox(label=i18n(
445
+ "文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动填充"))
446
+ openai_ft_suffix = gr.Textbox(label=i18n(
447
+ "模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
448
+ openai_train_epoch_slider = gr.Slider(label=i18n(
449
+ "训练轮数(Epochs)"), minimum=1, maximum=100, value=3, step=1, interactive=True)
450
+ openai_start_train_btn = gr.Button(
451
+ i18n("开始训练"), variant="primary", interactive=False)
452
+
453
+ with gr.Tab(label=i18n("状态")):
454
+ openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
455
+ openai_cancel_all_jobs_btn = gr.Button(
456
+ i18n("取消所有任务"))
457
+ add_to_models_btn = gr.Button(
458
+ i18n("添加训练好的模型到模型列表"), interactive=False)
459
+
460
+ with gr.Box(elem_id="web-config", visible=False):
461
+ gr.HTML(get_html('web_config.html').format(
462
+ enableCheckUpdate_config=check_update,
463
+ hideHistoryWhenNotLoggedIn_config=hide_history_when_not_logged_in,
464
+ forView_i18n=i18n("仅供查看"),
465
+ deleteConfirm_i18n_pref=i18n("你真的要删除 "),
466
+ deleteConfirm_i18n_suff=i18n(" 吗?"),
467
+ usingLatest_i18n=i18n("您使用的就是最新版!"),
468
+ updatingMsg_i18n=i18n("正在尝试更新..."),
469
+ updateSuccess_i18n=i18n("更新成功,请重启本程序"),
470
+ updateFailure_i18n=i18n(
471
+ "更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)"),
472
+ regenerate_i18n=i18n("重新生成"),
473
+ deleteRound_i18n=i18n("删除这轮问答"),
474
+ renameChat_i18n=i18n("重命名该对话"),
475
+ validFileName_i18n=i18n("请输入有效的文件名,不要包含以下特殊字符:"),
476
+ ))
477
+ with gr.Box(elem_id="fake-gradio-components", visible=False):
478
+ updateChuanhuBtn = gr.Button(
479
+ visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
480
+ changeSingleSessionBtn = gr.Button(
481
+ visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
482
+ changeOnlineSearchBtn = gr.Button(
483
+ visible=False, elem_classes="invisible-btn", elem_id="change-online-search-btn")
484
+ historySelectBtn = gr.Button(
485
+ visible=False, elem_classes="invisible-btn", elem_id="history-select-btn") # Not used
486
 
487
  # https://github.com/gradio-app/gradio/pull/3296
488
+
489
  def create_greeting(request: gr.Request):
490
+ if hasattr(request, "username") and request.username: # is not None or is not ""
491
  logging.info(f"Get User Name: {request.username}")
492
+ user_info, user_name = gr.Markdown.update(
493
+ value=f"User: {request.username}"), request.username
494
  else:
495
+ user_info, user_name = gr.Markdown.update(
496
+ value=f"", visible=False), ""
497
+ current_model = get_model(
498
+ model_name=MODELS[DEFAULT_MODEL], access_key=my_api_key)[0]
499
  current_model.set_user_identifier(user_name)
500
+ if not hide_history_when_not_logged_in or user_name:
501
+ filename, system_prompt, chatbot = current_model.auto_load()
502
+ else:
503
+ system_prompt = gr.update()
504
+ filename = gr.update()
505
+ chatbot = gr.Chatbot.update(label=MODELS[DEFAULT_MODEL])
506
+ return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), filename, system_prompt, chatbot, init_history_list(user_name)
507
+ demo.load(create_greeting, inputs=None, outputs=[
508
+ user_info, user_name, current_model, like_dislike_area, saveFileName, systemPromptTxt, chatbot, historySelectList], api_name="load")
509
  chatgpt_predict_args = dict(
510
  fn=predict,
511
  inputs=[
 
537
  )
538
 
539
  transfer_input_args = dict(
540
+ fn=transfer_input, inputs=[user_input], outputs=[
541
+ user_question, user_input, submitBtn, cancelBtn], show_progress=True
542
  )
543
 
544
  get_usage_args = dict(
545
+ fn=billing_info, inputs=[current_model], outputs=[
546
+ usageTxt], show_progress=False
547
  )
548
 
549
  load_history_from_file_args = dict(
550
  fn=load_chat_history,
551
+ inputs=[current_model, historySelectList, user_name],
552
  outputs=[saveFileName, systemPromptTxt, chatbot]
553
  )
554
 
555
  refresh_history_args = dict(
556
+ fn=get_history_list, inputs=[user_name], outputs=[historySelectList]
557
  )
558
 
559
+ auto_name_chat_history_args = dict(
560
+ fn=auto_name_chat_history,
561
+ inputs=[current_model, name_chat_method, user_question, chatbot, user_name, single_turn_checkbox],
562
+ outputs=[historySelectList],
563
+ show_progress=False,
564
+ )
565
 
566
  # Chatbot
567
  cancelBtn.click(interrupt, [current_model], [])
568
 
569
+ user_input.submit(**transfer_input_args).then(**
570
+ chatgpt_predict_args).then(**end_outputing_args).then(**auto_name_chat_history_args)
571
  user_input.submit(**get_usage_args)
572
 
573
+ # user_input.submit(auto_name_chat_history, [current_model, user_question, chatbot, user_name], [historySelectList], show_progress=False)
574
+
575
+ submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args,
576
+ api_name="predict").then(**end_outputing_args).then(**auto_name_chat_history_args)
577
  submitBtn.click(**get_usage_args)
578
 
579
+ # submitBtn.click(auto_name_chat_history, [current_model, user_question, chatbot, user_name], [historySelectList], show_progress=False)
580
+
581
+ index_files.upload(handle_file_upload, [current_model, index_files, chatbot, language_select_dropdown], [
582
+ index_files, chatbot, status_display])
583
+ summarize_btn.click(handle_summarize_index, [
584
+ current_model, index_files, chatbot, language_select_dropdown], [chatbot, status_display])
585
 
586
  emptyBtn.click(
587
  reset,
588
+ inputs=[current_model, retain_system_prompt_checkbox],
589
+ outputs=[chatbot, status_display, historySelectList, systemPromptTxt],
590
  show_progress=True,
591
+ _js='(a,b)=>{return clearChatbot(a,b);}',
592
  )
593
 
594
  retryBtn.click(**start_outputing_args).then(
 
636
  two_column.change(update_doc_config, [two_column], None)
637
 
638
  # LLM Models
639
+ keyTxt.change(set_key, [current_model, keyTxt], [
640
+ user_api_key, status_display], api_name="set_key").then(**get_usage_args)
641
  keyTxt.submit(**get_usage_args)
642
+ single_turn_checkbox.change(
643
+ set_single_turn, [current_model, single_turn_checkbox], None)
644
+ 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], [
645
+ current_model, status_display, chatbot, lora_select_dropdown, user_api_key, keyTxt], show_progress=True, api_name="get_model")
646
+ model_select_dropdown.change(toggle_like_btn_visibility, [model_select_dropdown], [
647
+ like_dislike_area], show_progress=False)
648
+ lora_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider,
649
+ top_p_slider, systemPromptTxt, user_name, current_model], [current_model, status_display, chatbot], show_progress=True)
650
 
651
  # Template
652
+ systemPromptTxt.change(set_system_prompt, [
653
+ current_model, systemPromptTxt], None)
654
+ templateRefreshBtn.click(get_template_dropdown, None, [
655
+ templateFileSelectDropdown])
656
+ templateFileSelectDropdown.input(
657
  load_template,
658
  [templateFileSelectDropdown],
659
  [promptTemplates, templateSelectDropdown],
 
667
  )
668
 
669
  # S&L
670
+ renameHistoryBtn.click(
671
+ rename_chat_history,
672
  [current_model, saveFileName, chatbot, user_name],
673
+ [historySelectList],
674
  show_progress=True,
675
+ _js='(a,b,c,d)=>{return saveChatHistory(a,b,c,d);}'
676
  )
 
677
  exportMarkdownBtn.click(
678
  export_markdown,
679
  [current_model, saveFileName, chatbot, user_name],
680
+ [],
681
  show_progress=True,
682
  )
683
  historyRefreshBtn.click(**refresh_history_args)
684
+ historyDeleteBtn.click(delete_chat_history, [current_model, historySelectList, user_name], [status_display, historySelectList, chatbot], _js='(a,b,c)=>{return showConfirmationDialog(a, b, c);}').then(
685
+ reset,
686
+ inputs=[current_model, retain_system_prompt_checkbox],
687
+ outputs=[chatbot, status_display, historySelectList, systemPromptTxt],
688
+ show_progress=True,
689
+ _js='(a,b)=>{return clearChatbot(a,b);}',
690
+ )
691
+ historySelectList.input(**load_history_from_file_args)
692
+ uploadFileBtn.upload(upload_chat_history, [current_model, uploadFileBtn, user_name], [
693
+ saveFileName, systemPromptTxt, chatbot]).then(**refresh_history_args)
694
+ historyDownloadBtn.click(None, [
695
+ user_name, historySelectList], None, _js='(a,b)=>{return downloadHistory(a,b,".json");}')
696
+ historyMarkdownDownloadBtn.click(None, [
697
+ user_name, historySelectList], None, _js='(a,b)=>{return downloadHistory(a,b,".md");}')
698
+ historySearchTextbox.input(
699
+ filter_history,
700
+ [user_name, historySearchTextbox],
701
+ [historySelectList]
702
+ )
703
 
704
  # Train
705
+ dataset_selection.upload(handle_dataset_selection, dataset_selection, [
706
+ dataset_preview_json, upload_to_openai_btn, openai_train_status])
707
+ dataset_selection.clear(handle_dataset_clear, [], [
708
+ dataset_preview_json, upload_to_openai_btn])
709
+ upload_to_openai_btn.click(upload_to_openai, [dataset_selection], [
710
+ openai_ft_file_id, openai_train_status], show_progress=True)
711
+
712
+ openai_ft_file_id.change(lambda x: gr.update(interactive=True) if len(
713
+ x) > 0 else gr.update(interactive=False), [openai_ft_file_id], [openai_start_train_btn])
714
+ openai_start_train_btn.click(start_training, [
715
+ openai_ft_file_id, openai_ft_suffix, openai_train_epoch_slider], [openai_train_status])
716
+
717
+ openai_status_refresh_btn.click(get_training_status, [], [
718
+ openai_train_status, add_to_models_btn])
719
+ add_to_models_btn.click(add_to_models, [], [
720
+ model_select_dropdown, openai_train_status], show_progress=True)
721
+ openai_cancel_all_jobs_btn.click(
722
+ cancel_all_jobs, [], [openai_train_status], show_progress=True)
723
 
724
  # Advanced
725
+ max_context_length_slider.change(
726
+ set_token_upper_limit, [current_model, max_context_length_slider], None)
727
+ temperature_slider.change(
728
+ set_temperature, [current_model, temperature_slider], None)
729
  top_p_slider.change(set_top_p, [current_model, top_p_slider], None)
730
+ n_choices_slider.change(
731
+ set_n_choices, [current_model, n_choices_slider], None)
732
+ stop_sequence_txt.change(
733
+ set_stop_sequence, [current_model, stop_sequence_txt], None)
734
+ max_generation_slider.change(
735
+ set_max_tokens, [current_model, max_generation_slider], None)
736
+ presence_penalty_slider.change(
737
+ set_presence_penalty, [current_model, presence_penalty_slider], None)
738
+ frequency_penalty_slider.change(
739
+ set_frequency_penalty, [current_model, frequency_penalty_slider], None)
740
+ logit_bias_txt.change(
741
+ set_logit_bias, [current_model, logit_bias_txt], None)
742
+ user_identifier_txt.change(set_user_identifier, [
743
+ current_model, user_identifier_txt], None)
744
 
745
  default_btn.click(
746
  reset_default, [], [apihostTxt, proxyTxt, status_display], show_progress=True
 
757
  # [status_display],
758
  # show_progress=True,
759
  # )
760
+ # checkUpdateBtn.click(fn=None, _js='manualCheckUpdate')
761
 
762
  # Invisible elements
763
  updateChuanhuBtn.click(
 
766
  [status_display],
767
  show_progress=True,
768
  )
769
+ changeSingleSessionBtn.click(
770
+ fn=lambda value: gr.Checkbox.update(value=value),
771
+ inputs=[single_turn_checkbox],
772
+ outputs=[single_turn_checkbox],
773
+ _js='(a)=>{return bgChangeSingleSession(a);}'
774
+ )
775
+ changeOnlineSearchBtn.click(
776
+ fn=lambda value: gr.Checkbox.update(value=value),
777
+ inputs=[use_websearch_checkbox],
778
+ outputs=[use_websearch_checkbox],
779
+ _js='(a)=>{return bgChangeOnlineSearch(a);}'
780
+ )
781
+ historySelectBtn.click( # This is an experimental feature... Not actually used.
782
+ fn=load_chat_history,
783
+ inputs=[current_model, historySelectList],
784
+ outputs=[saveFileName, systemPromptTxt, chatbot],
785
+ _js='(a,b)=>{return bgSelectHistory(a,b);}'
786
+ )
787
+
788
 
789
  logging.info(
790
  colorama.Back.GREEN
 
797
  if __name__ == "__main__":
798
  reload_javascript()
799
  demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
800
+ allowed_paths=["history", "web_assets"],
801
+ auth=auth_from_conf if authflag else None,
802
  favicon_path="./web_assets/favicon.ico",
803
+ inbrowser=not dockerflag, # 禁止在docker下开启inbrowser
804
  )
README.md CHANGED
@@ -1,13 +1,15 @@
 
1
  ---
2
  title: ChuanhuChatGPT
3
  emoji: 🐯
4
  colorFrom: yellow
5
  colorTo: yellow
6
  sdk: gradio
7
- sdk_version: 3.40.0
8
  app_file: ChuanhuChatbot.py
9
  pinned: false
10
  license: gpl-3.0
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
+ ```
2
  ---
3
  title: ChuanhuChatGPT
4
  emoji: 🐯
5
  colorFrom: yellow
6
  colorTo: yellow
7
  sdk: gradio
8
+ sdk_version: 3.43.2
9
  app_file: ChuanhuChatbot.py
10
  pinned: false
11
  license: gpl-3.0
12
  ---
13
 
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
15
+ ```
config_example.json CHANGED
@@ -11,6 +11,10 @@
11
  "midjourney_proxy_api_secret": "", // 你的 MidJourney Proxy API Secret,用于鉴权访问 api,可选
12
  "midjourney_discord_proxy_url": "", // 你的 MidJourney Discord Proxy URL,用于对生成对图进行反代,可选
13
  "midjourney_temp_folder": "./tmp", // 你的 MidJourney 临时文件夹,用于存放生成的图片,填空则关闭自动下载切图(直接显示MJ的四宫格图)
 
 
 
 
14
 
15
 
16
  //== Azure ==
@@ -23,14 +27,15 @@
23
  "azure_embedding_model_name": "text-embedding-ada-002", // 你的 Azure OpenAI Embedding 模型名称
24
 
25
  //== 基础配置 ==
26
- "language": "auto", // 界面语言,可选"auto", "zh-CN", "en-US", "ja-JP", "ko-KR", "sv-SE"
27
  "users": [], // 用户列表,[[用户名1, 密码1], [用户名2, 密码2], ...]
28
  "local_embedding": false, //是否在本地编制索引
29
  "hide_history_when_not_logged_in": false, //未登录情况下是否不展示对话历史
30
  "check_update": true, //是否启用检查更新
31
  "default_model": "gpt-3.5-turbo", // 默认模型
32
- "bot_avatar": "default", // 机器人头像,可填写图片链接、Data URL (base64),或者"none"(不显示头像)
33
- "user_avatar": "default", // 用户头像,可填写图片链接、Data URL (base64),或者"none"(不显示头像)
 
34
 
35
  //== API 用量 ==
36
  "show_api_billing": false, //是否显示OpenAI API用量(启用需要填写sensitive_id)
@@ -57,11 +62,13 @@
57
  //== 高级配置 ==
58
  // 是否多个API Key轮换使用
59
  "multi_api_key": false,
60
- "api_key_list": [
61
- "sk-xxxxxxxxxxxxxxxxxxxxxxxx1",
62
- "sk-xxxxxxxxxxxxxxxxxxxxxxxx2",
63
- "sk-xxxxxxxxxxxxxxxxxxxxxxxx3"
64
- ],
 
 
65
  // 自定义OpenAI API Base
66
  // "openai_api_base": "https://api.openai.com",
67
  // 自定义使用代理(请替换代理URL)
 
11
  "midjourney_proxy_api_secret": "", // 你的 MidJourney Proxy API Secret,用于鉴权访问 api,可选
12
  "midjourney_discord_proxy_url": "", // 你的 MidJourney Discord Proxy URL,用于对生成对图进行反代,可选
13
  "midjourney_temp_folder": "./tmp", // 你的 MidJourney 临时文件夹,用于存放生成的图片,填空则关闭自动下载切图(直接显示MJ的四宫格图)
14
+ "spark_appid": "", // 你的 讯飞星火大模型 API AppID,用于讯飞星火大模型对话模型
15
+ "spark_api_key": "", // 你的 讯飞星火大模型 API Key,用于讯飞星火大模型对话模型
16
+ "spark_api_secret": "", // 你的 讯飞星火大模型 API Secret,用于讯飞星火大模型对话模型
17
+ "claude_api_secret":"",// 你的 Claude API Secret,用于 Claude 对话模型
18
 
19
 
20
  //== Azure ==
 
27
  "azure_embedding_model_name": "text-embedding-ada-002", // 你的 Azure OpenAI Embedding 模型名称
28
 
29
  //== 基础配置 ==
30
+ "language": "auto", // 界面语言,可选"auto", "zh_CN", "en_US", "ja_JP", "ko_KR", "sv_SE", "ru_RU", "vi_VN"
31
  "users": [], // 用户列表,[[用户名1, 密码1], [用户名2, 密码2], ...]
32
  "local_embedding": false, //是否在本地编制索引
33
  "hide_history_when_not_logged_in": false, //未登录情况下是否不展示对话历史
34
  "check_update": true, //是否启用检查更新
35
  "default_model": "gpt-3.5-turbo", // 默认模型
36
+ "chat_name_method_index": 2, // 选择对话名称的方法。0: 使用日期时间命名;1: 使用第一条提问命名,2: 使用模型自动总结
37
+ "bot_avatar": "default", // 机器人头像,可填写本地或网络图片链接,或者"none"(不显示头像)
38
+ "user_avatar": "default", // 用户头像,可填写本地或网络图片链接,或者"none"(不显示头像)
39
 
40
  //== API 用量 ==
41
  "show_api_billing": false, //是否显示OpenAI API用量(启用需要填写sensitive_id)
 
62
  //== 高级配置 ==
63
  // 是否多个API Key轮换使用
64
  "multi_api_key": false,
65
+ // "available_models": ["GPT3.5 Turbo", "GPT4 Turbo", "GPT4 Vision"], // 可用的模型列表,将覆盖默认的可用模型列表
66
+ // "extra_models": ["模型名称3", "模型名称4", ...], // 额外的模型,将添加到可用的模型列表之后
67
+ // "api_key_list": [
68
+ // "sk-xxxxxxxxxxxxxxxxxxxxxxxx1",
69
+ // "sk-xxxxxxxxxxxxxxxxxxxxxxxx2",
70
+ // "sk-xxxxxxxxxxxxxxxxxxxxxxxx3"
71
+ // ],
72
  // 自定义OpenAI API Base
73
  // "openai_api_base": "https://api.openai.com",
74
  // 自定义使用代理(请替换代理URL)
locale/en_US.json CHANGED
@@ -1,87 +1,141 @@
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
- "# ⚠️ 务必谨慎更改 ⚠️": "# ⚠️ Caution: Changes require care. ⚠️",
36
- "参数": "Parameters",
37
- "停止符,用英文逗号隔开...": "Type in stop token here, separated by comma...",
38
- "用于定位滥用行为": "Used to locate abuse",
39
- "用户名": "Username",
40
- "在这里输入API-Host...": "Type in API-Host here...",
41
- "🔄 切换API地址": "🔄 Switch API Address",
42
- "未设置代理...": "No proxy...",
43
  "代理地址": "Proxy address",
44
- "🔄 设置代理地址": "🔄 Set Proxy Address",
45
- "🔙 恢复默认网络设置": "🔙 Reset Network Settings",
46
- "🔄 检查更新...": "🔄 Check for Update...",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  "取消": "Cancel",
48
- "更新": "Update",
49
- "详情": "Details",
 
 
 
 
 
 
50
  "好": "OK",
51
- "更新成功,请重启本程序": "Updated successfully, please restart this program",
52
- "更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)": "Update failed, please try [manually updating](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)",
 
 
 
 
 
53
  "川虎Chat 🚀": "Chuanhu Chat 🚀",
 
 
54
  "开始实时传输回答……": "Start streaming output...",
55
- "Token 计数: ": "Token Count: ",
56
- ",本次对话累计消耗了 ": ", Total cost for this dialogue is ",
57
- "**获取API使用情况失败**": "**Failed to get API usage**",
58
- "**获取API使用情况失败**,需在填写`config.json`中正确填写sensitive_id": "**Failed to get API usage**, correct sensitive_id needed in `config.json`",
59
- "**获取API使用情况失败**,sensitive_id错误或已过期": "**Failed to get API usage**, wrong or expired sensitive_id",
60
- "**本月使用金额** ": "**Monthly usage** ",
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  "本月使用金额": "Monthly usage",
62
- "获取API使用情况失败:": "Failed to get API usage:",
63
- "API密钥更改为了": "The API key is changed to",
64
- "JSON解析错误,收到的内容: ": "JSON parsing error, received content: ",
 
 
65
  "模型设置为了:": "Model is set to: ",
66
- "☹️发生了错误:": "☹️Error: ",
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  "获取对话时发生错误,请查看后台日志": "Error occurred when getting dialogue, check the background log",
 
 
 
 
 
 
 
 
 
68
  "请检查网络连接,或者API-Key是否有效。": "Check the network connection or whether the API-Key is valid.",
69
- "连接超时,无法获取对话。": "Connection timed out, unable to get dialogue.",
70
- "读取超时,无法获取对话。": "Read timed out, unable to get dialogue.",
71
- "代理错误,无法获取对话。": "Proxy error, unable to get dialogue.",
72
- "SSL错误,无法获取对话。": "SSL error, unable to get dialogue.",
73
- "API key为空,请检查是否输入正确。": "API key is empty, check whether it is entered correctly.",
74
  "请输入对话内容。": "Enter the content of the conversation.",
 
 
75
  "账单信息不适用": "Billing information is not applicable",
76
- "由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536)、[明昭MZhao](https://space.bilibili.com/24807452) 和 [Keldos](https://github.com/Keldos-Li) 开发<br />访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本": "Developed by Bilibili [土川虎虎虎](https://space.bilibili.com/29125536), [明昭MZhao](https://space.bilibili.com/24807452) and [Keldos](https://github.com/Keldos-Li)\n\nDownload latest code from [GitHub](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
77
- "切换亮暗色主题": "Switch light/dark theme",
78
- "您的IP区域:未知。": "Your IP region: Unknown.",
79
- "获取IP地理位置失败。原因:": "Failed to get IP location. Reason: ",
80
- "。你仍然可以使用聊天功能。": ". You can still use the chat function.",
81
- "您的IP区域:": "Your IP region: ",
82
- "总结": "Summarize",
83
- "生成内容总结中……": "Generating content summary...",
84
- "由于下面的原因,Google 拒绝返回 PaLM 的回答:\n\n": "Due to the following reasons, Google refuses to provide an answer to PaLM: \n\n",
85
- "---\n⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "---\n⚠️ To ensure the security of API-Key, please modify the network settings in the configuration file `config.json`.",
86
- "网络参数": "Network parameter"
87
- }
 
 
 
 
 
 
 
 
 
 
 
1
  {
2
+ " 吗?": " ?",
3
+ "# ⚠️ 务必谨慎更改 ⚠️": "# ⚠️ Caution: Changes require care. ⚠️",
 
 
 
 
 
 
4
  "**发送消息** 或 **提交key** 以显示额度": "**Send message** or **Submit key** to display credit",
5
+ "**本月使用金额** ": "**Monthly usage** ",
6
+ "**获取API使用情况失败**": "**Failed to get API usage**",
7
+ "**获取API使用情况失败**,sensitive_id错误或已过期": "**Failed to get API usage**, wrong or expired sensitive_id",
8
+ "**获取API使用情况失败**,需在填写`config.json`中正确填写sensitive_id": "**Failed to get API usage**, correct sensitive_id needed in `config.json`",
9
+ "API key为空,请检查是否输入正确。": "API key is empty, check whether it is entered correctly.",
10
+ "API密钥更改为了": "The API key is changed to",
11
+ "JSON解析错误,收到的内容: ": "JSON parsing error, received content: ",
12
+ "SSL错误,无法获取对话。": "SSL error, unable to get dialogue.",
13
+ "Token 计数: ": "Token Count: ",
14
+ "☹️发生了错误:": "☹️Error: ",
15
+ "⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "⚠️ To ensure the security of API-Key, please modify the network settings in the configuration file `config.json`.",
16
+ "。你仍然可以使用聊天功能。": ". You can still use the chat function.",
17
+ "上传": "Upload",
18
+ "上传了": "Uploaded",
19
+ "上传到 OpenAI 后自动填充": "Automatically filled after uploading to OpenAI",
20
+ "上传到OpenAI": "Upload to OpenAI",
21
+ "上传文件": "Upload files",
22
+ "仅供查看": "For viewing only",
23
  "从Prompt模板中加载": "Load from Prompt Template",
 
 
24
  "从列表中加载对话": "Load dialog from list",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  "代理地址": "Proxy address",
26
+ "代理错误,无法获取对话。": "Proxy error, unable to get dialogue.",
27
+ "你没有权限访问 GPT4,[进一步了解](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/843)": "You do not have permission to access GPT-4, [learn more](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/843)",
28
+ "你没有选择任何对话历史": "You have not selected any conversation history.",
29
+ "你真的要删除 ": "Are you sure you want to delete ",
30
+ "使用在线搜索": "Use online search",
31
+ "停止符,用英文逗号隔开...": "Type in stop token here, separated by comma...",
32
+ "关于": "About",
33
+ "准备数据集": "Prepare Dataset",
34
+ "切换亮暗色主题": "Switch light/dark theme",
35
+ "删除对话历史成功": "Successfully deleted conversation history.",
36
+ "删除这轮问答": "Delete this round of Q&A",
37
+ "刷新状态": "Refresh Status",
38
+ "��余配额不足,[进一步了解](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#you-exceeded-your-current-quota-please-check-your-plan-and-billing-details)": "Insufficient remaining quota, [learn more](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#you-exceeded-your-current-quota-please-check-your-plan-and-billing-details)",
39
+ "加载Prompt模板": "Load Prompt Template",
40
+ "单轮对话": "Single-turn",
41
+ "历史记录(JSON)": "History file (JSON)",
42
+ "参数": "Parameters",
43
+ "双栏pdf": "Two-column pdf",
44
  "取消": "Cancel",
45
+ "取消所有任务": "Cancel All Tasks",
46
+ "可选,用于区分不同的模型": "Optional, used to distinguish different models",
47
+ "启用的工具:": "Enabled tools: ",
48
+ "在工具箱中管理知识库文件": "Manage knowledge base files in the toolbox",
49
+ "在线搜索": "Web search",
50
+ "在这里输入": "Type in here",
51
+ "在这里输入System Prompt...": "Type in System Prompt here...",
52
+ "多账号模式已开启,无需输入key,可直接开始对话": "Multi-account mode is enabled, no need to enter key, you can start the dialogue directly",
53
  "好": "OK",
54
+ "实时传输回答": "Stream output",
55
+ "对话": "Dialogue",
56
+ "对话历史": "Conversation history",
57
+ "对话历史记录": "Dialog History",
58
+ "对话命名方式": "History naming method",
59
+ "导出为 Markdown": "Export as Markdown",
60
+ "川虎Chat": "Chuanhu Chat",
61
  "川虎Chat 🚀": "Chuanhu Chat 🚀",
62
+ "工具箱": "Toolbox",
63
+ "已经被删除啦": "It has been deleted.",
64
  "开始实时传输回答……": "Start streaming output...",
65
+ "开始训练": "Start Training",
66
+ "微调": "Fine-tuning",
67
+ "总结": "Summarize",
68
+ "总结完成": "Summary completed.",
69
+ "您使用的就是最新版!": "You are using the latest version!",
70
+ "您的IP区域:": "Your IP region: ",
71
+ "您的IP区域:未知。": "Your IP region: Unknown.",
72
+ "拓展": "Extensions",
73
+ "搜索(支持正则)...": "Search (supports regex)...",
74
+ "数据集预览": "Dataset Preview",
75
+ "文件ID": "File ID",
76
+ "新对话 ": "New Chat ",
77
+ "新建对话保留Prompt": "Retain Prompt For New Chat",
78
+ "暂时未知": "Unknown",
79
+ "更新": "Update",
80
+ "更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)": "Update failed, please try [manually updating](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)",
81
+ "更新成功,请重启本程序": "Updated successfully, please restart this program",
82
+ "未命名对话历史记录": "Unnamed Dialog History",
83
+ "未设置代理...": "No proxy...",
84
  "本月使用金额": "Monthly usage",
85
+ "查看[使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)": "View the [usage guide](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35) for more details",
86
+ "根据日期时间": "By date and time",
87
+ "模型": "Model",
88
+ "模型名称后缀": "Model Name Suffix",
89
+ "模型自动总结(消耗tokens)": "Auto summary by LLM (Consume tokens)",
90
  "模型设置为了:": "Model is set to: ",
91
+ "正在尝试更新...": "Trying to update...",
92
+ "添加训练好的模型到模型列表": "Add trained model to the model list",
93
+ "状态": "Status",
94
+ "生成内容总结中……": "Generating content summary...",
95
+ "用于定位滥用行为": "Used to locate abuse",
96
+ "用户名": "Username",
97
+ "由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536)、[明昭MZhao](https://space.bilibili.com/24807452) 和 [Keldos](https://github.com/Keldos-Li) 开发<br />访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本": "Developed by Bilibili [土川虎虎虎](https://space.bilibili.com/29125536), [明昭MZhao](https://space.bilibili.com/24807452) and [Keldos](https://github.com/Keldos-Li)\n\nDownload latest code from [GitHub](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
98
+ "知识库": "Knowledge base",
99
+ "知识库文件": "Knowledge base files",
100
+ "第一条提问": "By first question",
101
+ "索引构建完成": "Indexing complete.",
102
+ "网络": "Network",
103
+ "获取API使用情况失败:": "Failed to get API usage:",
104
+ "获取IP地理位置失败。原因:": "Failed to get IP location. Reason: ",
105
  "获取对话时发生错误,请查看后台日志": "Error occurred when getting dialogue, check the background log",
106
+ "训练": "Training",
107
+ "训练状态": "Training Status",
108
+ "训练轮数(Epochs)": "Training Epochs",
109
+ "设置": "Settings",
110
+ "设置保存文件名": "Set save file name",
111
+ "设置文件名: 默认为.json,可选为.md": "Set file name: default is .json, optional is .md",
112
+ "识别公式": "formula OCR",
113
+ "详情": "Details",
114
+ "请查看 config_example.json,配置 Azure OpenAI": "Please review config_example.json to configure Azure OpenAI",
115
  "请检查网络连接,或者API-Key是否有效。": "Check the network connection or whether the API-Key is valid.",
 
 
 
 
 
116
  "请输入对话内容。": "Enter the content of the conversation.",
117
+ "请输入有效的文件名,不要包含以下特殊字符:": "Please enter a valid file name, do not include the following special characters: ",
118
+ "读取超时,无法获取对话。": "Read timed out, unable to get dialogue.",
119
  "账单信息不适用": "Billing information is not applicable",
120
+ "连接超时,无法获取对话。": "Connection timed out, unable to get dialogue.",
121
+ "选择LoRA模型": "Select LoRA Model",
122
+ "选择Prompt模板集合文件": "Select Prompt Template Collection File",
123
+ "选择回复语言(针对搜索&索引功能)": "Select reply language (for search & index)",
124
+ "选择数据集": "Select Dataset",
125
+ "选择模型": "Select Model",
126
+ "重命名该对话": "Rename this chat",
127
+ "重新生成": "Regenerate",
128
+ "高级": "Advanced",
129
+ ",本次对话累计消耗了 ": ", total cost: ",
130
+ "💾 保存对话": "💾 Save Dialog",
131
+ "📝 导出为 Markdown": "📝 Export as Markdown",
132
+ "🔄 切换API地址": "🔄 Switch API Address",
133
+ "🔄 刷新": "🔄 Refresh",
134
+ "🔄 检查更新...": "🔄 Check for Update...",
135
+ "🔄 设置代理地址": "🔄 Set Proxy Address",
136
+ "🔄 重新生成": "🔄 Regeneration",
137
+ "🔙 恢复默认网络设置": "🔙 Reset Network Settings",
138
+ "🗑️ 删除最新对话": "🗑️ Delete latest dialog",
139
+ "🗑️ 删除最旧对话": "🗑️ Delete oldest dialog",
140
+ "🧹 新的对话": "🧹 New Dialogue"
141
+ }
locale/extract_locale.py CHANGED
@@ -1,26 +1,138 @@
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)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os, json, re, sys
2
+ import aiohttp, asyncio
3
+ import commentjson
4
 
5
+ asyncio.set_event_loop_policy(asyncio.DefaultEventLoopPolicy())
 
6
 
7
+ with open("config.json", "r", encoding="utf-8") as f:
8
+ config = commentjson.load(f)
9
+ api_key = config["openai_api_key"]
10
+ url = config["openai_api_base"] + "/v1/chat/completions" if "openai_api_base" in config else "https://api.openai.com/v1/chat/completions"
11
 
 
 
 
 
 
12
 
13
+ def get_current_strings():
14
+ pattern = r'i18n\s*\(\s*["\']([^"\']*(?:\)[^"\']*)?)["\']\s*\)'
15
 
16
+ # Load the .py files
17
+ contents = ""
18
+ for dirpath, dirnames, filenames in os.walk("."):
19
+ for filename in filenames:
20
+ if filename.endswith(".py"):
21
+ filepath = os.path.join(dirpath, filename)
22
+ with open(filepath, 'r', encoding='utf-8') as f:
23
+ contents += f.read()
24
+ # Matching with regular expressions
25
+ matches = re.findall(pattern, contents, re.DOTALL)
26
+ data = {match.strip('()"'): '' for match in matches}
27
+ fixed_data = {} # fix some keys
28
+ for key, value in data.items():
29
+ if "](" in key and key.count("(") != key.count(")"):
30
+ fixed_data[key+")"] = value
31
+ else:
32
+ fixed_data[key] = value
33
 
34
+ return fixed_data
35
+
36
+
37
+ def get_locale_strings(filename):
38
+ try:
39
+ with open(filename, "r", encoding="utf-8") as f:
40
+ locale_strs = json.load(f)
41
+ except FileNotFoundError:
42
+ locale_strs = {}
43
+ return locale_strs
44
+
45
+
46
+ def sort_strings(existing_translations):
47
+ # Sort the merged data
48
+ sorted_translations = {}
49
+ # Add entries with (NOT USED) in their values
50
+ for key, value in sorted(existing_translations.items(), key=lambda x: x[0]):
51
+ if "(🔴NOT USED)" in value:
52
+ sorted_translations[key] = value
53
+ # Add entries with empty values
54
+ for key, value in sorted(existing_translations.items(), key=lambda x: x[0]):
55
+ if value == "":
56
+ sorted_translations[key] = value
57
+ # Add the rest of the entries
58
+ for key, value in sorted(existing_translations.items(), key=lambda x: x[0]):
59
+ if value != "" and "(NOT USED)" not in value:
60
+ sorted_translations[key] = value
61
+
62
+ return sorted_translations
63
+
64
+
65
+ async def auto_translate(str, language):
66
+ headers = {
67
+ "Content-Type": "application/json",
68
+ "Authorization": f"Bearer {api_key}",
69
+ "temperature": f"{0}",
70
+ }
71
+ payload = {
72
+ "model": "gpt-3.5-turbo",
73
+ "messages": [
74
+ {
75
+ "role": "system",
76
+ "content": f"You are a translation program;\nYour job is to translate user input into {language};\nThe content you are translating is a string in the App;\nDo not explain emoji;\nIf input is only a emoji, please simply return origin emoji;\nPlease ensure that the translation results are concise and easy to understand."
77
+ },
78
+ {"role": "user", "content": f"{str}"}
79
+ ],
80
+ }
81
+
82
+ async with aiohttp.ClientSession() as session:
83
+ async with session.post(url, headers=headers, json=payload) as response:
84
+ data = await response.json()
85
+ return data["choices"][0]["message"]["content"]
86
+
87
+
88
+ async def main(auto=False):
89
+ current_strs = get_current_strings()
90
+ locale_files = []
91
+ # 遍历locale目录下的所有json文件
92
+ for dirpath, dirnames, filenames in os.walk("locale"):
93
+ for filename in filenames:
94
+ if filename.endswith(".json"):
95
+ locale_files.append(os.path.join(dirpath, filename))
96
+
97
+
98
+ for locale_filename in locale_files:
99
+ if "zh_CN" in locale_filename:
100
+ continue
101
+ locale_strs = get_locale_strings(locale_filename)
102
+
103
+ # Add new keys
104
+ new_keys = []
105
+ for key in current_strs:
106
+ if key not in locale_strs:
107
+ new_keys.append(key)
108
+ locale_strs[key] = ""
109
+ print(f"{locale_filename[7:-5]}'s new str: {len(new_keys)}")
110
+ # Add (NOT USED) to invalid keys
111
+ for key in locale_strs:
112
+ if key not in current_strs:
113
+ locale_strs[key] = "(🔴NOT USED)" + locale_strs[key]
114
+ print(f"{locale_filename[7:-5]}'s invalid str: {len(locale_strs) - len(current_strs)}")
115
+
116
+ locale_strs = sort_strings(locale_strs)
117
+
118
+ if auto:
119
+ tasks = []
120
+ non_translated_keys = []
121
+ for key in locale_strs:
122
+ if locale_strs[key] == "":
123
+ non_translated_keys.append(key)
124
+ tasks.append(auto_translate(key, locale_filename[7:-5]))
125
+ results = await asyncio.gather(*tasks)
126
+ for key, result in zip(non_translated_keys, results):
127
+ locale_strs[key] = "(🟡REVIEW NEEDED)" + result
128
+ print(f"{locale_filename[7:-5]}'s auto translated str: {len(non_translated_keys)}")
129
+
130
+ with open(locale_filename, 'w', encoding='utf-8') as f:
131
+ json.dump(locale_strs, f, ensure_ascii=False, indent=4)
132
+
133
+
134
+ if __name__ == "__main__":
135
+ auto = False
136
+ if len(sys.argv) > 1 and sys.argv[1] == "--auto":
137
+ auto = True
138
+ asyncio.run(main(auto))
locale/ja_JP.json CHANGED
@@ -1,87 +1,141 @@
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
- "# ⚠️ 务必谨慎更改 ⚠️": "# ⚠️ 変更には慎重に ⚠️",
36
- "参数": "パラメータ",
37
- "停止符,用英文逗号隔开...": "ここにストップ文字を英語のカンマで区切って入力してください...",
38
- "用于定位滥用行为": "不正行為を特定するために使用されます",
39
- "用户名": "ユーザー名",
40
- "在这里输入API-Host...": "API-Hostを入力してください...",
41
- "🔄 切换API地址": "🔄 APIアドレスを切り替え",
42
- "未设置代理...": "代理が設定されていません...",
43
  "代理地址": "プロキシアドレス",
44
- "🔄 设置代理地址": "🔄 プロキシアドレスを設定",
45
- "🔙 恢复默认网络设置": "🔙 ネットワーク設定のリセット",
46
- "🔄 检查更新...": "🔄 アップデートをチェック...",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  "取消": "キャンセル",
48
- "更新": "アップデート",
49
- "详情": "詳細",
 
 
 
 
 
 
50
  "好": "はい",
51
- "更新成功,请重启本程序": "更新が成功しました、このプログラムを再起動してください",
52
- "更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)": "更新に失敗しました、[手動での更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)をお試しください。",
 
 
 
 
 
53
  "川虎Chat 🚀": "川虎Chat 🚀",
 
 
54
  "开始实时传输回答……": "ストリーム出力開始……",
55
- "Token 计数: ": "Token数: ",
56
- ",本次对话累计消耗了 ": ", 今の会話で消費合計 ",
57
- "**获取API使用情况失败**": "**API使用状況の取得に失敗しました**",
58
- "**获取API使用情况失败**,需在填写`config.json`中正确填写sensitive_id": "**API使用状況の取得に失敗しました**、`config.json`に正しい`sensitive_id`を入力する必要があります",
59
- "**获取API使用情况失败**,sensitive_id错误或已过期": "**API使用状況の取得に失敗しました**、sensitive_idが間違っているか、期限切れです",
60
- "**本月使用金额** ": "**今月の使用料金** ",
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  "本月使用金额": "今月の使用料金",
62
- "获取API使用情况失败:": "API使用状況の取得に失敗しました:",
63
- "API密钥更改为了": "APIキーが変更されました",
64
- "JSON解析错误,收到的内容: ": "JSON解析エラー、受信内容: ",
 
 
65
  "模型设置为了:": "LLMモデルを設定しました: ",
66
- "☹️发生了错误:": "エラーが発生しました: ",
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  "获取对话时发生错误,请查看后台日志": "会話取得時にエラー発生、あとのログを確認してください",
 
 
 
 
 
 
 
 
 
68
  "请检查网络连接,或者API-Key是否有效。": "ネットワーク接続を確認するか、APIキーが有効かどうかを確認してください。",
69
- "连接超时,无法获取对话。": "接続タイムアウト、会話を取得できません。",
70
- "读取超时,无法获取对话。": "読み込みタイムアウト、会話を取得できません。",
71
- "代理错误,无法获取对话。": "プロキシエラー、会話を取得できません。",
72
- "SSL错误,无法获取对话。": "SSLエラー、会話を取得できません。",
73
- "API key为空,请检查是否输入正确。": "APIキーが入力されていません。正しく入力されているか確認してください。",
74
  "请输入对话内容。": "会話内容を入力してください。",
 
 
75
  "账单信息不适用": "課金情報は対象外です",
76
- "由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536)、[明昭MZhao](https://space.bilibili.com/24807452) 和 [Keldos](https://github.com/Keldos-Li) 开发<br />访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本": "開発:Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) と [明昭MZhao](https://space.bilibili.com/24807452) と [Keldos](https://github.com/Keldos-Li)\n\n最新コードは川虎Chatのサイトへ [GitHubプロジェクト](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
77
- "切换亮暗色主题": "テーマの明暗切替",
78
- "您的IP区域:未知。": "あなたのIPアドレス地域:不明",
79
- "获取IP地理位置失败。原因:": "IPアドレス地域の取得に失敗しました。理由:",
80
- "。你仍然可以使用聊天功能。": "。あなたはまだチャット機能を使用できます。",
81
- "您的IP区域:": "あなたのIPアドレス地域:",
82
- "总结": "要約する",
83
- "生成内容总结中……": "コンテンツ概要を生成しています...",
84
- "由于下面的原因,Google 拒绝返回 PaLM 的回答:\n\n": "Googleは以下の理由から、PaLMの回答を返すことを拒否しています:\n\n",
85
- "---\n⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "---\n⚠️ APIキーの安全性を確保するために、`config.json`ファイルでネットワーク設定を変更してください。",
86
- "网络参数": "ネットワークパラメータ"
87
- }
 
 
 
 
 
 
 
 
 
 
 
1
  {
2
+ " 吗?": " を削除してもよろしいですか?",
3
+ "# ⚠️ 务必谨慎更改 ⚠️": "# ⚠️ 変更には慎重に ⚠️",
 
 
 
 
 
 
4
  "**发送消息** 或 **提交key** 以显示额度": "**メッセージを送信** または **キーを送信** して、クレジットを表示します",
5
+ "**本月使用金额** ": "**今月の使用料金** ",
6
+ "**获取API使用情况失败**": "**API使用状況の取得に失敗しました**",
7
+ "**获取API使用情况失败**,sensitive_id错误或已过期": "**API使用状況の取得に失敗しました**、sensitive_idが間違っているか、期限切れです",
8
+ "**获取API使用情况失败**,需在填写`config.json`中正确填写sensitive_id": "**API使用状況の取得に失敗しました**、`config.json`に正しい`sensitive_id`を入力する必要があります",
9
+ "API key为空,请检查是否输入正确。": "APIキーが入力されていません。正しく入力されているか確認してください。",
10
+ "API密钥更改为了": "APIキーが変更されました",
11
+ "JSON解析错误,收到的内容: ": "JSON解析エラー、受信内容: ",
12
+ "SSL错误,无法获取对话。": "SSLエラー、会話を取得できません。",
13
+ "Token 计数: ": "Token数: ",
14
+ "☹️发生了错误:": "エラーが発生しました: ",
15
+ "⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "⚠️ APIキーの安全性を確保するために、`config.json`ファイルでネットワーク設定を変更してください。",
16
+ "。你仍然可以使用聊天功能。": "。あなたはまだチャット機能を使用できます。",
17
+ "上传": "アップロード",
18
+ "上传了": "アップロードしました。",
19
+ "上传到 OpenAI 后自动填充": "OpenAIへのアップロード後、自動的に入力されます",
20
+ "上传到OpenAI": "OpenAIへのアップロード",
21
+ "上传文件": "ファイルをアップロード",
22
+ "仅供查看": "閲覧専用",
23
  "从Prompt模板中加载": "Promptテンプレートから読込",
 
 
24
  "从列表中加载对话": "リストから会話を読込",
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  "代理地址": "プロキシアドレス",
26
+ "代理��误,无法获取对话。": "プロキシエラー、会話を取得できません。",
27
+ "你没有权限访问 GPT4,[进一步了解](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/843)": "GPT-4にアクセス権がありません、[詳細はこちら](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/843)",
28
+ "你没有选择任何对话历史": "あなたは何の会話履歴も選択していません。",
29
+ "你真的要删除 ": "本当に ",
30
+ "使用在线搜索": "オンライン検索を使用",
31
+ "停止符,用英文逗号隔开...": "ここにストップ文字を英語のカンマで区切って入力してください...",
32
+ "关于": "について",
33
+ "准备数据集": "データセットの準備",
34
+ "切换亮暗色主题": "テーマの明暗切替",
35
+ "删除对话历史成功": "削除した会話の履歴",
36
+ "删除这轮问答": "この質疑応答を削除",
37
+ "刷新状态": "ステータスを更新",
38
+ "剩余配额不足,[进一步了解](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#you-exceeded-your-current-quota-please-check-your-plan-and-billing-details)": "剩余配额不足,[进一步了解](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98#you-exceeded-your-current-quota-please-check-your-plan-and-billing-details)",
39
+ "加载Prompt模板": "Promptテンプレートを読込",
40
+ "单轮对话": "単発会話",
41
+ "历史记录(JSON)": "履歴ファイル(JSON)",
42
+ "参数": "パラメータ",
43
+ "双栏pdf": "2カラムpdf",
44
  "取消": "キャンセル",
45
+ "取消所有任务": "すべてのタスクをキャンセル",
46
+ "可选,用于区分不同的模型": "オプション、異なるモデルを区別するために使用",
47
+ "启用的工具:": "有効なツール:",
48
+ "在工具箱中管理知识库文件": "ツールボックスでナレッジベースファイルの管理を行う",
49
+ "在线搜索": "オンライン検索",
50
+ "在这里输入": "ここに入力",
51
+ "在这里输入System Prompt...": "System Promptを入力してください...",
52
+ "多账号模式已开启,无需输入key,可直接开始对话": "複数アカウントモードがオンになっています。キーを入力する必要はありません。会話を開始できます",
53
  "好": "はい",
54
+ "实时传输回答": "ストリーム出力",
55
+ "对话": "会話",
56
+ "对话历史": "対話履歴",
57
+ "对话历史记录": "会話履歴",
58
+ "对话命名方式": "会話の命名方法",
59
+ "导出为 Markdown": "Markdownでエクスポート",
60
+ "川虎Chat": "川虎Chat",
61
  "川虎Chat 🚀": "川虎Chat 🚀",
62
+ "工具箱": "ツールボックス",
63
+ "已经被删除啦": "削除されました。",
64
  "开始实时传输回答……": "ストリーム出力開始……",
65
+ "开始训练": "トレーニングを開始",
66
+ "微调": "ファインチューニング",
67
+ "总结": "要約する",
68
+ "总结完成": "完了",
69
+ "您使用的就是最新版!": "最新バージョンを使用しています!",
70
+ "您的IP区域:": "あなたのIPアドレス地域:",
71
+ "您的IP区域:未知。": "あなたのIPアドレス地域:不明",
72
+ "拓展": "拡張",
73
+ "搜索(支持正则)...": "検索(正規表現をサポート)...",
74
+ "数据集预览": "データセットのプレビュー",
75
+ "文件ID": "ファイルID",
76
+ "新对话 ": "新しい会話 ",
77
+ "新建对话保留Prompt": "新しい会話を作成してください。プロンプトを保留します。",
78
+ "暂时未知": "しばらく不明である",
79
+ "更新": "アップデート",
80
+ "更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)": "更新に失敗しました、[手動での更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)をお試しください。",
81
+ "更新成功,请重启本程序": "更新が成功しました、このプログラムを再起動してください",
82
+ "未命名对话历史记录": "名無しの会話履歴",
83
+ "未设置代理...": "代理が設定されていません...",
84
  "本月使用金额": "今月の使用料金",
85
+ "查看[使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)": "[使用ガイド](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)を表示",
86
+ "根据日期时间": "日付と時刻に基づいて",
87
+ "模型": "LLMモデル",
88
+ "模型名称后缀": "モデル名のサフィックス",
89
+ "模型自动总结(消耗tokens)": "モデルによる自動要約(トークン消費)",
90
  "模型设置为了:": "LLMモデルを設定しました: ",
91
+ "正在尝试更新...": "更新を試みています...",
92
+ "添加训练好的模型到模型列表": "トレーニング済みモデルをモデルリストに追加",
93
+ "状态": "ステータス",
94
+ "生成内容总结中……": "コンテンツ概要を生成しています...",
95
+ "用于定位滥用行为": "不正行為を特定するために使用されます",
96
+ "用户名": "ユーザー名",
97
+ "由Bilibili [土川虎虎虎](https://space.bilibili.com/29125536)、[明昭MZhao](https://space.bilibili.com/24807452) 和 [Keldos](https://github.com/Keldos-Li) 开发<br />访问川虎Chat的 [GitHub项目](https://github.com/GaiZhenbiao/ChuanhuChatGPT) 下载最新版脚本": "開発:Bilibili [土川虎虎虎](https://space.bilibili.com/29125536) と [明昭MZhao](https://space.bilibili.com/24807452) と [Keldos](https://github.com/Keldos-Li)\n\n最新コードは川虎Chatのサイトへ [GitHubプロジェクト](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
98
+ "知识库": "ナレッジベース",
99
+ "知识库文件": "ナレッジベースファイル",
100
+ "第一条提问": "最初の質問",
101
+ "索引构建完成": "索引の構築が完了しました。",
102
+ "网络": "ネットワーク",
103
+ "获取API使用情况失败:": "API使用状況の取得に失敗しました:",
104
+ "获取IP地理位置失败。原因:": "IPアドレス地域の取得に失敗しました。理由:",
105
  "获取对话时发生错误,请查看后台日志": "会話取得時にエラー発生、あとのログを確認してください",
106
+ "训练": "トレーニング",
107
+ "训练状态": "トレーニングステータス",
108
+ "训练轮数(Epochs)": "トレーニングエポック数",
109
+ "设置": "設定",
110
+ "设置保存文件名": "保存ファイル名を設定",
111
+ "设置文件名: 默认为.json,可选为.md": "ファイル名を設定: デフォルトは.json、.mdを選択できます",
112
+ "识别公式": "formula OCR",
113
+ "详情": "詳細",
114
+ "请查看 config_example.json,配置 Azure OpenAI": "Azure OpenAIの設定については、config_example.jsonをご覧ください",
115
  "请检查网络连接,或者API-Key是否有效。": "ネットワーク接続を確認するか、APIキーが有効かどうかを確認してください。",
 
 
 
 
 
116
  "请输入对话内容。": "会話内容を入力してください。",
117
+ "请输入有效的文件名,不要包含以下特殊字符:": "有効なファイル名を入力してください。以下の特殊文字は使用しないでください:",
118
+ "读取超时,无法获取对话。": "読み込みタイムアウト、会話を取得できません。",
119
  "账单信息不适用": "課金情報は対象外です",
120
+ "连接超时,无法获取对话。": "接続タイムアウト、会話を取得できません。",
121
+ "选择LoRA模型": "LoRAモデルを選択",
122
+ "选择Prompt模板集合文件": "Promptテンプレートコレクションを選択",
123
+ "选择回复语言(针对搜索&索引功能)": "回答言語を選択(検索とインデックス機能に対して)",
124
+ "选择数据集": "データセットの選択",
125
+ "选择模型": "LLMモデルを選択",
126
+ "重命名该对话": "会話の名前を変更",
127
+ "重新生成": "再生成",
128
+ "高级": "Advanced",
129
+