Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
123
#21
by
LIas2488952631
- opened
This view is limited to 50 files because it contains too many changes.
See the raw diff here.
- CITATION.cff +0 -20
- ChuanhuChatbot.py +0 -808
- Dockerfile +8 -12
- README.md +6 -5
- app.py +455 -0
- assets/custom.css +0 -468
- assets/custom.js +1 -502
- assets/external-scripts.js +0 -2
- assets/html/appearance_switcher.html +0 -11
- assets/html/footer.html +0 -1
- chat_func.py +456 -0
- config.json +0 -3
- config_example.json +0 -84
- configs/ds_config_chatbot.json +0 -17
- history/2023-06-14_15-05-04.json +0 -0
- llama_func.py +192 -0
- locale/en_US.json +0 -141
- locale/extract_locale.py +0 -138
- locale/ja_JP.json +0 -141
- locale/ko_KR.json +0 -141
- locale/ru_RU.json +0 -141
- locale/sv-SE.json +0 -87
- locale/sv_SE.json +0 -141
- locale/vi_VN.json +0 -141
- locale/zh_CN.json +0 -1
- modules/.DS_Store +0 -0
- modules/__init__.py +0 -0
- modules/__pycache__/__init__.cpython-311.pyc +0 -0
- modules/__pycache__/__init__.cpython-39.pyc +0 -0
- modules/__pycache__/base_model.cpython-311.pyc +0 -0
- modules/__pycache__/base_model.cpython-39.pyc +0 -0
- modules/__pycache__/chat_func.cpython-39.pyc +0 -0
- modules/__pycache__/config.cpython-311.pyc +0 -0
- modules/__pycache__/config.cpython-39.pyc +0 -0
- modules/__pycache__/index_func.cpython-311.pyc +0 -0
- modules/__pycache__/index_func.cpython-39.pyc +0 -0
- modules/__pycache__/llama_func.cpython-311.pyc +0 -0
- modules/__pycache__/llama_func.cpython-39.pyc +0 -0
- modules/__pycache__/models.cpython-311.pyc +0 -0
- modules/__pycache__/models.cpython-39.pyc +0 -0
- modules/__pycache__/openai_func.cpython-39.pyc +0 -0
- modules/__pycache__/overwrites.cpython-311.pyc +0 -0
- modules/__pycache__/overwrites.cpython-39.pyc +0 -0
- modules/__pycache__/pdf_func.cpython-311.pyc +0 -0
- modules/__pycache__/pdf_func.cpython-39.pyc +0 -0
- modules/__pycache__/presets.cpython-311.pyc +0 -0
- modules/__pycache__/presets.cpython-39.pyc +0 -0
- modules/__pycache__/proxy_func.cpython-39.pyc +0 -0
- modules/__pycache__/repo.cpython-311.pyc +0 -0
- modules/__pycache__/shared.cpython-311.pyc +0 -0
CITATION.cff
DELETED
@@ -1,20 +0,0 @@
|
|
1 |
-
cff-version: 1.2.0
|
2 |
-
title: Chuanhu Chat
|
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: This software provides a light and easy-to-use interface for ChatGPT API and many LLMs.
|
17 |
-
license: GPL-3.0
|
18 |
-
commit: c6c08bc62ef80e37c8be52f65f9b6051a7eea1fa
|
19 |
-
version: '20230709'
|
20 |
-
date-released: '2023-07-09'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ChuanhuChatbot.py
DELETED
@@ -1,808 +0,0 @@
|
|
1 |
-
# -*- coding:utf-8 -*-
|
2 |
-
import logging
|
3 |
-
logging.basicConfig(
|
4 |
-
level=logging.INFO,
|
5 |
-
format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s",
|
6 |
-
)
|
7 |
-
|
8 |
-
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 |
-
|
23 |
-
gr.Chatbot._postprocess_chat_messages = postprocess_chat_messages
|
24 |
-
gr.Chatbot.postprocess = postprocess
|
25 |
-
|
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(),
|
54 |
-
cancel_btn=i18n("取消"),
|
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 |
-
sanitize_html=False,
|
139 |
-
# height=700,
|
140 |
-
show_label=False,
|
141 |
-
avatar_images=[config.user_avatar, config.bot_avatar],
|
142 |
-
show_share_button=False,
|
143 |
-
)
|
144 |
-
with gr.Row(elem_id="chatbot-footer"):
|
145 |
-
with gr.Box(elem_id="chatbot-input-box"):
|
146 |
-
with gr.Row(elem_id="chatbot-input-row"):
|
147 |
-
gr.HTML(get_html("chatbot_more.html").format(
|
148 |
-
single_turn_label=i18n("单轮对话"),
|
149 |
-
websearch_label=i18n("在线搜索"),
|
150 |
-
upload_file_label=i18n("上传文件"),
|
151 |
-
uploaded_files_label=i18n("知识库文件"),
|
152 |
-
uploaded_files_tip=i18n("在工具箱中管理知识库文件")
|
153 |
-
))
|
154 |
-
with gr.Row(elem_id="chatbot-input-tb-row"):
|
155 |
-
with gr.Column(min_width=225, scale=12):
|
156 |
-
user_input = gr.Textbox(
|
157 |
-
elem_id="user-input-tb",
|
158 |
-
show_label=False,
|
159 |
-
placeholder=i18n("在这里输入"),
|
160 |
-
elem_classes="no-container",
|
161 |
-
max_lines=5,
|
162 |
-
# container=False
|
163 |
-
)
|
164 |
-
with gr.Column(min_width=42, scale=1, elem_id="chatbot-ctrl-btns"):
|
165 |
-
submitBtn = gr.Button(
|
166 |
-
value="", variant="primary", elem_id="submit-btn")
|
167 |
-
cancelBtn = gr.Button(
|
168 |
-
value="", variant="secondary", visible=False, elem_id="cancel-btn")
|
169 |
-
# Note: Buttons below are set invisible in UI. But they are used in JS.
|
170 |
-
with gr.Row(elem_id="chatbot-buttons", visible=False):
|
171 |
-
with gr.Column(min_width=120, scale=1):
|
172 |
-
emptyBtn = gr.Button(
|
173 |
-
i18n("🧹 新的对话"), elem_id="empty-btn"
|
174 |
-
)
|
175 |
-
with gr.Column(min_width=120, scale=1):
|
176 |
-
retryBtn = gr.Button(
|
177 |
-
i18n("🔄 重新生成"), elem_id="gr-retry-btn")
|
178 |
-
with gr.Column(min_width=120, scale=1):
|
179 |
-
delFirstBtn = gr.Button(i18n("🗑️ 删除最旧对话"))
|
180 |
-
with gr.Column(min_width=120, scale=1):
|
181 |
-
delLastBtn = gr.Button(
|
182 |
-
i18n("🗑️ 删除最新对话"), elem_id="gr-dellast-btn")
|
183 |
-
with gr.Row(visible=False) as like_dislike_area:
|
184 |
-
with gr.Column(min_width=20, scale=1):
|
185 |
-
likeBtn = gr.Button(
|
186 |
-
"👍", elem_id="gr-like-btn")
|
187 |
-
with gr.Column(min_width=20, scale=1):
|
188 |
-
dislikeBtn = gr.Button(
|
189 |
-
"👎", elem_id="gr-dislike-btn")
|
190 |
-
|
191 |
-
with gr.Column(elem_id="toolbox-area", scale=1):
|
192 |
-
# For CSS setting, there is an extra box. Don't remove it.
|
193 |
-
with gr.Box(elem_id="chuanhu-toolbox"):
|
194 |
-
with gr.Row():
|
195 |
-
gr.Markdown("## "+i18n("工具箱"))
|
196 |
-
gr.HTML(get_html("close_btn.html").format(
|
197 |
-
obj="toolbox"), elem_classes="close-btn")
|
198 |
-
with gr.Tabs(elem_id="chuanhu-toolbox-tabs"):
|
199 |
-
with gr.Tab(label=i18n("对话")):
|
200 |
-
keyTxt = gr.Textbox(
|
201 |
-
show_label=True,
|
202 |
-
placeholder=f"Your API-key...",
|
203 |
-
value=hide_middle_chars(user_api_key.value),
|
204 |
-
type="password",
|
205 |
-
visible=not HIDE_MY_KEY,
|
206 |
-
label="API-Key",
|
207 |
-
)
|
208 |
-
with gr.Accordion(label="Prompt", open=True):
|
209 |
-
systemPromptTxt = gr.Textbox(
|
210 |
-
show_label=True,
|
211 |
-
placeholder=i18n("在这里输入System Prompt..."),
|
212 |
-
label="System prompt",
|
213 |
-
value=INITIAL_SYSTEM_PROMPT,
|
214 |
-
lines=8
|
215 |
-
)
|
216 |
-
retain_system_prompt_checkbox = gr.Checkbox(
|
217 |
-
label=i18n("新建对话保留Prompt"), value=False, visible=True, elem_classes="switch-checkbox")
|
218 |
-
with gr.Accordion(label=i18n("加载Prompt模板"), open=False):
|
219 |
-
with gr.Column():
|
220 |
-
with gr.Row():
|
221 |
-
with gr.Column(scale=6):
|
222 |
-
templateFileSelectDropdown = gr.Dropdown(
|
223 |
-
label=i18n("选择Prompt模板集合文件"),
|
224 |
-
choices=get_template_names(),
|
225 |
-
multiselect=False,
|
226 |
-
value=get_template_names()[0],
|
227 |
-
container=False,
|
228 |
-
)
|
229 |
-
with gr.Column(scale=1):
|
230 |
-
templateRefreshBtn = gr.Button(
|
231 |
-
i18n("🔄 刷新"))
|
232 |
-
with gr.Row():
|
233 |
-
with gr.Column():
|
234 |
-
templateSelectDropdown = gr.Dropdown(
|
235 |
-
label=i18n("从Prompt模板中加载"),
|
236 |
-
choices=load_template(
|
237 |
-
get_template_names()[
|
238 |
-
0], mode=1
|
239 |
-
),
|
240 |
-
multiselect=False,
|
241 |
-
container=False,
|
242 |
-
)
|
243 |
-
gr.Markdown("---", elem_classes="hr-line")
|
244 |
-
with gr.Accordion(label=i18n("知识库"), open=True):
|
245 |
-
use_websearch_checkbox = gr.Checkbox(label=i18n(
|
246 |
-
"使用在线搜索"), value=False, elem_classes="switch-checkbox", elem_id="gr-websearch-cb", visible=False)
|
247 |
-
index_files = gr.Files(label=i18n(
|
248 |
-
"上传"), type="file", file_types=[".pdf", ".docx", ".pptx", ".epub", ".xlsx", ".txt", "text", "image"], elem_id="upload-index-file")
|
249 |
-
two_column = gr.Checkbox(label=i18n(
|
250 |
-
"双栏pdf"), value=advance_docs["pdf"].get("two_column", False))
|
251 |
-
summarize_btn = gr.Button(i18n("总结"))
|
252 |
-
# TODO: 公式ocr
|
253 |
-
# formula_ocr = gr.Checkbox(label=i18n("识别公式"), value=advance_docs["pdf"].get("formula_ocr", False))
|
254 |
-
|
255 |
-
with gr.Tab(label=i18n("参数")):
|
256 |
-
gr.Markdown(i18n("# ⚠️ 务必谨慎更改 ⚠️"),
|
257 |
-
elem_id="advanced-warning")
|
258 |
-
with gr.Accordion(i18n("参数"), open=True):
|
259 |
-
temperature_slider = gr.Slider(
|
260 |
-
minimum=-0,
|
261 |
-
maximum=2.0,
|
262 |
-
value=1.0,
|
263 |
-
step=0.1,
|
264 |
-
interactive=True,
|
265 |
-
label="temperature",
|
266 |
-
)
|
267 |
-
top_p_slider = gr.Slider(
|
268 |
-
minimum=-0,
|
269 |
-
maximum=1.0,
|
270 |
-
value=1.0,
|
271 |
-
step=0.05,
|
272 |
-
interactive=True,
|
273 |
-
label="top-p",
|
274 |
-
)
|
275 |
-
n_choices_slider = gr.Slider(
|
276 |
-
minimum=1,
|
277 |
-
maximum=10,
|
278 |
-
value=1,
|
279 |
-
step=1,
|
280 |
-
interactive=True,
|
281 |
-
label="n choices",
|
282 |
-
)
|
283 |
-
stop_sequence_txt = gr.Textbox(
|
284 |
-
show_label=True,
|
285 |
-
placeholder=i18n("停止符,用英文逗号隔开..."),
|
286 |
-
label="stop",
|
287 |
-
value="",
|
288 |
-
lines=1,
|
289 |
-
)
|
290 |
-
max_context_length_slider = gr.Slider(
|
291 |
-
minimum=1,
|
292 |
-
maximum=32768,
|
293 |
-
value=2000,
|
294 |
-
step=1,
|
295 |
-
interactive=True,
|
296 |
-
label="max context",
|
297 |
-
)
|
298 |
-
max_generation_slider = gr.Slider(
|
299 |
-
minimum=1,
|
300 |
-
maximum=32768,
|
301 |
-
value=1000,
|
302 |
-
step=1,
|
303 |
-
interactive=True,
|
304 |
-
label="max generations",
|
305 |
-
)
|
306 |
-
presence_penalty_slider = gr.Slider(
|
307 |
-
minimum=-2.0,
|
308 |
-
maximum=2.0,
|
309 |
-
value=0.0,
|
310 |
-
step=0.01,
|
311 |
-
interactive=True,
|
312 |
-
label="presence penalty",
|
313 |
-
)
|
314 |
-
frequency_penalty_slider = gr.Slider(
|
315 |
-
minimum=-2.0,
|
316 |
-
maximum=2.0,
|
317 |
-
value=0.0,
|
318 |
-
step=0.01,
|
319 |
-
interactive=True,
|
320 |
-
label="frequency penalty",
|
321 |
-
)
|
322 |
-
logit_bias_txt = gr.Textbox(
|
323 |
-
show_label=True,
|
324 |
-
placeholder=f"word:likelihood",
|
325 |
-
label="logit bias",
|
326 |
-
value="",
|
327 |
-
lines=1,
|
328 |
-
)
|
329 |
-
user_identifier_txt = gr.Textbox(
|
330 |
-
show_label=True,
|
331 |
-
placeholder=i18n("用于定位滥用行为"),
|
332 |
-
label=i18n("用户名"),
|
333 |
-
value=user_name.value,
|
334 |
-
lines=1,
|
335 |
-
)
|
336 |
-
with gr.Tab(label=i18n("拓展")):
|
337 |
-
gr.Markdown(
|
338 |
-
"Will be here soon...\n(We hope)\n\nAnd we hope you can help us to make more extensions!")
|
339 |
-
|
340 |
-
# changeAPIURLBtn = gr.Button(i18n("🔄 切换API地址"))
|
341 |
-
|
342 |
-
with gr.Row(elem_id="popup-wrapper"):
|
343 |
-
with gr.Box(elem_id="chuanhu-popup"):
|
344 |
-
with gr.Box(elem_id="chuanhu-setting"):
|
345 |
-
with gr.Row():
|
346 |
-
gr.Markdown("## "+i18n("设置"))
|
347 |
-
gr.HTML(get_html("close_btn.html").format(
|
348 |
-
obj="box"), elem_classes="close-btn")
|
349 |
-
with gr.Tabs(elem_id="chuanhu-setting-tabs"):
|
350 |
-
with gr.Tab(label=i18n("模型")):
|
351 |
-
if multi_api_key:
|
352 |
-
usageTxt = gr.Markdown(i18n(
|
353 |
-
"多账号模式已开启,无需输入key,可直接开始对话"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
354 |
-
else:
|
355 |
-
usageTxt = gr.Markdown(i18n(
|
356 |
-
"**发送消息** 或 **提交key** 以显示额度"), elem_id="usage-display", elem_classes="insert-block", visible=show_api_billing)
|
357 |
-
# model_select_dropdown = gr.Dropdown(
|
358 |
-
# label=i18n("选择模型"), choices=MODELS, multiselect=False, value=MODELS[DEFAULT_MODEL], interactive=True
|
359 |
-
# )
|
360 |
-
# lora_select_dropdown = gr.Dropdown(
|
361 |
-
# label=i18n("选择LoRA模型"), choices=[], multiselect=False, interactive=True, visible=False
|
362 |
-
# )
|
363 |
-
# with gr.Row():
|
364 |
-
|
365 |
-
language_select_dropdown = gr.Dropdown(
|
366 |
-
label=i18n("选择回复语言(针对搜索&索引功能)"),
|
367 |
-
choices=REPLY_LANGUAGES,
|
368 |
-
multiselect=False,
|
369 |
-
value=REPLY_LANGUAGES[0],
|
370 |
-
)
|
371 |
-
|
372 |
-
with gr.Tab(label=i18n("高级")):
|
373 |
-
gr.HTML(get_html("appearance_switcher.html").format(
|
374 |
-
label=i18n("切换亮暗色主题")), elem_classes="insert-block", visible=False)
|
375 |
-
use_streaming_checkbox = gr.Checkbox(
|
376 |
-
label=i18n("实时传输回答"), value=True, visible=ENABLE_STREAMING_OPTION, elem_classes="switch-checkbox"
|
377 |
-
)
|
378 |
-
name_chat_method = gr.Dropdown(
|
379 |
-
label=i18n("对话命名方式"),
|
380 |
-
choices=HISTORY_NAME_METHODS,
|
381 |
-
multiselect=False,
|
382 |
-
interactive=True,
|
383 |
-
value=HISTORY_NAME_METHODS[chat_name_method_index],
|
384 |
-
)
|
385 |
-
single_turn_checkbox = gr.Checkbox(label=i18n(
|
386 |
-
"单轮对话"), value=False, elem_classes="switch-checkbox", elem_id="gr-single-session-cb", visible=False)
|
387 |
-
# checkUpdateBtn = gr.Button(i18n("🔄 检查更新..."), visible=check_update)
|
388 |
-
|
389 |
-
with gr.Tab(i18n("网络")):
|
390 |
-
gr.Markdown(
|
391 |
-
i18n("⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置"), elem_id="netsetting-warning")
|
392 |
-
default_btn = gr.Button(i18n("🔙 恢复默认网络设置"))
|
393 |
-
# 网络代理
|
394 |
-
proxyTxt = gr.Textbox(
|
395 |
-
show_label=True,
|
396 |
-
placeholder=i18n("未设置代理..."),
|
397 |
-
label=i18n("代理地址"),
|
398 |
-
value=config.http_proxy,
|
399 |
-
lines=1,
|
400 |
-
interactive=False,
|
401 |
-
# container=False,
|
402 |
-
elem_classes="view-only-textbox no-container",
|
403 |
-
)
|
404 |
-
# changeProxyBtn = gr.Button(i18n("🔄 设置代理地址"))
|
405 |
-
|
406 |
-
# 优先展示自定义的api_host
|
407 |
-
apihostTxt = gr.Textbox(
|
408 |
-
show_label=True,
|
409 |
-
placeholder="api.openai.com",
|
410 |
-
label="OpenAI API-Host",
|
411 |
-
value=config.api_host or shared.API_HOST,
|
412 |
-
lines=1,
|
413 |
-
interactive=False,
|
414 |
-
# container=False,
|
415 |
-
elem_classes="view-only-textbox no-container",
|
416 |
-
)
|
417 |
-
|
418 |
-
with gr.Tab(label=i18n("关于"), elem_id="about-tab"):
|
419 |
-
gr.Markdown(
|
420 |
-
'<img alt="Chuanhu Chat logo" src="file=web_assets/icon/any-icon-512.png" style="max-width: 144px;">')
|
421 |
-
gr.Markdown("# "+i18n("川虎Chat"))
|
422 |
-
gr.HTML(get_html("footer.html").format(
|
423 |
-
versions=versions_html()), elem_id="footer")
|
424 |
-
gr.Markdown(CHUANHU_DESCRIPTION, elem_id="description")
|
425 |
-
|
426 |
-
with gr.Box(elem_id="chuanhu-training"):
|
427 |
-
with gr.Row():
|
428 |
-
gr.Markdown("## "+i18n("训练"))
|
429 |
-
gr.HTML(get_html("close_btn.html").format(
|
430 |
-
obj="box"), elem_classes="close-btn")
|
431 |
-
with gr.Tabs(elem_id="chuanhu-training-tabs"):
|
432 |
-
with gr.Tab(label="OpenAI "+i18n("微调")):
|
433 |
-
openai_train_status = gr.Markdown(label=i18n("训练状态"), value=i18n(
|
434 |
-
"查看[使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)"))
|
435 |
-
|
436 |
-
with gr.Tab(label=i18n("准备数据集")):
|
437 |
-
dataset_preview_json = gr.JSON(
|
438 |
-
label=i18n("数据集预览"))
|
439 |
-
dataset_selection = gr.Files(label=i18n("选择数据集"), file_types=[
|
440 |
-
".xlsx", ".jsonl"], file_count="single")
|
441 |
-
upload_to_openai_btn = gr.Button(
|
442 |
-
i18n("上传到OpenAI"), variant="primary", interactive=False)
|
443 |
-
|
444 |
-
with gr.Tab(label=i18n("训练")):
|
445 |
-
openai_ft_file_id = gr.Textbox(label=i18n(
|
446 |
-
"文件ID"), value="", lines=1, placeholder=i18n("上传到 OpenAI 后自动���充"))
|
447 |
-
openai_ft_suffix = gr.Textbox(label=i18n(
|
448 |
-
"模型名称后缀"), value="", lines=1, placeholder=i18n("可选,用于区分不同的模型"))
|
449 |
-
openai_train_epoch_slider = gr.Slider(label=i18n(
|
450 |
-
"训练轮数(Epochs)"), minimum=1, maximum=100, value=3, step=1, interactive=True)
|
451 |
-
openai_start_train_btn = gr.Button(
|
452 |
-
i18n("开始训练"), variant="primary", interactive=False)
|
453 |
-
|
454 |
-
with gr.Tab(label=i18n("状态")):
|
455 |
-
openai_status_refresh_btn = gr.Button(i18n("刷新状态"))
|
456 |
-
openai_cancel_all_jobs_btn = gr.Button(
|
457 |
-
i18n("取消所有任务"))
|
458 |
-
add_to_models_btn = gr.Button(
|
459 |
-
i18n("添加训练好的模型到模型列表"), interactive=False)
|
460 |
-
|
461 |
-
with gr.Box(elem_id="web-config", visible=False):
|
462 |
-
gr.HTML(get_html('web_config.html').format(
|
463 |
-
enableCheckUpdate_config=check_update,
|
464 |
-
hideHistoryWhenNotLoggedIn_config=hide_history_when_not_logged_in,
|
465 |
-
forView_i18n=i18n("仅供查看"),
|
466 |
-
deleteConfirm_i18n_pref=i18n("你真的要删除 "),
|
467 |
-
deleteConfirm_i18n_suff=i18n(" 吗?"),
|
468 |
-
usingLatest_i18n=i18n("您使用的就是最新版!"),
|
469 |
-
updatingMsg_i18n=i18n("正在尝试更新..."),
|
470 |
-
updateSuccess_i18n=i18n("更新成功,请重启本程序"),
|
471 |
-
updateFailure_i18n=i18n(
|
472 |
-
"更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)"),
|
473 |
-
regenerate_i18n=i18n("重新生成"),
|
474 |
-
deleteRound_i18n=i18n("删除这轮问答"),
|
475 |
-
renameChat_i18n=i18n("重命名该对话"),
|
476 |
-
validFileName_i18n=i18n("请输入有效的文件名,不要包含以下特殊字符:"),
|
477 |
-
))
|
478 |
-
with gr.Box(elem_id="fake-gradio-components", visible=False):
|
479 |
-
updateChuanhuBtn = gr.Button(
|
480 |
-
visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
|
481 |
-
changeSingleSessionBtn = gr.Button(
|
482 |
-
visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
|
483 |
-
changeOnlineSearchBtn = gr.Button(
|
484 |
-
visible=False, elem_classes="invisible-btn", elem_id="change-online-search-btn")
|
485 |
-
historySelectBtn = gr.Button(
|
486 |
-
visible=False, elem_classes="invisible-btn", elem_id="history-select-btn") # Not used
|
487 |
-
|
488 |
-
# https://github.com/gradio-app/gradio/pull/3296
|
489 |
-
|
490 |
-
def create_greeting(request: gr.Request):
|
491 |
-
if hasattr(request, "username") and request.username: # is not None or is not ""
|
492 |
-
logging.info(f"Get User Name: {request.username}")
|
493 |
-
user_info, user_name = gr.Markdown.update(
|
494 |
-
value=f"User: {request.username}"), request.username
|
495 |
-
else:
|
496 |
-
user_info, user_name = gr.Markdown.update(
|
497 |
-
value=f"", visible=False), ""
|
498 |
-
current_model = get_model(
|
499 |
-
model_name=MODELS[DEFAULT_MODEL], access_key=my_api_key)[0]
|
500 |
-
current_model.set_user_identifier(user_name)
|
501 |
-
if not hide_history_when_not_logged_in or user_name:
|
502 |
-
filename, system_prompt, chatbot = current_model.auto_load()
|
503 |
-
else:
|
504 |
-
system_prompt = gr.update()
|
505 |
-
filename = gr.update()
|
506 |
-
chatbot = gr.Chatbot.update(label=MODELS[DEFAULT_MODEL])
|
507 |
-
return user_info, user_name, current_model, toggle_like_btn_visibility(DEFAULT_MODEL), filename, system_prompt, chatbot, init_history_list(user_name)
|
508 |
-
demo.load(create_greeting, inputs=None, outputs=[
|
509 |
-
user_info, user_name, current_model, like_dislike_area, saveFileName, systemPromptTxt, chatbot, historySelectList], api_name="load")
|
510 |
-
chatgpt_predict_args = dict(
|
511 |
-
fn=predict,
|
512 |
-
inputs=[
|
513 |
-
current_model,
|
514 |
-
user_question,
|
515 |
-
chatbot,
|
516 |
-
use_streaming_checkbox,
|
517 |
-
use_websearch_checkbox,
|
518 |
-
index_files,
|
519 |
-
language_select_dropdown,
|
520 |
-
],
|
521 |
-
outputs=[chatbot, status_display],
|
522 |
-
show_progress=True,
|
523 |
-
)
|
524 |
-
|
525 |
-
start_outputing_args = dict(
|
526 |
-
fn=start_outputing,
|
527 |
-
inputs=[],
|
528 |
-
outputs=[submitBtn, cancelBtn],
|
529 |
-
show_progress=True,
|
530 |
-
)
|
531 |
-
|
532 |
-
end_outputing_args = dict(
|
533 |
-
fn=end_outputing, inputs=[], outputs=[submitBtn, cancelBtn]
|
534 |
-
)
|
535 |
-
|
536 |
-
reset_textbox_args = dict(
|
537 |
-
fn=reset_textbox, inputs=[], outputs=[user_input]
|
538 |
-
)
|
539 |
-
|
540 |
-
transfer_input_args = dict(
|
541 |
-
fn=transfer_input, inputs=[user_input], outputs=[
|
542 |
-
user_question, user_input, submitBtn, cancelBtn], show_progress=True
|
543 |
-
)
|
544 |
-
|
545 |
-
get_usage_args = dict(
|
546 |
-
fn=billing_info, inputs=[current_model], outputs=[
|
547 |
-
usageTxt], show_progress=False
|
548 |
-
)
|
549 |
-
|
550 |
-
load_history_from_file_args = dict(
|
551 |
-
fn=load_chat_history,
|
552 |
-
inputs=[current_model, historySelectList, user_name],
|
553 |
-
outputs=[saveFileName, systemPromptTxt, chatbot]
|
554 |
-
)
|
555 |
-
|
556 |
-
refresh_history_args = dict(
|
557 |
-
fn=get_history_list, inputs=[user_name], outputs=[historySelectList]
|
558 |
-
)
|
559 |
-
|
560 |
-
auto_name_chat_history_args = dict(
|
561 |
-
fn=auto_name_chat_history,
|
562 |
-
inputs=[current_model, name_chat_method, user_question, chatbot, user_name, single_turn_checkbox],
|
563 |
-
outputs=[historySelectList],
|
564 |
-
show_progress=False,
|
565 |
-
)
|
566 |
-
|
567 |
-
# Chatbot
|
568 |
-
cancelBtn.click(interrupt, [current_model], [])
|
569 |
-
|
570 |
-
user_input.submit(**transfer_input_args).then(**
|
571 |
-
chatgpt_predict_args).then(**end_outputing_args).then(**auto_name_chat_history_args)
|
572 |
-
user_input.submit(**get_usage_args)
|
573 |
-
|
574 |
-
# user_input.submit(auto_name_chat_history, [current_model, user_question, chatbot, user_name], [historySelectList], show_progress=False)
|
575 |
-
|
576 |
-
submitBtn.click(**transfer_input_args).then(**chatgpt_predict_args,
|
577 |
-
api_name="predict").then(**end_outputing_args).then(**auto_name_chat_history_args)
|
578 |
-
submitBtn.click(**get_usage_args)
|
579 |
-
|
580 |
-
# submitBtn.click(auto_name_chat_history, [current_model, user_question, chatbot, user_name], [historySelectList], show_progress=False)
|
581 |
-
|
582 |
-
index_files.upload(handle_file_upload, [current_model, index_files, chatbot, language_select_dropdown], [
|
583 |
-
index_files, chatbot, status_display])
|
584 |
-
summarize_btn.click(handle_summarize_index, [
|
585 |
-
current_model, index_files, chatbot, language_select_dropdown], [chatbot, status_display])
|
586 |
-
|
587 |
-
emptyBtn.click(
|
588 |
-
reset,
|
589 |
-
inputs=[current_model, retain_system_prompt_checkbox],
|
590 |
-
outputs=[chatbot, status_display, historySelectList, systemPromptTxt],
|
591 |
-
show_progress=True,
|
592 |
-
_js='(a,b)=>{return clearChatbot(a,b);}',
|
593 |
-
)
|
594 |
-
|
595 |
-
retryBtn.click(**start_outputing_args).then(
|
596 |
-
retry,
|
597 |
-
[
|
598 |
-
current_model,
|
599 |
-
chatbot,
|
600 |
-
use_streaming_checkbox,
|
601 |
-
use_websearch_checkbox,
|
602 |
-
index_files,
|
603 |
-
language_select_dropdown,
|
604 |
-
],
|
605 |
-
[chatbot, status_display],
|
606 |
-
show_progress=True,
|
607 |
-
).then(**end_outputing_args)
|
608 |
-
retryBtn.click(**get_usage_args)
|
609 |
-
|
610 |
-
delFirstBtn.click(
|
611 |
-
delete_first_conversation,
|
612 |
-
[current_model],
|
613 |
-
[status_display],
|
614 |
-
)
|
615 |
-
|
616 |
-
delLastBtn.click(
|
617 |
-
delete_last_conversation,
|
618 |
-
[current_model, chatbot],
|
619 |
-
[chatbot, status_display],
|
620 |
-
show_progress=False
|
621 |
-
)
|
622 |
-
|
623 |
-
likeBtn.click(
|
624 |
-
like,
|
625 |
-
[current_model],
|
626 |
-
[status_display],
|
627 |
-
show_progress=False
|
628 |
-
)
|
629 |
-
|
630 |
-
dislikeBtn.click(
|
631 |
-
dislike,
|
632 |
-
[current_model],
|
633 |
-
[status_display],
|
634 |
-
show_progress=False
|
635 |
-
)
|
636 |
-
|
637 |
-
two_column.change(update_doc_config, [two_column], None)
|
638 |
-
|
639 |
-
# LLM Models
|
640 |
-
keyTxt.change(set_key, [current_model, keyTxt], [
|
641 |
-
user_api_key, status_display], api_name="set_key").then(**get_usage_args)
|
642 |
-
keyTxt.submit(**get_usage_args)
|
643 |
-
single_turn_checkbox.change(
|
644 |
-
set_single_turn, [current_model, single_turn_checkbox], None)
|
645 |
-
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], [
|
646 |
-
current_model, status_display, chatbot, lora_select_dropdown, user_api_key, keyTxt], show_progress=True, api_name="get_model")
|
647 |
-
model_select_dropdown.change(toggle_like_btn_visibility, [model_select_dropdown], [
|
648 |
-
like_dislike_area], show_progress=False)
|
649 |
-
# model_select_dropdown.change(
|
650 |
-
# toggle_file_type, [model_select_dropdown], [index_files], show_progress=False)
|
651 |
-
lora_select_dropdown.change(get_model, [model_select_dropdown, lora_select_dropdown, user_api_key, temperature_slider,
|
652 |
-
top_p_slider, systemPromptTxt, user_name, current_model], [current_model, status_display, chatbot], show_progress=True)
|
653 |
-
|
654 |
-
# Template
|
655 |
-
systemPromptTxt.change(set_system_prompt, [
|
656 |
-
current_model, systemPromptTxt], None)
|
657 |
-
templateRefreshBtn.click(get_template_dropdown, None, [
|
658 |
-
templateFileSelectDropdown])
|
659 |
-
templateFileSelectDropdown.input(
|
660 |
-
load_template,
|
661 |
-
[templateFileSelectDropdown],
|
662 |
-
[promptTemplates, templateSelectDropdown],
|
663 |
-
show_progress=True,
|
664 |
-
)
|
665 |
-
templateSelectDropdown.change(
|
666 |
-
get_template_content,
|
667 |
-
[promptTemplates, templateSelectDropdown, systemPromptTxt],
|
668 |
-
[systemPromptTxt],
|
669 |
-
show_progress=True,
|
670 |
-
)
|
671 |
-
|
672 |
-
# S&L
|
673 |
-
renameHistoryBtn.click(
|
674 |
-
rename_chat_history,
|
675 |
-
[current_model, saveFileName, chatbot, user_name],
|
676 |
-
[historySelectList],
|
677 |
-
show_progress=True,
|
678 |
-
_js='(a,b,c,d)=>{return saveChatHistory(a,b,c,d);}'
|
679 |
-
)
|
680 |
-
exportMarkdownBtn.click(
|
681 |
-
export_markdown,
|
682 |
-
[current_model, saveFileName, chatbot, user_name],
|
683 |
-
[],
|
684 |
-
show_progress=True,
|
685 |
-
)
|
686 |
-
historyRefreshBtn.click(**refresh_history_args)
|
687 |
-
historyDeleteBtn.click(delete_chat_history, [current_model, historySelectList, user_name], [status_display, historySelectList, chatbot], _js='(a,b,c)=>{return showConfirmationDialog(a, b, c);}').then(
|
688 |
-
reset,
|
689 |
-
inputs=[current_model, retain_system_prompt_checkbox],
|
690 |
-
outputs=[chatbot, status_display, historySelectList, systemPromptTxt],
|
691 |
-
show_progress=True,
|
692 |
-
_js='(a,b)=>{return clearChatbot(a,b);}',
|
693 |
-
)
|
694 |
-
historySelectList.input(**load_history_from_file_args)
|
695 |
-
uploadFileBtn.upload(upload_chat_history, [current_model, uploadFileBtn, user_name], [
|
696 |
-
saveFileName, systemPromptTxt, chatbot]).then(**refresh_history_args)
|
697 |
-
historyDownloadBtn.click(None, [
|
698 |
-
user_name, historySelectList], None, _js='(a,b)=>{return downloadHistory(a,b,".json");}')
|
699 |
-
historyMarkdownDownloadBtn.click(None, [
|
700 |
-
user_name, historySelectList], None, _js='(a,b)=>{return downloadHistory(a,b,".md");}')
|
701 |
-
historySearchTextbox.input(
|
702 |
-
filter_history,
|
703 |
-
[user_name, historySearchTextbox],
|
704 |
-
[historySelectList]
|
705 |
-
)
|
706 |
-
|
707 |
-
# Train
|
708 |
-
dataset_selection.upload(handle_dataset_selection, dataset_selection, [
|
709 |
-
dataset_preview_json, upload_to_openai_btn, openai_train_status])
|
710 |
-
dataset_selection.clear(handle_dataset_clear, [], [
|
711 |
-
dataset_preview_json, upload_to_openai_btn])
|
712 |
-
upload_to_openai_btn.click(upload_to_openai, [dataset_selection], [
|
713 |
-
openai_ft_file_id, openai_train_status], show_progress=True)
|
714 |
-
|
715 |
-
openai_ft_file_id.change(lambda x: gr.update(interactive=True) if len(
|
716 |
-
x) > 0 else gr.update(interactive=False), [openai_ft_file_id], [openai_start_train_btn])
|
717 |
-
openai_start_train_btn.click(start_training, [
|
718 |
-
openai_ft_file_id, openai_ft_suffix, openai_train_epoch_slider], [openai_train_status])
|
719 |
-
|
720 |
-
openai_status_refresh_btn.click(get_training_status, [], [
|
721 |
-
openai_train_status, add_to_models_btn])
|
722 |
-
add_to_models_btn.click(add_to_models, [], [
|
723 |
-
model_select_dropdown, openai_train_status], show_progress=True)
|
724 |
-
openai_cancel_all_jobs_btn.click(
|
725 |
-
cancel_all_jobs, [], [openai_train_status], show_progress=True)
|
726 |
-
|
727 |
-
# Advanced
|
728 |
-
max_context_length_slider.change(
|
729 |
-
set_token_upper_limit, [current_model, max_context_length_slider], None)
|
730 |
-
temperature_slider.change(
|
731 |
-
set_temperature, [current_model, temperature_slider], None)
|
732 |
-
top_p_slider.change(set_top_p, [current_model, top_p_slider], None)
|
733 |
-
n_choices_slider.change(
|
734 |
-
set_n_choices, [current_model, n_choices_slider], None)
|
735 |
-
stop_sequence_txt.change(
|
736 |
-
set_stop_sequence, [current_model, stop_sequence_txt], None)
|
737 |
-
max_generation_slider.change(
|
738 |
-
set_max_tokens, [current_model, max_generation_slider], None)
|
739 |
-
presence_penalty_slider.change(
|
740 |
-
set_presence_penalty, [current_model, presence_penalty_slider], None)
|
741 |
-
frequency_penalty_slider.change(
|
742 |
-
set_frequency_penalty, [current_model, frequency_penalty_slider], None)
|
743 |
-
logit_bias_txt.change(
|
744 |
-
set_logit_bias, [current_model, logit_bias_txt], None)
|
745 |
-
user_identifier_txt.change(set_user_identifier, [
|
746 |
-
current_model, user_identifier_txt], None)
|
747 |
-
|
748 |
-
default_btn.click(
|
749 |
-
reset_default, [], [apihostTxt, proxyTxt, status_display], show_progress=True
|
750 |
-
)
|
751 |
-
# changeAPIURLBtn.click(
|
752 |
-
# change_api_host,
|
753 |
-
# [apihostTxt],
|
754 |
-
# [status_display],
|
755 |
-
# show_progress=True,
|
756 |
-
# )
|
757 |
-
# changeProxyBtn.click(
|
758 |
-
# change_proxy,
|
759 |
-
# [proxyTxt],
|
760 |
-
# [status_display],
|
761 |
-
# show_progress=True,
|
762 |
-
# )
|
763 |
-
# checkUpdateBtn.click(fn=None, _js='manualCheckUpdate')
|
764 |
-
|
765 |
-
# Invisible elements
|
766 |
-
updateChuanhuBtn.click(
|
767 |
-
update_chuanhu,
|
768 |
-
[],
|
769 |
-
[status_display],
|
770 |
-
show_progress=True,
|
771 |
-
)
|
772 |
-
changeSingleSessionBtn.click(
|
773 |
-
fn=lambda value: gr.Checkbox.update(value=value),
|
774 |
-
inputs=[single_turn_checkbox],
|
775 |
-
outputs=[single_turn_checkbox],
|
776 |
-
_js='(a)=>{return bgChangeSingleSession(a);}'
|
777 |
-
)
|
778 |
-
changeOnlineSearchBtn.click(
|
779 |
-
fn=lambda value: gr.Checkbox.update(value=value),
|
780 |
-
inputs=[use_websearch_checkbox],
|
781 |
-
outputs=[use_websearch_checkbox],
|
782 |
-
_js='(a)=>{return bgChangeOnlineSearch(a);}'
|
783 |
-
)
|
784 |
-
historySelectBtn.click( # This is an experimental feature... Not actually used.
|
785 |
-
fn=load_chat_history,
|
786 |
-
inputs=[current_model, historySelectList],
|
787 |
-
outputs=[saveFileName, systemPromptTxt, chatbot],
|
788 |
-
_js='(a,b)=>{return bgSelectHistory(a,b);}'
|
789 |
-
)
|
790 |
-
|
791 |
-
|
792 |
-
logging.info(
|
793 |
-
colorama.Back.GREEN
|
794 |
-
+ "\n川虎的温馨提示:访问 http://localhost:7860 查看界面"
|
795 |
-
+ colorama.Style.RESET_ALL
|
796 |
-
)
|
797 |
-
# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
|
798 |
-
demo.title = i18n("川虎Chat 🚀")
|
799 |
-
|
800 |
-
if __name__ == "__main__":
|
801 |
-
reload_javascript()
|
802 |
-
demo.queue(concurrency_count=CONCURRENT_COUNT).launch(
|
803 |
-
allowed_paths=["history", "web_assets"],
|
804 |
-
share=share,
|
805 |
-
auth=auth_from_conf if authflag else None,
|
806 |
-
favicon_path="./web_assets/favicon.ico",
|
807 |
-
inbrowser=not dockerflag, # 禁止在docker下开启inbrowser
|
808 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile
CHANGED
@@ -1,18 +1,14 @@
|
|
1 |
-
FROM python:3.9
|
2 |
-
RUN apt-get update
|
3 |
-
&& apt-get install -y build-essential \
|
4 |
-
&& apt-get clean \
|
5 |
-
&& rm -rf /var/lib/apt/lists/*
|
6 |
COPY requirements.txt .
|
7 |
-
|
8 |
-
RUN pip install --user --no-cache-dir -r requirements.txt
|
9 |
-
# RUN pip install --user --no-cache-dir -r requirements_advanced.txt
|
10 |
|
11 |
-
FROM python:3.9
|
12 |
-
|
13 |
COPY --from=builder /root/.local /root/.local
|
14 |
ENV PATH=/root/.local/bin:$PATH
|
15 |
COPY . /app
|
16 |
WORKDIR /app
|
17 |
-
ENV
|
18 |
-
|
|
|
|
1 |
+
FROM python:3.9 as builder
|
2 |
+
RUN apt-get update && apt-get install -y build-essential
|
|
|
|
|
|
|
3 |
COPY requirements.txt .
|
4 |
+
RUN pip install --user -r requirements.txt
|
|
|
|
|
5 |
|
6 |
+
FROM python:3.9
|
7 |
+
MAINTAINER iskoldt
|
8 |
COPY --from=builder /root/.local /root/.local
|
9 |
ENV PATH=/root/.local/bin:$PATH
|
10 |
COPY . /app
|
11 |
WORKDIR /app
|
12 |
+
ENV my_api_key empty
|
13 |
+
ENV dockerrun yes
|
14 |
+
CMD ["python3", "-u", "ChuanhuChatbot.py", "2>&1", "|", "tee", "/var/log/application.log"]
|
README.md
CHANGED
@@ -1,11 +1,12 @@
|
|
1 |
---
|
2 |
title: ChuanhuChatGPT
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
6 |
sdk: gradio
|
7 |
-
sdk_version: 3.
|
8 |
-
app_file:
|
|
|
9 |
license: gpl-3.0
|
10 |
---
|
11 |
|
|
|
1 |
---
|
2 |
title: ChuanhuChatGPT
|
3 |
+
emoji: 🐠
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: red
|
6 |
sdk: gradio
|
7 |
+
sdk_version: 3.23.0
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
license: gpl-3.0
|
11 |
---
|
12 |
|
app.py
ADDED
@@ -0,0 +1,455 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding:utf-8 -*-
|
2 |
+
import os
|
3 |
+
import logging
|
4 |
+
import sys
|
5 |
+
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
from utils import *
|
9 |
+
from presets import *
|
10 |
+
from overwrites import *
|
11 |
+
from chat_func import *
|
12 |
+
|
13 |
+
logging.basicConfig(
|
14 |
+
level=logging.DEBUG,
|
15 |
+
format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s",
|
16 |
+
)
|
17 |
+
|
18 |
+
my_api_key = "" # 在这里输入你的 API 密钥
|
19 |
+
|
20 |
+
# if we are running in Docker
|
21 |
+
if os.environ.get("dockerrun") == "yes":
|
22 |
+
dockerflag = True
|
23 |
+
else:
|
24 |
+
dockerflag = False
|
25 |
+
|
26 |
+
authflag = False
|
27 |
+
|
28 |
+
if dockerflag:
|
29 |
+
my_api_key = os.environ.get("my_api_key")
|
30 |
+
if my_api_key == "empty":
|
31 |
+
logging.error("Please give a api key!")
|
32 |
+
sys.exit(1)
|
33 |
+
# auth
|
34 |
+
username = os.environ.get("USERNAME")
|
35 |
+
password = os.environ.get("PASSWORD")
|
36 |
+
if not (isinstance(username, type(None)) or isinstance(password, type(None))):
|
37 |
+
authflag = True
|
38 |
+
else:
|
39 |
+
if (
|
40 |
+
not my_api_key
|
41 |
+
and os.path.exists("api_key.txt")
|
42 |
+
and os.path.getsize("api_key.txt")
|
43 |
+
):
|
44 |
+
with open("api_key.txt", "r") as f:
|
45 |
+
my_api_key = f.read().strip()
|
46 |
+
if os.path.exists("auth.json"):
|
47 |
+
with open("auth.json", "r") as f:
|
48 |
+
auth = json.load(f)
|
49 |
+
username = auth["username"]
|
50 |
+
password = auth["password"]
|
51 |
+
if username != "" and password != "":
|
52 |
+
authflag = True
|
53 |
+
|
54 |
+
gr.Chatbot.postprocess = postprocess
|
55 |
+
PromptHelper.compact_text_chunks = compact_text_chunks
|
56 |
+
|
57 |
+
with open("custom.css", "r", encoding="utf-8") as f:
|
58 |
+
customCSS = f.read()
|
59 |
+
|
60 |
+
with gr.Blocks(
|
61 |
+
css=customCSS,
|
62 |
+
theme=gr.themes.Soft(
|
63 |
+
primary_hue=gr.themes.Color(
|
64 |
+
c50="#02C160",
|
65 |
+
c100="rgba(2, 193, 96, 0.2)",
|
66 |
+
c200="#02C160",
|
67 |
+
c300="rgba(2, 193, 96, 0.32)",
|
68 |
+
c400="rgba(2, 193, 96, 0.32)",
|
69 |
+
c500="rgba(2, 193, 96, 1.0)",
|
70 |
+
c600="rgba(2, 193, 96, 1.0)",
|
71 |
+
c700="rgba(2, 193, 96, 0.32)",
|
72 |
+
c800="rgba(2, 193, 96, 0.32)",
|
73 |
+
c900="#02C160",
|
74 |
+
c950="#02C160",
|
75 |
+
),
|
76 |
+
secondary_hue=gr.themes.Color(
|
77 |
+
c50="#576b95",
|
78 |
+
c100="#576b95",
|
79 |
+
c200="#576b95",
|
80 |
+
c300="#576b95",
|
81 |
+
c400="#576b95",
|
82 |
+
c500="#576b95",
|
83 |
+
c600="#576b95",
|
84 |
+
c700="#576b95",
|
85 |
+
c800="#576b95",
|
86 |
+
c900="#576b95",
|
87 |
+
c950="#576b95",
|
88 |
+
),
|
89 |
+
neutral_hue=gr.themes.Color(
|
90 |
+
name="gray",
|
91 |
+
c50="#f9fafb",
|
92 |
+
c100="#f3f4f6",
|
93 |
+
c200="#e5e7eb",
|
94 |
+
c300="#d1d5db",
|
95 |
+
c400="#B2B2B2",
|
96 |
+
c500="#808080",
|
97 |
+
c600="#636363",
|
98 |
+
c700="#515151",
|
99 |
+
c800="#393939",
|
100 |
+
c900="#272727",
|
101 |
+
c950="#171717",
|
102 |
+
),
|
103 |
+
radius_size=gr.themes.sizes.radius_sm,
|
104 |
+
).set(
|
105 |
+
button_primary_background_fill="#06AE56",
|
106 |
+
button_primary_background_fill_dark="#06AE56",
|
107 |
+
button_primary_background_fill_hover="#07C863",
|
108 |
+
button_primary_border_color="#06AE56",
|
109 |
+
button_primary_border_color_dark="#06AE56",
|
110 |
+
button_primary_text_color="#FFFFFF",
|
111 |
+
button_primary_text_color_dark="#FFFFFF",
|
112 |
+
button_secondary_background_fill="#F2F2F2",
|
113 |
+
button_secondary_background_fill_dark="#2B2B2B",
|
114 |
+
button_secondary_text_color="#393939",
|
115 |
+
button_secondary_text_color_dark="#FFFFFF",
|
116 |
+
# background_fill_primary="#F7F7F7",
|
117 |
+
# background_fill_primary_dark="#1F1F1F",
|
118 |
+
block_title_text_color="*primary_500",
|
119 |
+
block_title_background_fill="*primary_100",
|
120 |
+
input_background_fill="#F6F6F6",
|
121 |
+
),
|
122 |
+
) as demo:
|
123 |
+
history = gr.State([])
|
124 |
+
token_count = gr.State([])
|
125 |
+
promptTemplates = gr.State(load_template(get_template_names(plain=True)[0], mode=2))
|
126 |
+
user_api_key = gr.State(my_api_key)
|
127 |
+
TRUECOMSTANT = gr.State(True)
|
128 |
+
FALSECONSTANT = gr.State(False)
|
129 |
+
topic = gr.State("未命名对话历史记录")
|
130 |
+
|
131 |
+
with gr.Row():
|
132 |
+
gr.HTML(title)
|
133 |
+
status_display = gr.Markdown(get_geoip(), elem_id="status_display")
|
134 |
+
|
135 |
+
with gr.Row(scale=1).style(equal_height=True):
|
136 |
+
with gr.Column(scale=5):
|
137 |
+
with gr.Row(scale=1):
|
138 |
+
chatbot = gr.Chatbot(elem_id="chuanhu_chatbot").style(height="100%")
|
139 |
+
with gr.Row(scale=1):
|
140 |
+
with gr.Column(scale=12):
|
141 |
+
user_input = gr.Textbox(
|
142 |
+
show_label=False, placeholder="在这里输入"
|
143 |
+
).style(container=False)
|
144 |
+
with gr.Column(min_width=70, scale=1):
|
145 |
+
submitBtn = gr.Button("发送", variant="primary")
|
146 |
+
with gr.Row(scale=1):
|
147 |
+
emptyBtn = gr.Button(
|
148 |
+
"🧹 新的对话",
|
149 |
+
)
|
150 |
+
retryBtn = gr.Button("🔄 重新生成")
|
151 |
+
delLastBtn = gr.Button("🗑️ 删除一条对话")
|
152 |
+
reduceTokenBtn = gr.Button("♻�� 总结对话")
|
153 |
+
|
154 |
+
with gr.Column():
|
155 |
+
with gr.Column(min_width=50, scale=1):
|
156 |
+
with gr.Tab(label="ChatGPT"):
|
157 |
+
keyTxt = gr.Textbox(
|
158 |
+
show_label=True,
|
159 |
+
placeholder=f"OpenAI API-key...",
|
160 |
+
value=hide_middle_chars(my_api_key),
|
161 |
+
type="password",
|
162 |
+
visible=not HIDE_MY_KEY,
|
163 |
+
label="API-Key",
|
164 |
+
)
|
165 |
+
model_select_dropdown = gr.Dropdown(
|
166 |
+
label="选择模型", choices=MODELS, multiselect=False, value=MODELS[0]
|
167 |
+
)
|
168 |
+
use_streaming_checkbox = gr.Checkbox(
|
169 |
+
label="实时传输回答", value=True, visible=enable_streaming_option
|
170 |
+
)
|
171 |
+
use_websearch_checkbox = gr.Checkbox(label="使用在线搜索", value=False)
|
172 |
+
index_files = gr.Files(label="上传索引文件", type="file", multiple=True)
|
173 |
+
|
174 |
+
with gr.Tab(label="Prompt"):
|
175 |
+
systemPromptTxt = gr.Textbox(
|
176 |
+
show_label=True,
|
177 |
+
placeholder=f"在这里输入System Prompt...",
|
178 |
+
label="System prompt",
|
179 |
+
value=initial_prompt,
|
180 |
+
lines=10,
|
181 |
+
).style(container=False)
|
182 |
+
with gr.Accordion(label="加载Prompt模板", open=True):
|
183 |
+
with gr.Column():
|
184 |
+
with gr.Row():
|
185 |
+
with gr.Column(scale=6):
|
186 |
+
templateFileSelectDropdown = gr.Dropdown(
|
187 |
+
label="选择Prompt模板集合文件",
|
188 |
+
choices=get_template_names(plain=True),
|
189 |
+
multiselect=False,
|
190 |
+
value=get_template_names(plain=True)[0],
|
191 |
+
).style(container=False)
|
192 |
+
with gr.Column(scale=1):
|
193 |
+
templateRefreshBtn = gr.Button("🔄 刷新")
|
194 |
+
with gr.Row():
|
195 |
+
with gr.Column():
|
196 |
+
templateSelectDropdown = gr.Dropdown(
|
197 |
+
label="从Prompt模板中加载",
|
198 |
+
choices=load_template(
|
199 |
+
get_template_names(plain=True)[0], mode=1
|
200 |
+
),
|
201 |
+
multiselect=False,
|
202 |
+
value=load_template(
|
203 |
+
get_template_names(plain=True)[0], mode=1
|
204 |
+
)[0],
|
205 |
+
).style(container=False)
|
206 |
+
|
207 |
+
with gr.Tab(label="保存/加载"):
|
208 |
+
with gr.Accordion(label="保存/加载对话历史记录", open=True):
|
209 |
+
with gr.Column():
|
210 |
+
with gr.Row():
|
211 |
+
with gr.Column(scale=6):
|
212 |
+
historyFileSelectDropdown = gr.Dropdown(
|
213 |
+
label="从列表中加载对话",
|
214 |
+
choices=get_history_names(plain=True),
|
215 |
+
multiselect=False,
|
216 |
+
value=get_history_names(plain=True)[0],
|
217 |
+
)
|
218 |
+
with gr.Column(scale=1):
|
219 |
+
historyRefreshBtn = gr.Button("🔄 刷新")
|
220 |
+
with gr.Row():
|
221 |
+
with gr.Column(scale=6):
|
222 |
+
saveFileName = gr.Textbox(
|
223 |
+
show_label=True,
|
224 |
+
placeholder=f"设置文件名: 默认为.json,可选为.md",
|
225 |
+
label="设置保存文件名",
|
226 |
+
value="对话历史记录",
|
227 |
+
).style(container=True)
|
228 |
+
with gr.Column(scale=1):
|
229 |
+
saveHistoryBtn = gr.Button("💾 保存对话")
|
230 |
+
exportMarkdownBtn = gr.Button("📝 导出为Markdown")
|
231 |
+
gr.Markdown("默认保存于history文件夹")
|
232 |
+
with gr.Row():
|
233 |
+
with gr.Column():
|
234 |
+
downloadFile = gr.File(interactive=True)
|
235 |
+
|
236 |
+
with gr.Tab(label="高级"):
|
237 |
+
default_btn = gr.Button("🔙 恢复默认设置")
|
238 |
+
gr.Markdown("# ⚠️ 务必谨慎更改 ⚠️\n\n如果无法使用请恢复默认设��")
|
239 |
+
|
240 |
+
with gr.Accordion("参数", open=False):
|
241 |
+
top_p = gr.Slider(
|
242 |
+
minimum=-0,
|
243 |
+
maximum=1.0,
|
244 |
+
value=1.0,
|
245 |
+
step=0.05,
|
246 |
+
interactive=True,
|
247 |
+
label="Top-p",
|
248 |
+
)
|
249 |
+
temperature = gr.Slider(
|
250 |
+
minimum=-0,
|
251 |
+
maximum=2.0,
|
252 |
+
value=1.0,
|
253 |
+
step=0.1,
|
254 |
+
interactive=True,
|
255 |
+
label="Temperature",
|
256 |
+
)
|
257 |
+
|
258 |
+
apiurlTxt = gr.Textbox(
|
259 |
+
show_label=True,
|
260 |
+
placeholder=f"在这里输入API地址...",
|
261 |
+
label="API地址",
|
262 |
+
value="https://api.openai.com/v1/chat/completions",
|
263 |
+
lines=2,
|
264 |
+
)
|
265 |
+
changeAPIURLBtn = gr.Button("🔄 切换API地址")
|
266 |
+
proxyTxt = gr.Textbox(
|
267 |
+
show_label=True,
|
268 |
+
placeholder=f"在这里输入代理地址...",
|
269 |
+
label="代理地址(示例:http://127.0.0.1:10809)",
|
270 |
+
value="",
|
271 |
+
lines=2,
|
272 |
+
)
|
273 |
+
changeProxyBtn = gr.Button("🔄 设置代理地址")
|
274 |
+
|
275 |
+
gr.Markdown(description)
|
276 |
+
|
277 |
+
keyTxt.submit(submit_key, keyTxt, [user_api_key, status_display])
|
278 |
+
keyTxt.change(submit_key, keyTxt, [user_api_key, status_display])
|
279 |
+
# Chatbot
|
280 |
+
user_input.submit(
|
281 |
+
predict,
|
282 |
+
[
|
283 |
+
user_api_key,
|
284 |
+
systemPromptTxt,
|
285 |
+
history,
|
286 |
+
user_input,
|
287 |
+
chatbot,
|
288 |
+
token_count,
|
289 |
+
top_p,
|
290 |
+
temperature,
|
291 |
+
use_streaming_checkbox,
|
292 |
+
model_select_dropdown,
|
293 |
+
use_websearch_checkbox,
|
294 |
+
index_files,
|
295 |
+
],
|
296 |
+
[chatbot, history, status_display, token_count],
|
297 |
+
show_progress=True,
|
298 |
+
)
|
299 |
+
user_input.submit(reset_textbox, [], [user_input])
|
300 |
+
|
301 |
+
submitBtn.click(
|
302 |
+
predict,
|
303 |
+
[
|
304 |
+
user_api_key,
|
305 |
+
systemPromptTxt,
|
306 |
+
history,
|
307 |
+
user_input,
|
308 |
+
chatbot,
|
309 |
+
token_count,
|
310 |
+
top_p,
|
311 |
+
temperature,
|
312 |
+
use_streaming_checkbox,
|
313 |
+
model_select_dropdown,
|
314 |
+
use_websearch_checkbox,
|
315 |
+
index_files,
|
316 |
+
],
|
317 |
+
[chatbot, history, status_display, token_count],
|
318 |
+
show_progress=True,
|
319 |
+
)
|
320 |
+
submitBtn.click(reset_textbox, [], [user_input])
|
321 |
+
|
322 |
+
emptyBtn.click(
|
323 |
+
reset_state,
|
324 |
+
outputs=[chatbot, history, token_count, status_display],
|
325 |
+
show_progress=True,
|
326 |
+
)
|
327 |
+
|
328 |
+
retryBtn.click(
|
329 |
+
retry,
|
330 |
+
[
|
331 |
+
user_api_key,
|
332 |
+
systemPromptTxt,
|
333 |
+
history,
|
334 |
+
chatbot,
|
335 |
+
token_count,
|
336 |
+
top_p,
|
337 |
+
temperature,
|
338 |
+
use_streaming_checkbox,
|
339 |
+
model_select_dropdown,
|
340 |
+
],
|
341 |
+
[chatbot, history, status_display, token_count],
|
342 |
+
show_progress=True,
|
343 |
+
)
|
344 |
+
|
345 |
+
delLastBtn.click(
|
346 |
+
delete_last_conversation,
|
347 |
+
[chatbot, history, token_count],
|
348 |
+
[chatbot, history, token_count, status_display],
|
349 |
+
show_progress=True,
|
350 |
+
)
|
351 |
+
|
352 |
+
reduceTokenBtn.click(
|
353 |
+
reduce_token_size,
|
354 |
+
[
|
355 |
+
user_api_key,
|
356 |
+
systemPromptTxt,
|
357 |
+
history,
|
358 |
+
chatbot,
|
359 |
+
token_count,
|
360 |
+
top_p,
|
361 |
+
temperature,
|
362 |
+
gr.State(0),
|
363 |
+
model_select_dropdown,
|
364 |
+
],
|
365 |
+
[chatbot, history, status_display, token_count],
|
366 |
+
show_progress=True,
|
367 |
+
)
|
368 |
+
|
369 |
+
# Template
|
370 |
+
templateRefreshBtn.click(get_template_names, None, [templateFileSelectDropdown])
|
371 |
+
templateFileSelectDropdown.change(
|
372 |
+
load_template,
|
373 |
+
[templateFileSelectDropdown],
|
374 |
+
[promptTemplates, templateSelectDropdown],
|
375 |
+
show_progress=True,
|
376 |
+
)
|
377 |
+
templateSelectDropdown.change(
|
378 |
+
get_template_content,
|
379 |
+
[promptTemplates, templateSelectDropdown, systemPromptTxt],
|
380 |
+
[systemPromptTxt],
|
381 |
+
show_progress=True,
|
382 |
+
)
|
383 |
+
|
384 |
+
# S&L
|
385 |
+
saveHistoryBtn.click(
|
386 |
+
save_chat_history,
|
387 |
+
[saveFileName, systemPromptTxt, history, chatbot],
|
388 |
+
downloadFile,
|
389 |
+
show_progress=True,
|
390 |
+
)
|
391 |
+
saveHistoryBtn.click(get_history_names, None, [historyFileSelectDropdown])
|
392 |
+
exportMarkdownBtn.click(
|
393 |
+
export_markdown,
|
394 |
+
[saveFileName, systemPromptTxt, history, chatbot],
|
395 |
+
downloadFile,
|
396 |
+
show_progress=True,
|
397 |
+
)
|
398 |
+
historyRefreshBtn.click(get_history_names, None, [historyFileSelectDropdown])
|
399 |
+
historyFileSelectDropdown.change(
|
400 |
+
load_chat_history,
|
401 |
+
[historyFileSelectDropdown, systemPromptTxt, history, chatbot],
|
402 |
+
[saveFileName, systemPromptTxt, history, chatbot],
|
403 |
+
show_progress=True,
|
404 |
+
)
|
405 |
+
downloadFile.change(
|
406 |
+
load_chat_history,
|
407 |
+
[downloadFile, systemPromptTxt, history, chatbot],
|
408 |
+
[saveFileName, systemPromptTxt, history, chatbot],
|
409 |
+
)
|
410 |
+
|
411 |
+
# Advanced
|
412 |
+
default_btn.click(
|
413 |
+
reset_default, [], [apiurlTxt, proxyTxt, status_display], show_progress=True
|
414 |
+
)
|
415 |
+
changeAPIURLBtn.click(
|
416 |
+
change_api_url,
|
417 |
+
[apiurlTxt],
|
418 |
+
[status_display],
|
419 |
+
show_progress=True,
|
420 |
+
)
|
421 |
+
changeProxyBtn.click(
|
422 |
+
change_proxy,
|
423 |
+
[proxyTxt],
|
424 |
+
[status_display],
|
425 |
+
show_progress=True,
|
426 |
+
)
|
427 |
+
|
428 |
+
logging.info(
|
429 |
+
colorama.Back.GREEN
|
430 |
+
+ "\n川虎的温馨提示:访问 http://localhost:7860 查看界面"
|
431 |
+
+ colorama.Style.RESET_ALL
|
432 |
+
)
|
433 |
+
# 默认开启本地服务器,默认可以直接从IP访问,默认不创建公开分享链接
|
434 |
+
demo.title = "川虎ChatGPT 🚀"
|
435 |
+
|
436 |
+
if __name__ == "__main__":
|
437 |
+
reload_javascript()
|
438 |
+
# if running in Docker
|
439 |
+
if dockerflag:
|
440 |
+
if authflag:
|
441 |
+
demo.queue().launch(
|
442 |
+
server_name="0.0.0.0", server_port=7860, auth=(username, password),
|
443 |
+
favicon_path="./assets/favicon.png"
|
444 |
+
)
|
445 |
+
else:
|
446 |
+
demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False, favicon_path="./assets/favicon.png")
|
447 |
+
# if not running in Docker
|
448 |
+
else:
|
449 |
+
if authflag:
|
450 |
+
demo.queue().launch(share=False, auth=(username, password), favicon_path="./assets/favicon.png", inbrowser=True)
|
451 |
+
else:
|
452 |
+
demo.queue(concurrency_count=1000).launch(share=False, favicon_path="./assets/favicon.ico", inbrowser=True) # 改为 share=True 可以创建公开分享链接
|
453 |
+
# demo.queue().launch(server_name="0.0.0.0", server_port=7860, share=False) # 可自定义端口
|
454 |
+
# demo.queue().launch(server_name="0.0.0.0", server_port=7860,auth=("在这里填写用户名", "在这里填写密码")) # 可设置用户名与密码
|
455 |
+
# demo.queue().launch(auth=("在这里填写用户名", "在这里填写密码")) # 适合Nginx反向代理
|
assets/custom.css
DELETED
@@ -1,468 +0,0 @@
|
|
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
CHANGED
@@ -1,502 +1 @@
|
|
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>';
|
|
|
1 |
+
// custom javascript here
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assets/external-scripts.js
DELETED
@@ -1,2 +0,0 @@
|
|
1 |
-
|
2 |
-
// external javascript here
|
|
|
|
|
|
assets/html/appearance_switcher.html
DELETED
@@ -1,11 +0,0 @@
|
|
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
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
<div class="versions">{versions}</div>
|
|
|
|
chat_func.py
ADDED
@@ -0,0 +1,456 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding:utf-8 -*-
|
2 |
+
from __future__ import annotations
|
3 |
+
from typing import TYPE_CHECKING, List
|
4 |
+
|
5 |
+
import logging
|
6 |
+
import json
|
7 |
+
import os
|
8 |
+
import requests
|
9 |
+
import urllib3
|
10 |
+
|
11 |
+
from tqdm import tqdm
|
12 |
+
import colorama
|
13 |
+
from duckduckgo_search import ddg
|
14 |
+
import asyncio
|
15 |
+
import aiohttp
|
16 |
+
|
17 |
+
from presets import *
|
18 |
+
from llama_func import *
|
19 |
+
from utils import *
|
20 |
+
|
21 |
+
# logging.basicConfig(level=logging.INFO, format="%(asctime)s [%(levelname)s] [%(filename)s:%(lineno)d] %(message)s")
|
22 |
+
|
23 |
+
if TYPE_CHECKING:
|
24 |
+
from typing import TypedDict
|
25 |
+
|
26 |
+
class DataframeData(TypedDict):
|
27 |
+
headers: List[str]
|
28 |
+
data: List[List[str | int | bool]]
|
29 |
+
|
30 |
+
|
31 |
+
initial_prompt = "You are a helpful assistant."
|
32 |
+
API_URL = "https://api.openai.com/v1/chat/completions"
|
33 |
+
HISTORY_DIR = "history"
|
34 |
+
TEMPLATES_DIR = "templates"
|
35 |
+
|
36 |
+
def get_response(
|
37 |
+
openai_api_key, system_prompt, history, temperature, top_p, stream, selected_model
|
38 |
+
):
|
39 |
+
headers = {
|
40 |
+
"Content-Type": "application/json",
|
41 |
+
"Authorization": f"Bearer {openai_api_key}",
|
42 |
+
}
|
43 |
+
|
44 |
+
history = [construct_system(system_prompt), *history]
|
45 |
+
|
46 |
+
payload = {
|
47 |
+
"model": selected_model,
|
48 |
+
"messages": history, # [{"role": "user", "content": f"{inputs}"}],
|
49 |
+
"temperature": temperature, # 1.0,
|
50 |
+
"top_p": top_p, # 1.0,
|
51 |
+
"n": 1,
|
52 |
+
"stream": stream,
|
53 |
+
"presence_penalty": 0,
|
54 |
+
"frequency_penalty": 0,
|
55 |
+
}
|
56 |
+
if stream:
|
57 |
+
timeout = timeout_streaming
|
58 |
+
else:
|
59 |
+
timeout = timeout_all
|
60 |
+
|
61 |
+
# 获取环境变量中的代理设置
|
62 |
+
http_proxy = os.environ.get("HTTP_PROXY") or os.environ.get("http_proxy")
|
63 |
+
https_proxy = os.environ.get("HTTPS_PROXY") or os.environ.get("https_proxy")
|
64 |
+
|
65 |
+
# 如果存在代理设置,使用它们
|
66 |
+
proxies = {}
|
67 |
+
if http_proxy:
|
68 |
+
logging.info(f"Using HTTP proxy: {http_proxy}")
|
69 |
+
proxies["http"] = http_proxy
|
70 |
+
if https_proxy:
|
71 |
+
logging.info(f"Using HTTPS proxy: {https_proxy}")
|
72 |
+
proxies["https"] = https_proxy
|
73 |
+
|
74 |
+
# 如果有代理,使用代理发送请求,否则使用默认设置发送请求
|
75 |
+
if proxies:
|
76 |
+
response = requests.post(
|
77 |
+
API_URL,
|
78 |
+
headers=headers,
|
79 |
+
json=payload,
|
80 |
+
stream=True,
|
81 |
+
timeout=timeout,
|
82 |
+
proxies=proxies,
|
83 |
+
)
|
84 |
+
else:
|
85 |
+
response = requests.post(
|
86 |
+
API_URL,
|
87 |
+
headers=headers,
|
88 |
+
json=payload,
|
89 |
+
stream=True,
|
90 |
+
timeout=timeout,
|
91 |
+
)
|
92 |
+
return response
|
93 |
+
|
94 |
+
|
95 |
+
def stream_predict(
|
96 |
+
openai_api_key,
|
97 |
+
system_prompt,
|
98 |
+
history,
|
99 |
+
inputs,
|
100 |
+
chatbot,
|
101 |
+
all_token_counts,
|
102 |
+
top_p,
|
103 |
+
temperature,
|
104 |
+
selected_model,
|
105 |
+
fake_input=None,
|
106 |
+
display_append=""
|
107 |
+
):
|
108 |
+
def get_return_value():
|
109 |
+
return chatbot, history, status_text, all_token_counts
|
110 |
+
|
111 |
+
logging.info("实时回答模式")
|
112 |
+
partial_words = ""
|
113 |
+
counter = 0
|
114 |
+
status_text = "开始实时传输回答……"
|
115 |
+
history.append(construct_user(inputs))
|
116 |
+
history.append(construct_assistant(""))
|
117 |
+
if fake_input:
|
118 |
+
chatbot.append((fake_input, ""))
|
119 |
+
else:
|
120 |
+
chatbot.append((inputs, ""))
|
121 |
+
user_token_count = 0
|
122 |
+
if len(all_token_counts) == 0:
|
123 |
+
system_prompt_token_count = count_token(construct_system(system_prompt))
|
124 |
+
user_token_count = (
|
125 |
+
count_token(construct_user(inputs)) + system_prompt_token_count
|
126 |
+
)
|
127 |
+
else:
|
128 |
+
user_token_count = count_token(construct_user(inputs))
|
129 |
+
all_token_counts.append(user_token_count)
|
130 |
+
logging.info(f"输入token计数: {user_token_count}")
|
131 |
+
yield get_return_value()
|
132 |
+
try:
|
133 |
+
response = get_response(
|
134 |
+
openai_api_key,
|
135 |
+
system_prompt,
|
136 |
+
history,
|
137 |
+
temperature,
|
138 |
+
top_p,
|
139 |
+
True,
|
140 |
+
selected_model,
|
141 |
+
)
|
142 |
+
except requests.exceptions.ConnectTimeout:
|
143 |
+
status_text = (
|
144 |
+
standard_error_msg + connection_timeout_prompt + error_retrieve_prompt
|
145 |
+
)
|
146 |
+
yield get_return_value()
|
147 |
+
return
|
148 |
+
except requests.exceptions.ReadTimeout:
|
149 |
+
status_text = standard_error_msg + read_timeout_prompt + error_retrieve_prompt
|
150 |
+
yield get_return_value()
|
151 |
+
return
|
152 |
+
|
153 |
+
yield get_return_value()
|
154 |
+
error_json_str = ""
|
155 |
+
|
156 |
+
for chunk in tqdm(response.iter_lines()):
|
157 |
+
if counter == 0:
|
158 |
+
counter += 1
|
159 |
+
continue
|
160 |
+
counter += 1
|
161 |
+
# check whether each line is non-empty
|
162 |
+
if chunk:
|
163 |
+
chunk = chunk.decode()
|
164 |
+
chunklength = len(chunk)
|
165 |
+
try:
|
166 |
+
chunk = json.loads(chunk[6:])
|
167 |
+
except json.JSONDecodeError:
|
168 |
+
logging.info(chunk)
|
169 |
+
error_json_str += chunk
|
170 |
+
status_text = f"JSON解析错误。请重置对话。收到的内容: {error_json_str}"
|
171 |
+
yield get_return_value()
|
172 |
+
continue
|
173 |
+
# decode each line as response data is in bytes
|
174 |
+
if chunklength > 6 and "delta" in chunk["choices"][0]:
|
175 |
+
finish_reason = chunk["choices"][0]["finish_reason"]
|
176 |
+
status_text = construct_token_message(
|
177 |
+
sum(all_token_counts), stream=True
|
178 |
+
)
|
179 |
+
if finish_reason == "stop":
|
180 |
+
yield get_return_value()
|
181 |
+
break
|
182 |
+
try:
|
183 |
+
partial_words = (
|
184 |
+
partial_words + chunk["choices"][0]["delta"]["content"]
|
185 |
+
)
|
186 |
+
except KeyError:
|
187 |
+
status_text = (
|
188 |
+
standard_error_msg
|
189 |
+
+ "API回复中找不到内容。很可能是Token计数达到上限了。请重置对话。当前Token计数: "
|
190 |
+
+ str(sum(all_token_counts))
|
191 |
+
)
|
192 |
+
yield get_return_value()
|
193 |
+
break
|
194 |
+
history[-1] = construct_assistant(partial_words)
|
195 |
+
chatbot[-1] = (chatbot[-1][0], partial_words+display_append)
|
196 |
+
all_token_counts[-1] += 1
|
197 |
+
yield get_return_value()
|
198 |
+
|
199 |
+
|
200 |
+
def predict_all(
|
201 |
+
openai_api_key,
|
202 |
+
system_prompt,
|
203 |
+
history,
|
204 |
+
inputs,
|
205 |
+
chatbot,
|
206 |
+
all_token_counts,
|
207 |
+
top_p,
|
208 |
+
temperature,
|
209 |
+
selected_model,
|
210 |
+
fake_input=None,
|
211 |
+
display_append=""
|
212 |
+
):
|
213 |
+
logging.info("一次性回答模式")
|
214 |
+
history.append(construct_user(inputs))
|
215 |
+
history.append(construct_assistant(""))
|
216 |
+
if fake_input:
|
217 |
+
chatbot.append((fake_input, ""))
|
218 |
+
else:
|
219 |
+
chatbot.append((inputs, ""))
|
220 |
+
all_token_counts.append(count_token(construct_user(inputs)))
|
221 |
+
try:
|
222 |
+
response = get_response(
|
223 |
+
openai_api_key,
|
224 |
+
system_prompt,
|
225 |
+
history,
|
226 |
+
temperature,
|
227 |
+
top_p,
|
228 |
+
False,
|
229 |
+
selected_model,
|
230 |
+
)
|
231 |
+
except requests.exceptions.ConnectTimeout:
|
232 |
+
status_text = (
|
233 |
+
standard_error_msg + connection_timeout_prompt + error_retrieve_prompt
|
234 |
+
)
|
235 |
+
return chatbot, history, status_text, all_token_counts
|
236 |
+
except requests.exceptions.ProxyError:
|
237 |
+
status_text = standard_error_msg + proxy_error_prompt + error_retrieve_prompt
|
238 |
+
return chatbot, history, status_text, all_token_counts
|
239 |
+
except requests.exceptions.SSLError:
|
240 |
+
status_text = standard_error_msg + ssl_error_prompt + error_retrieve_prompt
|
241 |
+
return chatbot, history, status_text, all_token_counts
|
242 |
+
response = json.loads(response.text)
|
243 |
+
content = response["choices"][0]["message"]["content"]
|
244 |
+
history[-1] = construct_assistant(content)
|
245 |
+
chatbot[-1] = (chatbot[-1][0], content+display_append)
|
246 |
+
total_token_count = response["usage"]["total_tokens"]
|
247 |
+
all_token_counts[-1] = total_token_count - sum(all_token_counts)
|
248 |
+
status_text = construct_token_message(total_token_count)
|
249 |
+
return chatbot, history, status_text, all_token_counts
|
250 |
+
|
251 |
+
|
252 |
+
def predict(
|
253 |
+
openai_api_key,
|
254 |
+
system_prompt,
|
255 |
+
history,
|
256 |
+
inputs,
|
257 |
+
chatbot,
|
258 |
+
all_token_counts,
|
259 |
+
top_p,
|
260 |
+
temperature,
|
261 |
+
stream=False,
|
262 |
+
selected_model=MODELS[0],
|
263 |
+
use_websearch=False,
|
264 |
+
files = None,
|
265 |
+
should_check_token_count=True,
|
266 |
+
): # repetition_penalty, top_k
|
267 |
+
logging.info("输入为:" + colorama.Fore.BLUE + f"{inputs}" + colorama.Style.RESET_ALL)
|
268 |
+
if files:
|
269 |
+
msg = "构建索引中……(这可能需要比较久的时间)"
|
270 |
+
logging.info(msg)
|
271 |
+
yield chatbot, history, msg, all_token_counts
|
272 |
+
index = construct_index(openai_api_key, file_src=files)
|
273 |
+
msg = "索引构建完成,获取回答中……"
|
274 |
+
yield chatbot, history, msg, all_token_counts
|
275 |
+
history, chatbot, status_text = chat_ai(openai_api_key, index, inputs, history, chatbot)
|
276 |
+
yield chatbot, history, status_text, all_token_counts
|
277 |
+
return
|
278 |
+
|
279 |
+
old_inputs = ""
|
280 |
+
link_references = []
|
281 |
+
if use_websearch:
|
282 |
+
search_results = ddg(inputs, max_results=5)
|
283 |
+
old_inputs = inputs
|
284 |
+
web_results = []
|
285 |
+
for idx, result in enumerate(search_results):
|
286 |
+
logging.info(f"搜索结果{idx + 1}:{result}")
|
287 |
+
domain_name = urllib3.util.parse_url(result["href"]).host
|
288 |
+
web_results.append(f'[{idx+1}]"{result["body"]}"\nURL: {result["href"]}')
|
289 |
+
link_references.append(f"{idx+1}. [{domain_name}]({result['href']})\n")
|
290 |
+
link_references = "\n\n" + "".join(link_references)
|
291 |
+
inputs = (
|
292 |
+
replace_today(WEBSEARCH_PTOMPT_TEMPLATE)
|
293 |
+
.replace("{query}", inputs)
|
294 |
+
.replace("{web_results}", "\n\n".join(web_results))
|
295 |
+
)
|
296 |
+
else:
|
297 |
+
link_references = ""
|
298 |
+
|
299 |
+
if len(openai_api_key) != 51:
|
300 |
+
status_text = standard_error_msg + no_apikey_msg
|
301 |
+
logging.info(status_text)
|
302 |
+
chatbot.append((inputs, ""))
|
303 |
+
if len(history) == 0:
|
304 |
+
history.append(construct_user(inputs))
|
305 |
+
history.append("")
|
306 |
+
all_token_counts.append(0)
|
307 |
+
else:
|
308 |
+
history[-2] = construct_user(inputs)
|
309 |
+
yield chatbot, history, status_text, all_token_counts
|
310 |
+
return
|
311 |
+
|
312 |
+
yield chatbot, history, "开始生成回答……", all_token_counts
|
313 |
+
|
314 |
+
if stream:
|
315 |
+
logging.info("使用流式传输")
|
316 |
+
iter = stream_predict(
|
317 |
+
openai_api_key,
|
318 |
+
system_prompt,
|
319 |
+
history,
|
320 |
+
inputs,
|
321 |
+
chatbot,
|
322 |
+
all_token_counts,
|
323 |
+
top_p,
|
324 |
+
temperature,
|
325 |
+
selected_model,
|
326 |
+
fake_input=old_inputs,
|
327 |
+
display_append=link_references
|
328 |
+
)
|
329 |
+
for chatbot, history, status_text, all_token_counts in iter:
|
330 |
+
yield chatbot, history, status_text, all_token_counts
|
331 |
+
else:
|
332 |
+
logging.info("不使用流式传输")
|
333 |
+
chatbot, history, status_text, all_token_counts = predict_all(
|
334 |
+
openai_api_key,
|
335 |
+
system_prompt,
|
336 |
+
history,
|
337 |
+
inputs,
|
338 |
+
chatbot,
|
339 |
+
all_token_counts,
|
340 |
+
top_p,
|
341 |
+
temperature,
|
342 |
+
selected_model,
|
343 |
+
fake_input=old_inputs,
|
344 |
+
display_append=link_references
|
345 |
+
)
|
346 |
+
yield chatbot, history, status_text, all_token_counts
|
347 |
+
|
348 |
+
logging.info(f"传输完毕。当前token计数为{all_token_counts}")
|
349 |
+
if len(history) > 1 and history[-1]["content"] != inputs:
|
350 |
+
logging.info(
|
351 |
+
"回答为:"
|
352 |
+
+ colorama.Fore.BLUE
|
353 |
+
+ f"{history[-1]['content']}"
|
354 |
+
+ colorama.Style.RESET_ALL
|
355 |
+
)
|
356 |
+
|
357 |
+
if stream:
|
358 |
+
max_token = max_token_streaming
|
359 |
+
else:
|
360 |
+
max_token = max_token_all
|
361 |
+
|
362 |
+
if sum(all_token_counts) > max_token and should_check_token_count:
|
363 |
+
status_text = f"精简token中{all_token_counts}/{max_token}"
|
364 |
+
logging.info(status_text)
|
365 |
+
yield chatbot, history, status_text, all_token_counts
|
366 |
+
iter = reduce_token_size(
|
367 |
+
openai_api_key,
|
368 |
+
system_prompt,
|
369 |
+
history,
|
370 |
+
chatbot,
|
371 |
+
all_token_counts,
|
372 |
+
top_p,
|
373 |
+
temperature,
|
374 |
+
max_token//2,
|
375 |
+
selected_model=selected_model,
|
376 |
+
)
|
377 |
+
for chatbot, history, status_text, all_token_counts in iter:
|
378 |
+
status_text = f"Token 达到上限,已自动降低Token计数至 {status_text}"
|
379 |
+
yield chatbot, history, status_text, all_token_counts
|
380 |
+
|
381 |
+
|
382 |
+
def retry(
|
383 |
+
openai_api_key,
|
384 |
+
system_prompt,
|
385 |
+
history,
|
386 |
+
chatbot,
|
387 |
+
token_count,
|
388 |
+
top_p,
|
389 |
+
temperature,
|
390 |
+
stream=False,
|
391 |
+
selected_model=MODELS[0],
|
392 |
+
):
|
393 |
+
logging.info("重试中……")
|
394 |
+
if len(history) == 0:
|
395 |
+
yield chatbot, history, f"{standard_error_msg}上下文是空的", token_count
|
396 |
+
return
|
397 |
+
history.pop()
|
398 |
+
inputs = history.pop()["content"]
|
399 |
+
token_count.pop()
|
400 |
+
iter = predict(
|
401 |
+
openai_api_key,
|
402 |
+
system_prompt,
|
403 |
+
history,
|
404 |
+
inputs,
|
405 |
+
chatbot,
|
406 |
+
token_count,
|
407 |
+
top_p,
|
408 |
+
temperature,
|
409 |
+
stream=stream,
|
410 |
+
selected_model=selected_model,
|
411 |
+
)
|
412 |
+
logging.info("重试中……")
|
413 |
+
for x in iter:
|
414 |
+
yield x
|
415 |
+
logging.info("重试完毕")
|
416 |
+
|
417 |
+
|
418 |
+
def reduce_token_size(
|
419 |
+
openai_api_key,
|
420 |
+
system_prompt,
|
421 |
+
history,
|
422 |
+
chatbot,
|
423 |
+
token_count,
|
424 |
+
top_p,
|
425 |
+
temperature,
|
426 |
+
max_token_count,
|
427 |
+
selected_model=MODELS[0],
|
428 |
+
):
|
429 |
+
logging.info("开始减少token数量……")
|
430 |
+
iter = predict(
|
431 |
+
openai_api_key,
|
432 |
+
system_prompt,
|
433 |
+
history,
|
434 |
+
summarize_prompt,
|
435 |
+
chatbot,
|
436 |
+
token_count,
|
437 |
+
top_p,
|
438 |
+
temperature,
|
439 |
+
selected_model=selected_model,
|
440 |
+
should_check_token_count=False,
|
441 |
+
)
|
442 |
+
logging.info(f"chatbot: {chatbot}")
|
443 |
+
flag = False
|
444 |
+
for chatbot, history, status_text, previous_token_count in iter:
|
445 |
+
num_chat = find_n(previous_token_count, max_token_count)
|
446 |
+
if flag:
|
447 |
+
chatbot = chatbot[:-1]
|
448 |
+
flag = True
|
449 |
+
history = history[-2*num_chat:] if num_chat > 0 else []
|
450 |
+
token_count = previous_token_count[-num_chat:] if num_chat > 0 else []
|
451 |
+
msg = f"保留了最近{num_chat}轮对话"
|
452 |
+
yield chatbot, history, msg + "," + construct_token_message(
|
453 |
+
sum(token_count) if len(token_count) > 0 else 0,
|
454 |
+
), token_count
|
455 |
+
logging.info(msg)
|
456 |
+
logging.info("减少token数量完毕")
|
config.json
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"hide_history_when_not_logged_in": true
|
3 |
-
}
|
|
|
|
|
|
|
|
config_example.json
DELETED
@@ -1,84 +0,0 @@
|
|
1 |
-
{
|
2 |
-
// 各配置具体说明,见 [https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#配置-configjson]
|
3 |
-
|
4 |
-
//== API 配置 ==
|
5 |
-
"openai_api_key": "", // 你的 OpenAI API Key,一般必填,若空缺则需在图形界面中填入API Key
|
6 |
-
"google_palm_api_key": "", // 你的 Google PaLM API Key,用于 Google PaLM 对话模型
|
7 |
-
"xmchat_api_key": "", // 你的 xmchat API Key,用于 XMChat 对话模型
|
8 |
-
"minimax_api_key": "", // 你的 MiniMax API Key,用于 MiniMax 对话模型
|
9 |
-
"minimax_group_id": "", // 你的 MiniMax Group ID,用于 MiniMax 对话模型
|
10 |
-
"midjourney_proxy_api_base": "https://xxx/mj", // 你的 https://github.com/novicezk/midjourney-proxy 代理地址
|
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 |
-
"ernie_api_key": "",// 你的文心一言在百度云中的API Key,用于文心一言对话模型
|
19 |
-
"ernie_secret_key": "",// 你的文心一言在百度云中的Secret Key,用于文心一言对话模型
|
20 |
-
|
21 |
-
|
22 |
-
//== Azure ==
|
23 |
-
"openai_api_type": "openai", // 可选项:azure, openai
|
24 |
-
"azure_openai_api_key": "", // 你的 Azure OpenAI API Key,用于 Azure OpenAI 对话模型
|
25 |
-
"azure_openai_api_base_url": "", // 你的 Azure Base URL
|
26 |
-
"azure_openai_api_version": "2023-05-15", // 你的 Azure OpenAI API 版本
|
27 |
-
"azure_deployment_name": "", // 你的 Azure OpenAI Chat 模型 Deployment 名称
|
28 |
-
"azure_embedding_deployment_name": "", // 你的 Azure OpenAI Embedding 模型 Deployment 名称
|
29 |
-
"azure_embedding_model_name": "text-embedding-ada-002", // 你的 Azure OpenAI Embedding 模型名称
|
30 |
-
|
31 |
-
//== 基础配置 ==
|
32 |
-
"language": "auto", // 界面语言,可选"auto", "zh_CN", "en_US", "ja_JP", "ko_KR", "sv_SE", "ru_RU", "vi_VN"
|
33 |
-
"users": [], // 用户列表,[[用户名1, 密码1], [用户名2, 密码2], ...]
|
34 |
-
"local_embedding": false, //是否在本地编制索引
|
35 |
-
"hide_history_when_not_logged_in": false, //未登录情况下是否不展示对话历史
|
36 |
-
"check_update": true, //是否启用检查更新
|
37 |
-
"default_model": "gpt-3.5-turbo", // 默认模型
|
38 |
-
"chat_name_method_index": 2, // 选择对话名称的方法。0: 使用日期时间命名;1: 使用第一条提问命名,2: 使用模型自动总结
|
39 |
-
"bot_avatar": "default", // 机器人头像,可填写本地或网络图片链接,或者"none"(不显示头像)
|
40 |
-
"user_avatar": "default", // 用户头像,可填写本地或网络图片链接,或者"none"(不显示头像)
|
41 |
-
|
42 |
-
//== API 用量 ==
|
43 |
-
"show_api_billing": false, //是否显示OpenAI API用量(启用需要填写sensitive_id)
|
44 |
-
"sensitive_id": "", // 你 OpenAI 账户的 Sensitive ID,用于查询 API 用量
|
45 |
-
"usage_limit": 120, // 该 OpenAI API Key 的当月限额,单位:美元,用于计算百分比和显示上限
|
46 |
-
"legacy_api_usage": false, // 是否使用旧版 API 用量查询接口(OpenAI现已关闭该接口,但是如果你在使用第三方 API,第三方可能仍然支持此接口)
|
47 |
-
|
48 |
-
//== 川虎助理设置 ==
|
49 |
-
"default_chuanhu_assistant_model": "gpt-4", //川虎助理使用的模型,可选gpt-3.5-turbo或者gpt-4等
|
50 |
-
"GOOGLE_CSE_ID": "", //谷歌搜索引擎ID,用于川虎助理Pro模式,获取方式请看 https://stackoverflow.com/questions/37083058/programmatically-searching-google-in-python-using-custom-search
|
51 |
-
"GOOGLE_API_KEY": "", //谷歌API Key,用于川虎助理Pro模式
|
52 |
-
"WOLFRAM_ALPHA_APPID": "", //Wolfram Alpha API Key,用于川虎助理Pro模式,获取方式请看 https://products.wolframalpha.com/api/
|
53 |
-
"SERPAPI_API_KEY": "", //SerpAPI API Key,用于川虎助理Pro模式,获取方式请看 https://serpapi.com/
|
54 |
-
|
55 |
-
//== 文档处理与显示 ==
|
56 |
-
"latex_option": "default", // LaTeX 公式渲染策略,可选"default", "strict", "all"或者"disabled"
|
57 |
-
"advance_docs": {
|
58 |
-
"pdf": {
|
59 |
-
"two_column": false, // 是否认为PDF是双栏的
|
60 |
-
"formula_ocr": true // 是否使用OCR识别PDF中的公式
|
61 |
-
}
|
62 |
-
},
|
63 |
-
|
64 |
-
//== 高级配置 ==
|
65 |
-
// 是否多个API Key轮换使用
|
66 |
-
"multi_api_key": false,
|
67 |
-
// "available_models": ["GPT3.5 Turbo", "GPT4 Turbo", "GPT4 Vision"], // 可用的模型列表,将覆盖默认的可用模型列���
|
68 |
-
// "extra_models": ["模型名称3", "模型名称4", ...], // 额外的模型,将添加到可用的模型列表之后
|
69 |
-
// "api_key_list": [
|
70 |
-
// "sk-xxxxxxxxxxxxxxxxxxxxxxxx1",
|
71 |
-
// "sk-xxxxxxxxxxxxxxxxxxxxxxxx2",
|
72 |
-
// "sk-xxxxxxxxxxxxxxxxxxxxxxxx3"
|
73 |
-
// ],
|
74 |
-
// 自定义OpenAI API Base
|
75 |
-
// "openai_api_base": "https://api.openai.com",
|
76 |
-
// 自定义使用代理(请替换代理URL)
|
77 |
-
// "https_proxy": "http://127.0.0.1:1079",
|
78 |
-
// "http_proxy": "http://127.0.0.1:1079",
|
79 |
-
// 自定义端口、自定义ip(请替换对应内容)
|
80 |
-
// "server_name": "0.0.0.0",
|
81 |
-
// "server_port": 7860,
|
82 |
-
// 如果要share到gradio,设置为true
|
83 |
-
// "share": false,
|
84 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
configs/ds_config_chatbot.json
DELETED
@@ -1,17 +0,0 @@
|
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
history/2023-06-14_15-05-04.json
DELETED
File without changes
|
llama_func.py
ADDED
@@ -0,0 +1,192 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import logging
|
3 |
+
|
4 |
+
from llama_index import GPTSimpleVectorIndex
|
5 |
+
from llama_index import download_loader
|
6 |
+
from llama_index import (
|
7 |
+
Document,
|
8 |
+
LLMPredictor,
|
9 |
+
PromptHelper,
|
10 |
+
QuestionAnswerPrompt,
|
11 |
+
RefinePrompt,
|
12 |
+
)
|
13 |
+
from langchain.llms import OpenAI
|
14 |
+
import colorama
|
15 |
+
|
16 |
+
|
17 |
+
from presets import *
|
18 |
+
from utils import *
|
19 |
+
|
20 |
+
|
21 |
+
def get_documents(file_src):
|
22 |
+
documents = []
|
23 |
+
index_name = ""
|
24 |
+
logging.debug("Loading documents...")
|
25 |
+
logging.debug(f"file_src: {file_src}")
|
26 |
+
for file in file_src:
|
27 |
+
logging.debug(f"file: {file.name}")
|
28 |
+
index_name += file.name
|
29 |
+
if os.path.splitext(file.name)[1] == ".pdf":
|
30 |
+
logging.debug("Loading PDF...")
|
31 |
+
CJKPDFReader = download_loader("CJKPDFReader")
|
32 |
+
loader = CJKPDFReader()
|
33 |
+
documents += loader.load_data(file=file.name)
|
34 |
+
elif os.path.splitext(file.name)[1] == ".docx":
|
35 |
+
logging.debug("Loading DOCX...")
|
36 |
+
DocxReader = download_loader("DocxReader")
|
37 |
+
loader = DocxReader()
|
38 |
+
documents += loader.load_data(file=file.name)
|
39 |
+
elif os.path.splitext(file.name)[1] == ".epub":
|
40 |
+
logging.debug("Loading EPUB...")
|
41 |
+
EpubReader = download_loader("EpubReader")
|
42 |
+
loader = EpubReader()
|
43 |
+
documents += loader.load_data(file=file.name)
|
44 |
+
else:
|
45 |
+
logging.debug("Loading text file...")
|
46 |
+
with open(file.name, "r", encoding="utf-8") as f:
|
47 |
+
text = add_space(f.read())
|
48 |
+
documents += [Document(text)]
|
49 |
+
index_name = sha1sum(index_name)
|
50 |
+
return documents, index_name
|
51 |
+
|
52 |
+
|
53 |
+
def construct_index(
|
54 |
+
api_key,
|
55 |
+
file_src,
|
56 |
+
max_input_size=4096,
|
57 |
+
num_outputs=1,
|
58 |
+
max_chunk_overlap=20,
|
59 |
+
chunk_size_limit=600,
|
60 |
+
embedding_limit=None,
|
61 |
+
separator=" ",
|
62 |
+
num_children=10,
|
63 |
+
max_keywords_per_chunk=10,
|
64 |
+
):
|
65 |
+
os.environ["OPENAI_API_KEY"] = api_key
|
66 |
+
chunk_size_limit = None if chunk_size_limit == 0 else chunk_size_limit
|
67 |
+
embedding_limit = None if embedding_limit == 0 else embedding_limit
|
68 |
+
separator = " " if separator == "" else separator
|
69 |
+
|
70 |
+
llm_predictor = LLMPredictor(
|
71 |
+
llm=OpenAI(model_name="gpt-3.5-turbo-0301", openai_api_key=api_key)
|
72 |
+
)
|
73 |
+
prompt_helper = PromptHelper(
|
74 |
+
max_input_size,
|
75 |
+
num_outputs,
|
76 |
+
max_chunk_overlap,
|
77 |
+
embedding_limit,
|
78 |
+
chunk_size_limit,
|
79 |
+
separator=separator,
|
80 |
+
)
|
81 |
+
documents, index_name = get_documents(file_src)
|
82 |
+
if os.path.exists(f"./index/{index_name}.json"):
|
83 |
+
logging.info("找到了缓存的索引文件,加载中……")
|
84 |
+
return GPTSimpleVectorIndex.load_from_disk(f"./index/{index_name}.json")
|
85 |
+
else:
|
86 |
+
try:
|
87 |
+
logging.debug("构建索引中……")
|
88 |
+
index = GPTSimpleVectorIndex(
|
89 |
+
documents, llm_predictor=llm_predictor, prompt_helper=prompt_helper
|
90 |
+
)
|
91 |
+
os.makedirs("./index", exist_ok=True)
|
92 |
+
index.save_to_disk(f"./index/{index_name}.json")
|
93 |
+
return index
|
94 |
+
except Exception as e:
|
95 |
+
print(e)
|
96 |
+
return None
|
97 |
+
|
98 |
+
|
99 |
+
def chat_ai(
|
100 |
+
api_key,
|
101 |
+
index,
|
102 |
+
question,
|
103 |
+
context,
|
104 |
+
chatbot,
|
105 |
+
):
|
106 |
+
os.environ["OPENAI_API_KEY"] = api_key
|
107 |
+
|
108 |
+
logging.info(f"Question: {question}")
|
109 |
+
|
110 |
+
response, chatbot_display, status_text = ask_ai(
|
111 |
+
api_key,
|
112 |
+
index,
|
113 |
+
question,
|
114 |
+
replace_today(PROMPT_TEMPLATE),
|
115 |
+
REFINE_TEMPLATE,
|
116 |
+
SIM_K,
|
117 |
+
INDEX_QUERY_TEMPRATURE,
|
118 |
+
context,
|
119 |
+
)
|
120 |
+
if response is None:
|
121 |
+
status_text = "查询失败,请换个问法试试"
|
122 |
+
return context, chatbot
|
123 |
+
response = response
|
124 |
+
|
125 |
+
context.append({"role": "user", "content": question})
|
126 |
+
context.append({"role": "assistant", "content": response})
|
127 |
+
chatbot.append((question, chatbot_display))
|
128 |
+
|
129 |
+
os.environ["OPENAI_API_KEY"] = ""
|
130 |
+
return context, chatbot, status_text
|
131 |
+
|
132 |
+
|
133 |
+
def ask_ai(
|
134 |
+
api_key,
|
135 |
+
index,
|
136 |
+
question,
|
137 |
+
prompt_tmpl,
|
138 |
+
refine_tmpl,
|
139 |
+
sim_k=1,
|
140 |
+
temprature=0,
|
141 |
+
prefix_messages=[],
|
142 |
+
):
|
143 |
+
os.environ["OPENAI_API_KEY"] = api_key
|
144 |
+
|
145 |
+
logging.debug("Index file found")
|
146 |
+
logging.debug("Querying index...")
|
147 |
+
llm_predictor = LLMPredictor(
|
148 |
+
llm=OpenAI(
|
149 |
+
temperature=temprature,
|
150 |
+
model_name="gpt-3.5-turbo-0301",
|
151 |
+
prefix_messages=prefix_messages,
|
152 |
+
)
|
153 |
+
)
|
154 |
+
|
155 |
+
response = None # Initialize response variable to avoid UnboundLocalError
|
156 |
+
qa_prompt = QuestionAnswerPrompt(prompt_tmpl)
|
157 |
+
rf_prompt = RefinePrompt(refine_tmpl)
|
158 |
+
response = index.query(
|
159 |
+
question,
|
160 |
+
llm_predictor=llm_predictor,
|
161 |
+
similarity_top_k=sim_k,
|
162 |
+
text_qa_template=qa_prompt,
|
163 |
+
refine_template=rf_prompt,
|
164 |
+
response_mode="compact",
|
165 |
+
)
|
166 |
+
|
167 |
+
if response is not None:
|
168 |
+
logging.info(f"Response: {response}")
|
169 |
+
ret_text = response.response
|
170 |
+
nodes = []
|
171 |
+
for index, node in enumerate(response.source_nodes):
|
172 |
+
brief = node.source_text[:25].replace("\n", "")
|
173 |
+
nodes.append(
|
174 |
+
f"<details><summary>[{index+1}]\t{brief}...</summary><p>{node.source_text}</p></details>"
|
175 |
+
)
|
176 |
+
new_response = ret_text + "\n----------\n" + "\n\n".join(nodes)
|
177 |
+
logging.info(
|
178 |
+
f"Response: {colorama.Fore.BLUE}{ret_text}{colorama.Style.RESET_ALL}"
|
179 |
+
)
|
180 |
+
os.environ["OPENAI_API_KEY"] = ""
|
181 |
+
return ret_text, new_response, f"查询消耗了{llm_predictor.last_token_usage} tokens"
|
182 |
+
else:
|
183 |
+
logging.warning("No response found, returning None")
|
184 |
+
os.environ["OPENAI_API_KEY"] = ""
|
185 |
+
return None
|
186 |
+
|
187 |
+
|
188 |
+
def add_space(text):
|
189 |
+
punctuations = {",": ", ", "。": "。 ", "?": "? ", "!": "! ", ":": ": ", ";": "; "}
|
190 |
+
for cn_punc, en_punc in punctuations.items():
|
191 |
+
text = text.replace(cn_punc, en_punc)
|
192 |
+
return text
|
locale/en_US.json
DELETED
@@ -1,141 +0,0 @@
|
|
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
DELETED
@@ -1,138 +0,0 @@
|
|
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
DELETED
@@ -1,141 +0,0 @@
|
|
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 |
-
",本次对话累计消耗了 ": ", 今の会話で消費合計 ",
|
130 |
-
"💾 保存对话": "💾 会話を保存",
|
131 |
-
"📝 导出为 Markdown": "📝 Markdownにエクスポート",
|
132 |
-
"🔄 切换API地址": "🔄 APIアドレスを切り替え",
|
133 |
-
"🔄 刷新": "🔄 更新",
|
134 |
-
"🔄 检查更新...": "🔄 アップデートをチェック...",
|
135 |
-
"🔄 设置代理地址": "🔄 プロキシアドレスを設定",
|
136 |
-
"🔄 重新生成": "🔄 再生成",
|
137 |
-
"🔙 恢复默认网络设置": "🔙 ネットワーク設定のリセット",
|
138 |
-
"🗑️ 删除最新对话": "🗑️ 最新の会話削除",
|
139 |
-
"🗑️ 删除最旧对话": "🗑️ 最古の会話削除",
|
140 |
-
"🧹 新的对话": "🧹 新しい会話"
|
141 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
locale/ko_KR.json
DELETED
@@ -1,141 +0,0 @@
|
|
1 |
-
{
|
2 |
-
" 吗?": " 을(를) 삭제하시겠습니까?",
|
3 |
-
"# ⚠️ 务必谨慎更改 ⚠️": "# ⚠️ 주의: 변경시 주의하세요. ⚠️",
|
4 |
-
"**发送消息** 或 **提交key** 以显示额度": "**메세지를 전송** 하거나 **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 计数: ": "토큰 수: ",
|
14 |
-
"☹️发生了错误:": "☹️에러: ",
|
15 |
-
"⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "⚠️ API-Key의 안전을 보장하기 위해 네트워크 설정을 `config.json` 구성 파일에서 수정해주세요.",
|
16 |
-
"。你仍然可以使用聊天功能。": ". 채팅 기능을 계속 사용할 수 있습니다.",
|
17 |
-
"上传": "업로드",
|
18 |
-
"上传了": "업로드되었습니다.",
|
19 |
-
"上传到 OpenAI 后自动填充": "OpenAI로 업로드한 후 자동으로 채워집니다",
|
20 |
-
"上传到OpenAI": "OpenAI로 업로드",
|
21 |
-
"上传文件": "파일 업로드",
|
22 |
-
"仅供查看": "읽기 전용",
|
23 |
-
"从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模板": "프롬프트 템플릿 불러오기",
|
40 |
-
"单轮对话": "단일 대화",
|
41 |
-
"历史记录(JSON)": "기록 파일 (JSON)",
|
42 |
-
"参数": "파라미터들",
|
43 |
-
"双栏pdf": "2-column pdf",
|
44 |
-
"取消": "취소",
|
45 |
-
"取消所有任务": "모든 작업 취소",
|
46 |
-
"可选,用于区分不同的模型": "선택 사항, 다른 모델을 구분하는 데 사용",
|
47 |
-
"启用的工具:": "활성화된 도구: ",
|
48 |
-
"在工具箱中管理知识库文件": "지식 라이브러리 파일을 도구 상자에서 관리",
|
49 |
-
"在线搜索": "온라인 검색",
|
50 |
-
"在这里输入": "여기에 입력하세요",
|
51 |
-
"在这里输入System Prompt...": "여기에 시스템 프롬프트를 입력하세요...",
|
52 |
-
"多账号模式已开启,无需输入key,可直接开始对话": "다중 계정 모드가 활성화되어 있으므로 키를 입력할 필요가 없이 바로 대화를 시작할 수 있습니다",
|
53 |
-
"好": "예",
|
54 |
-
"实时传输回答": "실시간 전송",
|
55 |
-
"对话": "대화",
|
56 |
-
"对话历史": "대화 내역",
|
57 |
-
"对话历史记录": "대화 기록",
|
58 |
-
"对话命名方式": "대화 이름 설정",
|
59 |
-
"导出为 Markdown": "마크다운으로 내보내기",
|
60 |
-
"川虎Chat": "Chuanhu Chat",
|
61 |
-
"川虎Chat 🚀": "Chuanhu 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 |
-
"模型设置为了:": "설정된 모델: ",
|
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최신 코드 다운로드: [GitHub](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
|
98 |
-
"知识库": "지식 라이브러리",
|
99 |
-
"知识库文件": "지식 라이브러리 파일",
|
100 |
-
"第一条提问": "첫 번째 질문",
|
101 |
-
"索引构建完成": "인덱스 구축이 완료되었습니다.",
|
102 |
-
"网络": "네트워크",
|
103 |
-
"获取API使用情况失败:": "API 사용량 가져오기 실패:",
|
104 |
-
"获取IP地理位置失败。原因:": "다음과 같은 이유로 IP 위치를 가져올 수 없습니다. 이유: ",
|
105 |
-
"获取对话时发生错误,请查看后台日志": "대화를 가져오는 중 에러가 발생했습니다. 백그라운드 로그를 확인하세요",
|
106 |
-
"训练": "훈련",
|
107 |
-
"训练状态": "훈련 상태",
|
108 |
-
"训练轮数(Epochs)": "훈련 라운드(Epochs)",
|
109 |
-
"设置": "설정",
|
110 |
-
"设置保存文件名": "저장 파일명 설정",
|
111 |
-
"设置文件名: 默认为.json,可选为.md": "파일 이름 설정: 기본값: .json, 선택: .md",
|
112 |
-
"识别公式": "formula OCR",
|
113 |
-
"详情": "상세",
|
114 |
-
"请查看 config_example.json,配置 Azure OpenAI": "Azure OpenAI 설정을 확인하세요",
|
115 |
-
"请检查网络连接,或者API-Key是否有效。": "네트워크 연결 또는 API키가 유효한지 확인하세요",
|
116 |
-
"请输入对话内容。": "대화 내용을 입력하세요.",
|
117 |
-
"请输入有效的文件名,不要包含以下特殊字符:": "유효한 파일 이름을 입력하세요. 다음 특수 문자는 포함하지 마세요: ",
|
118 |
-
"读取超时,无法获取对话。": "읽기 시간 초과, 대화를 가져올 수 없습니다.",
|
119 |
-
"账单信息不适用": "청구 정보를 가져올 수 없습니다",
|
120 |
-
"连接超时,无法获取对话。": "연결 시간 초과, 대화를 가져올 수 없습니다.",
|
121 |
-
"选择LoRA模型": "LoRA 모델 선택",
|
122 |
-
"选择Prompt模板集合文件": "프롬프트 콜렉션 파일 선택",
|
123 |
-
"选择回复语言(针对搜索&索引功能)": "답장 언어 선택 (검색 & 인덱스용)",
|
124 |
-
"选择数据集": "데이터셋 선택",
|
125 |
-
"选择模型": "모델 선택",
|
126 |
-
"重命名该对话": "대화 이름 변경",
|
127 |
-
"重新生成": "재생성",
|
128 |
-
"高级": "고급",
|
129 |
-
",本次对话累计消耗了 ": ",이 대화의 전체 비용은 ",
|
130 |
-
"💾 保存对话": "💾 대화 저장",
|
131 |
-
"📝 导出为 Markdown": "📝 마크다운으로 내보내기",
|
132 |
-
"🔄 切换API地址": "🔄 API 주소 변경",
|
133 |
-
"🔄 刷新": "🔄 새로고침",
|
134 |
-
"🔄 检查更新...": "🔄 업���이트 확인...",
|
135 |
-
"🔄 设置代理地址": "🔄 프록시 주소 설정",
|
136 |
-
"🔄 重新生成": "🔄 재생성",
|
137 |
-
"🔙 恢复默认网络设置": "🔙 네트워크 설정 초기화",
|
138 |
-
"🗑️ 删除最新对话": "🗑️ 최신 대화 삭제",
|
139 |
-
"🗑️ 删除最旧对话": "🗑️ 가장 오래된 대화 삭제",
|
140 |
-
"🧹 新的对话": "🧹 새로운 대화"
|
141 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
locale/ru_RU.json
DELETED
@@ -1,141 +0,0 @@
|
|
1 |
-
{
|
2 |
-
" 吗?": " ?",
|
3 |
-
"# ⚠️ 务必谨慎更改 ⚠️": "# ⚠️ ВНИМАНИЕ: ИЗМЕНЯЙТЕ ОСТОРОЖНО ⚠️",
|
4 |
-
"**发送消息** 或 **提交key** 以显示额度": "**Отправить сообщение** или **отправить ключ** для отображения лимита",
|
5 |
-
"**本月使用金额** ": "**Использовано средств в этом месяце**",
|
6 |
-
"**获取API使用情况失败**": "**Не удалось получить информацию об использовании API**",
|
7 |
-
"**获取API使用情况失败**,sensitive_id错误或已过期": "**Не удалось получить информацию об использовании API**, ошибка sensitive_id или истек срок действия",
|
8 |
-
"**获取API使用情况失败**,需在填写`config.json`中正确填写sensitive_id": "**Не удалось получить информацию об использовании API**, необходимо правильно заполнить sensitive_id в `config.json`",
|
9 |
-
"API key为空,请检查是否输入正确。": "Пустой API-Key, пожалуйста, проверьте правильность ввода.",
|
10 |
-
"API密钥更改为了": "Ключ API изменен на",
|
11 |
-
"JSON解析错误,收到的内容: ": "Ошибка анализа JSON, полученный контент:",
|
12 |
-
"SSL错误,无法获取对话。": "Ошибка SSL, не удалось получить диалог.",
|
13 |
-
"Token 计数: ": "Использованно токенов: ",
|
14 |
-
"☹️发生了错误:": "☹️ Произошла ошибка:",
|
15 |
-
"⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "⚠️ Для обеспечения безопасности API-Key, измените настройки сети в файле конфигурации `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)": "У вас нет доступа к GPT4, [подробнее](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": "Двухколоночный PDF",
|
44 |
-
"取消": "Отмена",
|
45 |
-
"取消所有任务": "Отменить все задачи",
|
46 |
-
"可选,用于区分不同的模型": "Необязательно, используется для различения разных моделей",
|
47 |
-
"启用的工具:": "Включенные инструменты:",
|
48 |
-
"在工具箱中管理知识库文件": "Управление файлами базы знаний в инструментах",
|
49 |
-
"在线搜索": "Онлайн-поиск",
|
50 |
-
"在这里输入": "Введите здесь",
|
51 |
-
"在这里输入System Prompt...": "Введите здесь системное подсказку...",
|
52 |
-
"多账号模式已开启,无需输入key,可直接开始对话": "Режим множественных аккаунтов включен, не требуется ввод ключа, можно сразу начать диалог",
|
53 |
-
"好": "Хорошо",
|
54 |
-
"实时传输回答": "Передача ответа в реальном времени",
|
55 |
-
"对话": "Диалог",
|
56 |
-
"对话历史": "Диалоговая история",
|
57 |
-
"对话历史记录": "История диалога",
|
58 |
-
"对话命名方式": "Способ названия диалога",
|
59 |
-
"导出为 Markdown": "Экспортировать в Markdown",
|
60 |
-
"川虎Chat": "Chuanhu Чат",
|
61 |
-
"川虎Chat 🚀": "Chuanhu Чат 🚀",
|
62 |
-
"工具箱": "Инструменты",
|
63 |
-
"已经被删除啦": "Уже удалено.",
|
64 |
-
"开始实时传输回答……": "Начните трансляцию ответов в режиме реального времени...",
|
65 |
-
"开始训练": "Начать обучение",
|
66 |
-
"微调": "Своя модель",
|
67 |
-
"总结": "Подведение итога",
|
68 |
-
"总结完成": "Готово",
|
69 |
-
"您使用的就是最新版!": "Вы используете последнюю версию!",
|
70 |
-
"您的IP区域:": "Ваша IP-зона:",
|
71 |
-
"您的IP区域:未知。": "Ваша IP-зона: неизвестно.",
|
72 |
-
"拓展": "Расширенные настройки",
|
73 |
-
"搜索(支持正则)...": "Поиск (поддержка регулярности)...",
|
74 |
-
"数据集预览": "Предпросмотр набора данных",
|
75 |
-
"文件ID": "Идентификатор файла",
|
76 |
-
"新对话 ": "Новый диалог ",
|
77 |
-
"新建对话保留Prompt": "Создать диалог с сохранением подсказки",
|
78 |
-
"暂时未知": "Временно неизвестно",
|
79 |
-
"更新": "Обновить",
|
80 |
-
"更新失败,请尝试[手动更新](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 |
-
"模型": "Модель",
|
88 |
-
"模型名称后缀": "Суффикс имени модели",
|
89 |
-
"模型自动总结(消耗tokens)": "Автоматическое подведение итогов модели (потребление токенов)",
|
90 |
-
"模型设置为了:": "Модель настроена на:",
|
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) 下载最新版脚本": "Разработано [土川虎虎虎](https://space.bilibili.com/29125536), [明昭MZhao](https://space.bilibili.com/24807452) и [Keldos](https://github.com/Keldos-Li).<br />посетите [GitHub Project](https://github.com/GaiZhenbiao/ChuanhuChatGPT) чата Chuanhu, чтобы загрузить последнюю версию скрипта",
|
98 |
-
"知识库": "База знаний",
|
99 |
-
"知识库文件": "Файл базы знаний",
|
100 |
-
"第一条提问": "Первый вопрос",
|
101 |
-
"索引构建完成": "Индексирование завершено.",
|
102 |
-
"网络": "Параметры сети",
|
103 |
-
"获取API使用情况失败:": "Не удалось получитьAPIинформацию об использовании:",
|
104 |
-
"获取IP地理位置失��。原因:": "Не удалось получить географическое положение IP. Причина:",
|
105 |
-
"获取对话时发生错误,请查看后台日志": "Возникла ошибка при получении диалога, пожалуйста, проверьте журналы",
|
106 |
-
"训练": "Обучение",
|
107 |
-
"训练状态": "Статус обучения",
|
108 |
-
"训练轮数(Epochs)": "Количество эпох обучения",
|
109 |
-
"设置": "Настройки",
|
110 |
-
"设置保存文件名": "Установить имя сохраняемого файла",
|
111 |
-
"设置文件名: 默认为.json,可选为.md": "Установить имя файла: по умолчанию .json, можно выбрать .md",
|
112 |
-
"识别公式": "Распознавание формул",
|
113 |
-
"详情": "Подробности",
|
114 |
-
"请查看 config_example.json,配置 Azure OpenAI": "Пожалуйста, просмотрите config_example.json для настройки Azure OpenAI",
|
115 |
-
"请检查网络连接,或者API-Key是否有效。": "Проверьте подключение к сети или действительность API-Key.",
|
116 |
-
"请输入对话内容。": "Пожалуйста, введите содержание диалога.",
|
117 |
-
"请输入有效的文件名,不要包含以下特殊字符:": "Введите действительное имя файла, не содержащее следующих специальных символов: ",
|
118 |
-
"读取超时,无法获取对话。": "Тайм-аут чтения, не удалось получить диалог.",
|
119 |
-
"账单信息不适用": "Информация о счете не применима",
|
120 |
-
"连接超时,无法获取对话。": "Тайм-аут подключения, не удалось получить диалог.",
|
121 |
-
"选择LoRA模型": "Выберите модель LoRA",
|
122 |
-
"选择Prompt模板集合文件": "Выберите файл с набором шаблонов Prompt",
|
123 |
-
"选择回复语言(针对搜索&索引功能)": "Выберите язык ответа (для функций поиска и индексации)",
|
124 |
-
"选择数据集": "Выберите набор данных",
|
125 |
-
"选择模型": "Выберите модель",
|
126 |
-
"重命名该对话": "Переименовать этот диалог",
|
127 |
-
"重新生成": "Пересоздать",
|
128 |
-
"高级": "Расширенные настройки",
|
129 |
-
",本次对话累计消耗了 ": ", Общая стоимость этого диалога составляет ",
|
130 |
-
"💾 保存对话": "💾 Сохранить диалог",
|
131 |
-
"📝 导出为 Markdown": "📝 Экспортировать в Markdown",
|
132 |
-
"🔄 切换API地址": "🔄 Переключить адрес API",
|
133 |
-
"🔄 刷新": "🔄 Обновить",
|
134 |
-
"🔄 检查更新...": "🔄 Проверить обновления...",
|
135 |
-
"🔄 设置代理地址": "🔄 Установить адрес прокси",
|
136 |
-
"🔄 重新生成": "🔄 Пересоздать",
|
137 |
-
"🔙 恢复默认网络设置": "🔙 Восстановить настройки сети по умолчанию",
|
138 |
-
"🗑️ 删除最新对话": "🗑️ Удалить последний диалог",
|
139 |
-
"🗑️ 删除最旧对话": "🗑️ Удалить старейший диалог",
|
140 |
-
"🧹 新的对话": "🧹 Новый диалог"
|
141 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
locale/sv-SE.json
DELETED
@@ -1,87 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"未命名对话历史记录": "Onämnd Dialoghistorik",
|
3 |
-
"在这里输入": "Skriv in här",
|
4 |
-
"🧹 新的对话": "🧹 Ny Dialog",
|
5 |
-
"🔄 重新生成": "🔄 Regenerera",
|
6 |
-
"🗑️ 删除最旧对话": "🗑️ Ta bort äldsta dialogen",
|
7 |
-
"🗑️ 删除最新对话": "🗑️ Ta bort senaste dialogen",
|
8 |
-
"模型": "Modell",
|
9 |
-
"多账号模式已开启,无需输入key,可直接开始对话": "Flerkontoläge är aktiverat, ingen nyckel behövs, du kan starta dialogen direkt",
|
10 |
-
"**发送消息** 或 **提交key** 以显示额度": "**Skicka meddelande** eller **Skicka in nyckel** för att visa kredit",
|
11 |
-
"选择模型": "Välj Modell",
|
12 |
-
"选择LoRA模型": "Välj LoRA Modell",
|
13 |
-
"实时传输回答": "Strömmande utdata",
|
14 |
-
"单轮对话": "Enkel dialog",
|
15 |
-
"使用在线搜索": "Använd online-sökning",
|
16 |
-
"选择回复语言(针对搜索&索引功能)": "Välj svarspråk (för sök- och indexfunktion)",
|
17 |
-
"上传索引文件": "Ladda upp",
|
18 |
-
"双栏pdf": "Två-kolumns pdf",
|
19 |
-
"识别公式": "Formel OCR",
|
20 |
-
"在这里输入System Prompt...": "Skriv in System Prompt här...",
|
21 |
-
"加载Prompt模板": "Ladda Prompt-mall",
|
22 |
-
"选择Prompt模板集合文件": "Välj Prompt-mall Samlingsfil",
|
23 |
-
"🔄 刷新": "🔄 Uppdatera",
|
24 |
-
"从Prompt模板中加载": "Ladda från Prompt-mall",
|
25 |
-
"保存/加载": "Spara/Ladda",
|
26 |
-
"保存/加载对话历史记录": "Spara/Ladda Dialoghistorik",
|
27 |
-
"从列表中加载对话": "Ladda dialog från lista",
|
28 |
-
"设置文件名: 默认为.json,可选为.md": "Ställ in filnamn: standard är .json, valfritt är .md",
|
29 |
-
"设置保存文件名": "Ställ in sparfilnamn",
|
30 |
-
"对话历史记录": "Dialoghistorik",
|
31 |
-
"💾 保存对话": "💾 Spara Dialog",
|
32 |
-
"📝 导出为Markdown": "📝 Exportera som Markdown",
|
33 |
-
"默认保存于history文件夹": "Sparas som standard i mappen history",
|
34 |
-
"高级": "Avancerat",
|
35 |
-
"# ⚠️ 务必谨慎更改 ⚠️": "# ⚠️ Var försiktig med ändringar. ⚠️",
|
36 |
-
"参数": "Parametrar",
|
37 |
-
"停止符,用英文逗号隔开...": "Skriv in stopptecken här, separerade med kommatecken...",
|
38 |
-
"用于定位滥用行为": "Används för att lokalisera missbruk",
|
39 |
-
"用户名": "Användarnamn",
|
40 |
-
"在这里输入API-Host...": "Skriv in API-Host här...",
|
41 |
-
"🔄 切换API地址": "🔄 Byt API-adress",
|
42 |
-
"未设置代理...": "Inte inställd proxy...",
|
43 |
-
"代理地址": "Proxyadress",
|
44 |
-
"🔄 设置代理地址": "🔄 Ställ in Proxyadress",
|
45 |
-
"🔙 恢复网络默认设置": "🔙 Återställ Nätverksinställningar",
|
46 |
-
"🔄 检查更新...": "🔄 Sök efter uppdateringar...",
|
47 |
-
"取消": "Avbryt",
|
48 |
-
"更新": "Uppdatera",
|
49 |
-
"详情": "Detaljer",
|
50 |
-
"好": "OK",
|
51 |
-
"更新成功,请重启本程序": "Uppdaterat framgångsrikt, starta om programmet",
|
52 |
-
"更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)": "Uppdateringen misslyckades, prova att [uppdatera manuellt](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)",
|
53 |
-
"川虎Chat 🚀": "Chuanhu Chat 🚀",
|
54 |
-
"开始实时传输回答……": "Börjar strömma utdata...",
|
55 |
-
"Token 计数: ": "Tokenräkning: ",
|
56 |
-
",本次对话累计消耗了 ": ", Total kostnad för denna dialog är ",
|
57 |
-
"**获取API使用情况失败**": "**Misslyckades med att hämta API-användning**",
|
58 |
-
"**获取API使用情况失败**,需在填写`config.json`中正确填写sensitive_id": "**Misslyckades med att hämta API-användning**, korrekt sensitive_id behövs i `config.json`",
|
59 |
-
"**获取API使用情况失败**,sensitive_id错误或已过期": "**Misslyckades med att hämta API-användning**, felaktig eller utgången sensitive_id",
|
60 |
-
"**本月使用金额** ": "**Månadens användning** ",
|
61 |
-
"本月使用金额": "Månadens användning",
|
62 |
-
"获取API使用情况失败:": "Misslyckades med att hämta API-användning:",
|
63 |
-
"API密钥更改为了": "API-nyckeln har ändrats till",
|
64 |
-
"JSON解析错误,收到的内容: ": "JSON-tolkningsfel, mottaget innehåll: ",
|
65 |
-
"模型设置为了:": "Modellen är inställd på: ",
|
66 |
-
"☹️发生了错误:": "☹️Fel: ",
|
67 |
-
"获取对话时发生错误,请查看后台日志": "Ett fel uppstod när dialogen hämtades, kontrollera bakgrundsloggen",
|
68 |
-
"请检查网络连接,或者API-Key是否有效。": "Kontrollera nätverksanslutningen eller om API-nyckeln är giltig.",
|
69 |
-
"连接超时,无法获取对话。": "Anslutningen tog för lång tid, kunde inte hämta dialogen.",
|
70 |
-
"读取超时,无法获取对话。": "Läsningen tog för lång tid, kunde inte hämta dialogen.",
|
71 |
-
"代理错误,无法获取对话。": "Proxyfel, kunde inte hämta dialogen.",
|
72 |
-
"SSL错误,无法获取对话。": "SSL-fel, kunde inte hämta dialogen.",
|
73 |
-
"API key为空,请检查是否输入正确。": "API-nyckeln är tom, kontrollera om den är korrekt inmatad.",
|
74 |
-
"请输入对话内容。": "Ange dialoginnehåll.",
|
75 |
-
"账单信息不适用": "Faktureringsinformation är inte tillämplig",
|
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) 下载最新版脚本": "Utvecklad av Bilibili [土川虎虎虎](https://space.bilibili.com/29125536), [明昭MZhao](https://space.bilibili.com/24807452) och [Keldos](https://github.com/Keldos-Li)\n\nLadda ner senaste koden från [GitHub](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
|
77 |
-
"切换亮暗色主题": "Byt ljus/mörk tema",
|
78 |
-
"您的IP区域:未知。": "Din IP-region: Okänd.",
|
79 |
-
"获取IP地理位置失败。原因:": "Misslyckades med att hämta IP-plats. Orsak: ",
|
80 |
-
"。你仍然可以使用聊天功能。": ". Du kan fortfarande använda chattfunktionen.",
|
81 |
-
"您的IP区域:": "Din IP-region: ",
|
82 |
-
"总结": "Sammanfatta",
|
83 |
-
"生成内容总结中……": "Genererar innehållssammanfattning...",
|
84 |
-
"由于下面的原因,Google 拒绝返回 PaLM 的回答:\n\n": "På grund av följande skäl vägrar Google att ge ett svar till PaLM: \n\n",
|
85 |
-
"---\n⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "---\n⚠️ För att säkerställa säkerheten för API-nyckeln, vänligen ändra nätverksinställningarna i konfigurationsfilen `config.json`.",
|
86 |
-
"网络参数": "nätverksparametrar"
|
87 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
locale/sv_SE.json
DELETED
@@ -1,141 +0,0 @@
|
|
1 |
-
{
|
2 |
-
" 吗?": " ?",
|
3 |
-
"# ⚠️ 务必谨慎更改 ⚠️": "# ⚠️ Var försiktig med ändringar. ⚠️",
|
4 |
-
"**发送消息** 或 **提交key** 以显示额度": "**Skicka meddelande** eller **Skicka in nyckel** för att visa kredit",
|
5 |
-
"**本月使用金额** ": "**Månadens användning** ",
|
6 |
-
"**获取API使用情况失败**": "**Misslyckades med att hämta API-användning**",
|
7 |
-
"**获取API使用情况失败**,sensitive_id错误或已过期": "**Misslyckades med att hämta API-användning**, felaktig eller utgången sensitive_id",
|
8 |
-
"**获取API使用情况失败**,需在填写`config.json`中正确填写sensitive_id": "**Misslyckades med att hämta API-användning**, korrekt sensitive_id behövs i `config.json`",
|
9 |
-
"API key为空,请检查是否输入正确。": "API-nyckeln är tom, kontrollera om den är korrekt inmatad.",
|
10 |
-
"API密钥更改为了": "API-nyckeln har ändrats till",
|
11 |
-
"JSON解析错误,收到的内容: ": "JSON-tolkningsfel, mottaget innehåll: ",
|
12 |
-
"SSL错误,无法获取对话。": "SSL-fel, kunde inte hämta dialogen.",
|
13 |
-
"Token 计数: ": "Tokenräkning: ",
|
14 |
-
"☹️发生了错误:": "☹️Fel: ",
|
15 |
-
"⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "⚠️ För att säkerställa säkerheten för API-nyckeln, vänligen ändra nätverksinställningarna i konfigurationsfilen `config.json`.",
|
16 |
-
"。你仍然可以使用聊天功能。": ". Du kan fortfarande använda chattfunktionen.",
|
17 |
-
"上传": "Ladda upp",
|
18 |
-
"上传了": "Uppladdad",
|
19 |
-
"上传到 OpenAI 后自动填充": "Automatiskt ifylld efter uppladdning till OpenAI",
|
20 |
-
"上传到OpenAI": "Ladda upp till OpenAI",
|
21 |
-
"上传文件": "ladda upp fil",
|
22 |
-
"仅供查看": "Endast för visning",
|
23 |
-
"从Prompt模板中加载": "Ladda från Prompt-mall",
|
24 |
-
"从列表中加载对话": "Ladda dialog från lista",
|
25 |
-
"代理地址": "Proxyadress",
|
26 |
-
"代理错误,无法获取对话。": "Proxyfel, kunde inte hämta dialogen.",
|
27 |
-
"你没有权限访问 GPT4,[进一步了解](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/843)": "Du har inte behörighet att komma åt GPT-4, [läs mer](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/843)",
|
28 |
-
"你没有选择任何对话历史": "Du har inte valt någon konversationshistorik.",
|
29 |
-
"你真的要删除 ": "Är du säker på att du vill ta bort ",
|
30 |
-
"使用在线搜索": "Använd online-sökning",
|
31 |
-
"停止符,用英文逗号隔开...": "Skriv in stopptecken här, separerade med kommatecken...",
|
32 |
-
"关于": "om",
|
33 |
-
"准备数据集": "Förbered dataset",
|
34 |
-
"切换亮暗色主题": "Byt ljus/mörk tema",
|
35 |
-
"删除对话历史成功": "Raderade konversationens historik.",
|
36 |
-
"删除这轮问答": "Ta bort denna omgång av Q&A",
|
37 |
-
"刷新状态": "Uppdatera 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)": "Återstående kvot är otillräcklig, [läs mer](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/%C3%84mnen)",
|
39 |
-
"加载Prompt模板": "Ladda Prompt-mall",
|
40 |
-
"单轮对话": "Enkel dialog",
|
41 |
-
"历史记录(JSON)": "Historikfil (JSON)",
|
42 |
-
"参数": "Parametrar",
|
43 |
-
"双栏pdf": "Två-kolumns pdf",
|
44 |
-
"取消": "Avbryt",
|
45 |
-
"取消所有任务": "Avbryt alla uppgifter",
|
46 |
-
"可选,用于区分不同的模型": "Valfritt, används för att särskilja olika modeller",
|
47 |
-
"启用的工具:": "Aktiverade verktyg: ",
|
48 |
-
"在工具箱中管理知识库文件": "hantera kunskapsbankfiler i verktygslådan",
|
49 |
-
"在线搜索": "onlinesökning",
|
50 |
-
"在这里输入": "Skriv in här",
|
51 |
-
"在这里输入System Prompt...": "Skriv in System Prompt här...",
|
52 |
-
"多账号模式已开启,无需输入key,可直接开始对话": "Flerkontoläge är aktiverat, ingen nyckel behövs, du kan starta dialogen direkt",
|
53 |
-
"好": "OK",
|
54 |
-
"实时传输回答": "Strömmande utdata",
|
55 |
-
"对话": "konversation",
|
56 |
-
"对话历史": "Dialoghistorik",
|
57 |
-
"对话历史记录": "Dialoghistorik",
|
58 |
-
"对话命名方式": "Dialognamn",
|
59 |
-
"导出为 Markdown": "Exportera som Markdown",
|
60 |
-
"川虎Chat": "Chuanhu Chat",
|
61 |
-
"川虎Chat 🚀": "Chuanhu Chat 🚀",
|
62 |
-
"工具箱": "verktygslåda",
|
63 |
-
"已经被删除啦": "Har raderats.",
|
64 |
-
"开始实时传输回答……": "Börjar strömma utdata...",
|
65 |
-
"开始训练": "Börja träning",
|
66 |
-
"微调": "Finjustering",
|
67 |
-
"总结": "Sammanfatta",
|
68 |
-
"总结完成": "Slutfört sammanfattningen.",
|
69 |
-
"您使用的就是最新版!": "Du använder den senaste versionen!",
|
70 |
-
"您的IP区域:": "Din IP-region: ",
|
71 |
-
"您的IP区域:未知。": "Din IP-region: Okänd.",
|
72 |
-
"拓展": "utvidgning",
|
73 |
-
"搜索(支持正则)...": "Sök (stöd för reguljära uttryck)...",
|
74 |
-
"数据集预览": "Datasetförhandsvisning",
|
75 |
-
"文件ID": "Fil-ID",
|
76 |
-
"新���话 ": "Ny dialog ",
|
77 |
-
"新建对话保留Prompt": "Skapa ny konversation med bevarad Prompt",
|
78 |
-
"暂时未知": "Okänd",
|
79 |
-
"更新": "Uppdatera",
|
80 |
-
"更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)": "Uppdateringen misslyckades, prova att [uppdatera manuellt](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)",
|
81 |
-
"更新成功,请重启本程序": "Uppdaterat framgångsrikt, starta om programmet",
|
82 |
-
"未命名对话历史记录": "Onämnd Dialoghistorik",
|
83 |
-
"未设置代理...": "Inte inställd proxy...",
|
84 |
-
"本月使用金额": "Månadens användning",
|
85 |
-
"查看[使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)": "Se [användarguiden](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35) för mer information",
|
86 |
-
"根据日期时间": "Enligt datum och tid",
|
87 |
-
"模型": "Modell",
|
88 |
-
"模型名称后缀": "Modellnamnstillägg",
|
89 |
-
"模型自动总结(消耗tokens)": "Modellens automatiska sammanfattning (förbrukar tokens)",
|
90 |
-
"模型设置为了:": "Modellen är inställd på: ",
|
91 |
-
"正在尝试更新...": "Försöker uppdatera...",
|
92 |
-
"添加训练好的模型到模型列表": "Lägg till tränad modell i modellistan",
|
93 |
-
"状态": "Status",
|
94 |
-
"生成内容总结中……": "Genererar innehållssammanfattning...",
|
95 |
-
"用于定位滥用行为": "Används för att lokalisera missbruk",
|
96 |
-
"用户名": "Användarnamn",
|
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) 下载最新版脚本": "Utvecklad av Bilibili [土川虎虎虎](https://space.bilibili.com/29125536), [明昭MZhao](https://space.bilibili.com/24807452) och [Keldos](https://github.com/Keldos-Li)\n\nLadda ner senaste koden från [GitHub](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
|
98 |
-
"知识库": "kunskapsbank",
|
99 |
-
"知识库文件": "kunskapsbankfil",
|
100 |
-
"第一条提问": "Första frågan",
|
101 |
-
"索引构建完成": "Indexet har blivit byggt färdigt.",
|
102 |
-
"网络": "nätverksparametrar",
|
103 |
-
"获取API使用情况失败:": "Misslyckades med att hämta API-användning:",
|
104 |
-
"获取IP地理位置失败。原因:": "Misslyckades med att hämta IP-plats. Orsak: ",
|
105 |
-
"获取对话时发生错误,请查看后台日志": "Ett fel uppstod när dialogen hämtades, kontrollera bakgrundsloggen",
|
106 |
-
"训练": "träning",
|
107 |
-
"训练状态": "Träningsstatus",
|
108 |
-
"训练轮数(Epochs)": "Träningsomgångar (Epochs)",
|
109 |
-
"设置": "inställningar",
|
110 |
-
"设置保存文件名": "Ställ in sparfilnamn",
|
111 |
-
"设置文件名: 默认为.json,可选为.md": "Ställ in filnamn: standard är .json, valfritt är .md",
|
112 |
-
"识别公式": "Formel OCR",
|
113 |
-
"详情": "Detaljer",
|
114 |
-
"请查看 config_example.json,配置 Azure OpenAI": "Vänligen granska config_example.json för att konfigurera Azure OpenAI",
|
115 |
-
"请检查网络连接,或者API-Key是否有效。": "Kontrollera nätverksanslutningen eller om API-nyckeln är giltig.",
|
116 |
-
"请输入对话内容。": "Ange dialoginnehåll.",
|
117 |
-
"请输入有效的文件名,不要包含以下特殊字符:": "Ange ett giltigt filnamn, använd inte följande specialtecken: ",
|
118 |
-
"读取超时,无法获取对话。": "Läsningen tog för lång tid, kunde inte hämta dialogen.",
|
119 |
-
"账单信息不适用": "Faktureringsinformation är inte tillämplig",
|
120 |
-
"连接超时,无法获取对话。": "Anslutningen tog för lång tid, kunde inte hämta dialogen.",
|
121 |
-
"选择LoRA模型": "Välj LoRA Modell",
|
122 |
-
"选择Prompt模板集合文件": "Välj Prompt-mall Samlingsfil",
|
123 |
-
"选择回复语言(针对搜索&索引功能)": "Välj svarspråk (för sök- och indexfunktion)",
|
124 |
-
"选择数据集": "Välj dataset",
|
125 |
-
"选择模型": "Välj Modell",
|
126 |
-
"重命名该对话": "Byt namn på dialogen",
|
127 |
-
"重新生成": "Återgenerera",
|
128 |
-
"高级": "Avancerat",
|
129 |
-
",本次对话累计消耗了 ": ", Total kostnad för denna dialog är ",
|
130 |
-
"💾 保存对话": "💾 Spara Dialog",
|
131 |
-
"📝 导出为 Markdown": "📝 Exportera som Markdown",
|
132 |
-
"🔄 切换API地址": "🔄 Byt API-adress",
|
133 |
-
"🔄 刷新": "🔄 Uppdatera",
|
134 |
-
"🔄 检查更新...": "🔄 Sök efter uppdateringar...",
|
135 |
-
"🔄 设置代理地址": "🔄 Ställ in Proxyadress",
|
136 |
-
"🔄 重新生成": "🔄 Regenerera",
|
137 |
-
"🔙 恢复默认网络设置": "🔙 Återställ standardnätverksinställningar+",
|
138 |
-
"🗑️ 删除最新对话": "🗑️ Ta bort senaste dialogen",
|
139 |
-
"🗑️ 删除最旧对话": "🗑️ Ta bort äldsta dialogen",
|
140 |
-
"🧹 新的对话": "🧹 Ny Dialog"
|
141 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
locale/vi_VN.json
DELETED
@@ -1,141 +0,0 @@
|
|
1 |
-
{
|
2 |
-
" 吗?": " ?",
|
3 |
-
"# ⚠️ 务必谨慎更改 ⚠️": "# ⚠️ Lưu ý: Thay đổi yêu cầu cẩn thận. ⚠️",
|
4 |
-
"**发送消息** 或 **提交key** 以显示额度": "**Gửi tin nhắn** hoặc **Gửi khóa(key)** để hiển thị số dư",
|
5 |
-
"**本月使用金额** ": "**Số tiền sử dụng trong tháng** ",
|
6 |
-
"**获取API使用情况失败**": "**Lỗi khi lấy thông tin sử dụng API**",
|
7 |
-
"**获取API使用情况失败**,sensitive_id错误或已过期": "**Lỗi khi lấy thông tin sử dụng API**, sensitive_id sai hoặc đã hết hạn",
|
8 |
-
"**获取API使用情况失败**,需在填写`config.json`中正确填写sensitive_id": "**Lỗi khi lấy thông tin sử dụng API**, cần điền đúng sensitive_id trong tệp `config.json`",
|
9 |
-
"API key为空,请检查是否输入正确。": "Khóa API trống, vui lòng kiểm tra xem đã nhập đúng chưa.",
|
10 |
-
"API密钥更改为了": "Khóa API đã được thay đổi thành",
|
11 |
-
"JSON解析错误,收到的内容: ": "Lỗi phân tích JSON, nội dung nhận được: ",
|
12 |
-
"SSL错误,无法获取对话。": "Lỗi SSL, không thể nhận cuộc trò chuyện.",
|
13 |
-
"Token 计数: ": "Số lượng Token: ",
|
14 |
-
"☹️发生了错误:": "☹️Lỗi: ",
|
15 |
-
"⚠️ 为保证API-Key安全,请在配置文件`config.json`中修改网络设置": "⚠️ Để đảm bảo an toàn cho API-Key, vui lòng chỉnh sửa cài đặt mạng trong tệp cấu hình `config.json`.",
|
16 |
-
"。你仍然可以使用聊天功能。": ". Bạn vẫn có thể sử dụng chức năng trò chuyện.",
|
17 |
-
"上传": "Tải lên",
|
18 |
-
"上传了": "Tải lên thành công.",
|
19 |
-
"上传到 OpenAI 后自动填充": "Tự động điền sau khi tải lên OpenAI",
|
20 |
-
"上传到OpenAI": "Tải lên OpenAI",
|
21 |
-
"上传文件": "Tải lên tệp",
|
22 |
-
"仅供查看": "Chỉ xem",
|
23 |
-
"从Prompt模板中加载": "Tải từ mẫu Prompt",
|
24 |
-
"从列表中加载对话": "Tải cuộc trò chuyện từ danh sách",
|
25 |
-
"代理地址": "Địa chỉ proxy",
|
26 |
-
"代理错误,无法获取对话。": "Lỗi proxy, không thể nhận cuộc trò chuyện.",
|
27 |
-
"你没有权限访问 GPT4,[进一步了解](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/843)": "Bạn không có quyền truy cập GPT-4, [tìm hiểu thêm](https://github.com/GaiZhenbiao/ChuanhuChatGPT/issues/843)",
|
28 |
-
"你没有选择任何对话历史": "Bạn chưa chọn bất kỳ lịch sử trò chuyện nào.",
|
29 |
-
"你真的要删除 ": "Bạn có chắc chắn muốn xóa ",
|
30 |
-
"使用在线搜索": "Sử dụng tìm kiếm trực tuyến",
|
31 |
-
"停止符,用英文逗号隔开...": "Nhập dấu dừng, cách nhau bằng dấu phẩy...",
|
32 |
-
"关于": "Về",
|
33 |
-
"准备数据集": "Chuẩn bị tập dữ liệu",
|
34 |
-
"切换亮暗色主题": "Chuyển đổi chủ đề sáng/tối",
|
35 |
-
"删除对话历史成功": "Xóa lịch sử cuộc trò chuyện thành công.",
|
36 |
-
"删除这轮问答": "Xóa cuộc trò chuyện này",
|
37 |
-
"刷新状态": "Làm mới tình trạng",
|
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)": "剩余配额 không đủ, [Nhấn vào đây để biết thêm](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模板": "Tải mẫu Prompt",
|
40 |
-
"单轮对话": "Cuộc trò chuyện một lượt",
|
41 |
-
"历史记录(JSON)": "Tệp lịch sử (JSON)",
|
42 |
-
"参数": "Tham số",
|
43 |
-
"双栏pdf": "PDF hai cột",
|
44 |
-
"取消": "Hủy",
|
45 |
-
"取消所有任务": "Hủy tất cả các nhiệm vụ",
|
46 |
-
"可选,用于区分不同的模型": "Tùy chọn, sử dụng để phân biệt các mô hình khác nhau",
|
47 |
-
"启用的工具:": "Công cụ đã bật: ",
|
48 |
-
"在工具箱中管理知识库文件": "Quản lý tệp cơ sở kiến thức trong hộp công cụ",
|
49 |
-
"在线搜索": "Tìm kiếm trực tuyến",
|
50 |
-
"在这里输入": "Nhập vào đây",
|
51 |
-
"在这里输入System Prompt...": "Nhập System Prompt ở đây...",
|
52 |
-
"多账号模式已开启,无需输入key,可直接开始对话": "Chế độ nhiều tài khoản đã được bật, không cần nhập key, bạn có thể bắt đầu cuộc trò chuyện trực tiếp",
|
53 |
-
"好": "OK",
|
54 |
-
"实时传输回答": "Truyền đầu ra trực tiếp",
|
55 |
-
"对话": "Cuộc trò chuyện",
|
56 |
-
"对话历史": "Lịch sử cuộc trò chuyện",
|
57 |
-
"对话历史记录": "Lịch sử Cuộc trò chuyện",
|
58 |
-
"对话命名方式": "Phương thức đặt tên lịch sử trò chuyện",
|
59 |
-
"导出为 Markdown": "Xuất ra Markdown",
|
60 |
-
"川虎Chat": "Chuanhu Chat",
|
61 |
-
"川虎Chat 🚀": "Chuanhu Chat 🚀",
|
62 |
-
"工具箱": "Hộp công cụ",
|
63 |
-
"已经��删除啦": "Đã bị xóa rồi.",
|
64 |
-
"开始实时传输回答……": "Bắt đầu truyền đầu ra trực tiếp...",
|
65 |
-
"开始训练": "Bắt đầu đào tạo",
|
66 |
-
"微调": "Feeling-tuning",
|
67 |
-
"总结": "Tóm tắt",
|
68 |
-
"总结完成": "Hoàn thành tóm tắt",
|
69 |
-
"您使用的就是最新版!": "Bạn đang sử dụng phiên bản mới nhất!",
|
70 |
-
"您的IP区域:": "Khu vực IP của bạn: ",
|
71 |
-
"您的IP区域:未知。": "Khu vực IP của bạn: Không xác định.",
|
72 |
-
"拓展": "Mở rộng",
|
73 |
-
"搜索(支持正则)...": "Tìm kiếm (hỗ trợ regex)...",
|
74 |
-
"数据集预览": "Xem trước tập dữ liệu",
|
75 |
-
"文件ID": "ID Tệp",
|
76 |
-
"新对话 ": "Cuộc trò chuyện mới ",
|
77 |
-
"新建对话保留Prompt": "Tạo Cuộc trò chuyện mới và giữ Prompt nguyên vẹn",
|
78 |
-
"暂时未知": "Tạm thời chưa xác định",
|
79 |
-
"更新": "Cập nhật",
|
80 |
-
"更新失败,请尝试[手动更新](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)": "Cập nhật thất bại, vui lòng thử [cập nhật thủ công](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#手动更新)",
|
81 |
-
"更新成功,请重启本程序": "Cập nhật thành công, vui lòng khởi động lại chương trình này",
|
82 |
-
"未命名对话历史记录": "Lịch sử Cuộc trò chuyện không đặt tên",
|
83 |
-
"未设置代理...": "Không có proxy...",
|
84 |
-
"本月使用金额": "Số tiền sử dụng trong tháng",
|
85 |
-
"查看[使用介绍](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35)": "Xem [hướng dẫn sử dụng](https://github.com/GaiZhenbiao/ChuanhuChatGPT/wiki/使用教程#微调-gpt-35) để biết thêm chi tiết",
|
86 |
-
"根据日期时间": "Theo ngày và giờ",
|
87 |
-
"模型": "Mô hình",
|
88 |
-
"模型名称后缀": "Hậu tố Tên Mô hình",
|
89 |
-
"模型自动总结(消耗tokens)": "Tự động tóm tắt bằng LLM (Tiêu thụ token)",
|
90 |
-
"模型设置为了:": "Mô hình đã được đặt thành: ",
|
91 |
-
"正在尝试更新...": "Đang cố gắng cập nhật...",
|
92 |
-
"添加训练好的模型到模型列表": "Thêm mô hình đã đào tạo vào danh sách mô hình",
|
93 |
-
"状态": "Tình trạng",
|
94 |
-
"生成内容总结中……": "Đang tạo tóm tắt nội dung...",
|
95 |
-
"用于定位滥用行为": "Sử dụng để xác định hành vi lạm dụng",
|
96 |
-
"用户名": "Tên người dùng",
|
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) 下载最新版脚本": "Phát triển bởi Bilibili [土川虎虎虎](https://space.bilibili.com/29125536), [明昭MZhao](https://space.bilibili.com/24807452) và [Keldos](https://github.com/Keldos-Li)\n\nTải mã nguồn mới nhất từ [GitHub](https://github.com/GaiZhenbiao/ChuanhuChatGPT)",
|
98 |
-
"知识库": "Cơ sở kiến thức",
|
99 |
-
"知识库文件": "Tệp cơ sở kiến thức",
|
100 |
-
"第一条提问": "Theo câu hỏi đầu tiên",
|
101 |
-
"索引构建完成": "Xây dựng chỉ mục hoàn tất",
|
102 |
-
"网络": "Mạng",
|
103 |
-
"获取API使用情况失败:": "Lỗi khi lấy thông tin sử dụng API:",
|
104 |
-
"获取IP地理位置失败。原因:": "Không thể lấy vị trí địa lý của IP. Nguyên nhân: ",
|
105 |
-
"获取对话时发生错误,请查看后台日志": "Xảy ra lỗi khi nhận cuộc trò chuyện, kiểm tra nhật ký nền",
|
106 |
-
"训练": "Đào tạo",
|
107 |
-
"训练状态": "Tình trạng đào tạo",
|
108 |
-
"训练轮数(Epochs)": "Số lượt đào tạo (Epochs)",
|
109 |
-
"设置": "Cài đặt",
|
110 |
-
"设置保存文件名": "Đặt tên tệp lưu",
|
111 |
-
"设置文件名: 默认为.json,可选为.md": "Đặt tên tệp: mặc định là .json, tùy chọn là .md",
|
112 |
-
"识别公式": "Nhận dạng công thức",
|
113 |
-
"详情": "Chi tiết",
|
114 |
-
"请查看 config_example.json,配置 Azure OpenAI": "Vui lòng xem tệp config_example.json để cấu hình Azure OpenAI",
|
115 |
-
"请检查网络连接,或者API-Key是否有效。": "Vui lòng kiểm tra kết nối mạng hoặc xem xét tính hợp lệ của API-Key.",
|
116 |
-
"请输入对话内容。": "Nhập nội dung cuộc trò chuyện.",
|
117 |
-
"请输入有效的文件名,不要包含以下特殊字符:": "Vui lòng nhập tên tệp hợp lệ, không chứa các ký tự đặc biệt sau: ",
|
118 |
-
"读取超时,无法获取对话。": "Hết thời gian đọc, không thể nhận cuộc trò chuyện.",
|
119 |
-
"账单信息不适用": "Thông tin thanh toán không áp dụng",
|
120 |
-
"连接超时,无法获取对话。": "Hết thời gian kết nối, không thể nhận cuộc trò chuyện.",
|
121 |
-
"选择LoRA模型": "Chọn Mô hình LoRA",
|
122 |
-
"选择Prompt模板集合文件": "Chọn Tệp bộ sưu tập mẫu Prompt",
|
123 |
-
"选择回复语言��针对搜索&索引功能)": "Chọn ngôn ngữ phản hồi (đối với chức năng tìm kiếm & chỉ mục)",
|
124 |
-
"选择数据集": "Chọn tập dữ liệu",
|
125 |
-
"选择模型": "Chọn Mô hình",
|
126 |
-
"重命名该对话": "Đổi tên cuộc trò chuyện này",
|
127 |
-
"重新生成": "Tạo lại",
|
128 |
-
"高级": "Nâng cao",
|
129 |
-
",本次对话累计消耗了 ": ", Tổng cộng chi phí cho cuộc trò chuyện này là ",
|
130 |
-
"💾 保存对话": "💾 Lưu Cuộc trò chuyện",
|
131 |
-
"📝 导出为 Markdown": "📝 Xuất ra dưới dạng Markdown",
|
132 |
-
"🔄 切换API地址": "🔄 Chuyển đổi Địa chỉ API",
|
133 |
-
"🔄 刷新": "🔄 Làm mới",
|
134 |
-
"🔄 检查更新...": "🔄 Kiểm tra cập nhật...",
|
135 |
-
"🔄 设置代理地址": "🔄 Đặt Địa chỉ Proxy",
|
136 |
-
"🔄 重新生成": "🔄 Tạo lại",
|
137 |
-
"🔙 恢复默认网络设置": "🔙 Khôi phục cài đặt mạng mặc định",
|
138 |
-
"🗑️ 删除最新对话": "🗑️ Xóa cuộc trò chuyện mới nhất",
|
139 |
-
"🗑️ 删除最旧对话": "🗑️ Xóa cuộc trò chuyện cũ nhất",
|
140 |
-
"🧹 新的对话": "🧹 Cuộc trò chuyện mới"
|
141 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
locale/zh_CN.json
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
{}
|
|
|
|
modules/.DS_Store
DELETED
Binary file (6.15 kB)
|
|
modules/__init__.py
DELETED
File without changes
|
modules/__pycache__/__init__.cpython-311.pyc
DELETED
Binary file (172 Bytes)
|
|
modules/__pycache__/__init__.cpython-39.pyc
DELETED
Binary file (154 Bytes)
|
|
modules/__pycache__/base_model.cpython-311.pyc
DELETED
Binary file (28.7 kB)
|
|
modules/__pycache__/base_model.cpython-39.pyc
DELETED
Binary file (16.3 kB)
|
|
modules/__pycache__/chat_func.cpython-39.pyc
DELETED
Binary file (10.1 kB)
|
|
modules/__pycache__/config.cpython-311.pyc
DELETED
Binary file (14.3 kB)
|
|
modules/__pycache__/config.cpython-39.pyc
DELETED
Binary file (5.3 kB)
|
|
modules/__pycache__/index_func.cpython-311.pyc
DELETED
Binary file (8.2 kB)
|
|
modules/__pycache__/index_func.cpython-39.pyc
DELETED
Binary file (4.52 kB)
|
|
modules/__pycache__/llama_func.cpython-311.pyc
DELETED
Binary file (9.44 kB)
|
|
modules/__pycache__/llama_func.cpython-39.pyc
DELETED
Binary file (4.85 kB)
|
|
modules/__pycache__/models.cpython-311.pyc
DELETED
Binary file (31.2 kB)
|
|
modules/__pycache__/models.cpython-39.pyc
DELETED
Binary file (17.5 kB)
|
|
modules/__pycache__/openai_func.cpython-39.pyc
DELETED
Binary file (2.16 kB)
|
|
modules/__pycache__/overwrites.cpython-311.pyc
DELETED
Binary file (5.16 kB)
|
|
modules/__pycache__/overwrites.cpython-39.pyc
DELETED
Binary file (3.41 kB)
|
|
modules/__pycache__/pdf_func.cpython-311.pyc
DELETED
Binary file (10.4 kB)
|
|
modules/__pycache__/pdf_func.cpython-39.pyc
DELETED
Binary file (6.13 kB)
|
|
modules/__pycache__/presets.cpython-311.pyc
DELETED
Binary file (9.24 kB)
|
|
modules/__pycache__/presets.cpython-39.pyc
DELETED
Binary file (6.27 kB)
|
|
modules/__pycache__/proxy_func.cpython-39.pyc
DELETED
Binary file (718 Bytes)
|
|
modules/__pycache__/repo.cpython-311.pyc
DELETED
Binary file (14.8 kB)
|
|
modules/__pycache__/shared.cpython-311.pyc
DELETED
Binary file (4 kB)
|
|