Spaces:
Sleeping
Sleeping
Keldos
commited on
Commit
·
74da1a0
1
Parent(s):
164fb4e
feat: 可以点击以重启
Browse fileschore: update i18n
- ChuanhuChatbot.py +11 -0
- locale/en_US.json +3 -0
- locale/ja_JP.json +4 -1
- locale/ko_KR.json +4 -1
- locale/ru_RU.json +4 -1
- locale/sv_SE.json +4 -1
- locale/vi_VN.json +4 -1
- modules/utils.py +5 -0
- web_assets/html/update.html +4 -0
- web_assets/javascript/ChuanhuChat.js +2 -0
- web_assets/javascript/fake-gradio.js +4 -0
- web_assets/javascript/updater.js +10 -2
- web_assets/javascript/utils.js +8 -0
ChuanhuChatbot.py
CHANGED
@@ -55,6 +55,8 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
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"):
|
@@ -484,6 +486,8 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
484 |
with gr.Box(elem_id="fake-gradio-components", visible=False):
|
485 |
updateChuanhuBtn = gr.Button(
|
486 |
visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
|
|
|
|
|
487 |
changeSingleSessionBtn = gr.Button(
|
488 |
visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
|
489 |
changeOnlineSearchBtn = gr.Button(
|
@@ -772,6 +776,13 @@ with gr.Blocks(theme=small_and_beautiful_theme) as demo:
|
|
772 |
[status_display],
|
773 |
show_progress=True,
|
774 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
775 |
changeSingleSessionBtn.click(
|
776 |
fn=lambda value: gr.Checkbox.update(value=value),
|
777 |
inputs=[single_turn_checkbox],
|
|
|
55 |
update_btn=i18n("更新"),
|
56 |
seenew_btn=i18n("详情"),
|
57 |
ok_btn=i18n("好"),
|
58 |
+
close_btn=i18n("关闭"),
|
59 |
+
reboot_btn=i18n("立即重启"),
|
60 |
), visible=check_update)
|
61 |
|
62 |
with gr.Row(equal_height=True, elem_id="chuanhu-body"):
|
|
|
486 |
with gr.Box(elem_id="fake-gradio-components", visible=False):
|
487 |
updateChuanhuBtn = gr.Button(
|
488 |
visible=False, elem_classes="invisible-btn", elem_id="update-chuanhu-btn")
|
489 |
+
rebootChuanhuBtn = gr.Button(
|
490 |
+
visible=False, elem_classes="invisible-btn", elem_id="reboot-chuanhu-btn")
|
491 |
changeSingleSessionBtn = gr.Button(
|
492 |
visible=False, elem_classes="invisible-btn", elem_id="change-single-session-btn")
|
493 |
changeOnlineSearchBtn = gr.Button(
|
|
|
776 |
[status_display],
|
777 |
show_progress=True,
|
778 |
)
|
779 |
+
rebootChuanhuBtn.click(
|
780 |
+
reboot_chuanhu,
|
781 |
+
[],
|
782 |
+
[],
|
783 |
+
show_progress=True,
|
784 |
+
_js='rebootingChuanhu'
|
785 |
+
)
|
786 |
changeSingleSessionBtn.click(
|
787 |
fn=lambda value: gr.Checkbox.update(value=value),
|
788 |
inputs=[single_turn_checkbox],
|
locale/en_US.json
CHANGED
@@ -141,6 +141,9 @@
|
|
141 |
"正在获取IP地址信息,请稍候...": "Getting IP address information, please wait...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Please clear the files in the knowledge base before trying to upload new files!",
|
143 |
"释放文件以上传": "Drop files to upload",
|
|
|
|
|
|
|
144 |
"正在进行首次设置,请按照提示进行配置,配置将会被保存在": "First-time setup is in progress, please follow the prompts to configure, and the configuration will be saved in",
|
145 |
"中。": ".",
|
146 |
"在": "",
|
|
|
141 |
"正在获取IP地址信息,请稍候...": "Getting IP address information, please wait...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Please clear the files in the knowledge base before trying to upload new files!",
|
143 |
"释放文件以上传": "Drop files to upload",
|
144 |
+
"关闭": "Close",
|
145 |
+
"立即重启": "Restart now",
|
146 |
+
"正在尝试重启...": "Trying to restart...",
|
147 |
"正在进行首次设置,请按照提示进行配置,配置将会被保存在": "First-time setup is in progress, please follow the prompts to configure, and the configuration will be saved in",
|
148 |
"中。": ".",
|
149 |
"在": "",
|
locale/ja_JP.json
CHANGED
@@ -140,5 +140,8 @@
|
|
140 |
"🧹 新的对话": "🧹 新しい会話",
|
141 |
"正在获取IP地址信息,请稍候...": "IPアドレス情報を取得しています、しばらくお待ちください...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ ナレッジベースの履歴ファイルを削除してから、アップロードを試してください!",
|
143 |
-
"释放文件以上传": "ファイルをアップロードするには、ここでドロップしてください"
|
|
|
|
|
|
|
144 |
}
|
|
|
140 |
"🧹 新的对话": "🧹 新しい会話",
|
141 |
"正在获取IP地址信息,请稍候...": "IPアドレス情報を取得しています、しばらくお待ちください...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ ナレッジベースの履歴ファイルを削除してから、アップロードを試してください!",
|
143 |
+
"释放文件以上传": "ファイルをアップロードするには、ここでドロップしてください",
|
144 |
+
"关闭": "閉じる",
|
145 |
+
"立即重启": "今すぐ再起動",
|
146 |
+
"正在尝试重启...": "再起動を試みています..."
|
147 |
}
|
locale/ko_KR.json
CHANGED
@@ -140,5 +140,8 @@
|
|
140 |
"🧹 新的对话": "🧹 새로운 대화",
|
141 |
"正在获取IP地址信息,请稍候...": "IP 주소 정보를 가져오는 중입니다. 잠시만 기다려주세요...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ 먼저 지식 라이브러리에서 기록 파일을 삭제한 후 다시 업로드하세요!",
|
143 |
-
"释放文件以上传": "파일을 놓아 업로드"
|
|
|
|
|
|
|
144 |
}
|
|
|
140 |
"🧹 新的对话": "🧹 새로운 대화",
|
141 |
"正在获取IP地址信息,请稍候...": "IP 주소 정보를 가져오는 중입니다. 잠시만 기다려주세요...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ 먼저 지식 라이브러리에서 기록 파일을 삭제한 후 다시 업로드하세요!",
|
143 |
+
"释放文件以上传": "파일을 놓아 업로드",
|
144 |
+
"关闭": "닫기",
|
145 |
+
"立即重启": "지금 재시작",
|
146 |
+
"正在尝试重启...": "재시작을 시도 중..."
|
147 |
}
|
locale/ru_RU.json
CHANGED
@@ -140,5 +140,8 @@
|
|
140 |
"🧹 新的对话": "🧹 Новый диалог",
|
141 |
"正在获取IP地址信息,请稍候...": "Получение информации об IP-адресе, пожалуйста, подождите...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Сначала удалите исторические файлы из базы знаний, а затем попробуйте загрузить!",
|
143 |
-
"释放文件以上传": "Отпустите файл для загрузки"
|
|
|
|
|
|
|
144 |
}
|
|
|
140 |
"🧹 新的对话": "🧹 Новый диалог",
|
141 |
"正在获取IP地址信息,请稍候...": "Получение информации об IP-адресе, пожалуйста, подождите...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Сначала удалите исторические файлы из базы знаний, а затем попробуйте загрузить!",
|
143 |
+
"释放文件以上传": "Отпустите файл для загрузки",
|
144 |
+
"关闭": "Закрыть",
|
145 |
+
"立即重启": "Перезапустить сейчас",
|
146 |
+
"正在尝试重启...": "Попытка перезапуска..."
|
147 |
}
|
locale/sv_SE.json
CHANGED
@@ -140,5 +140,8 @@
|
|
140 |
"🧹 新的对话": "🧹 Ny Dialog",
|
141 |
"正在获取IP地址信息,请稍候...": "Hämtar IP-adressinformation, vänta...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Ta bort historikfilen i kunskapsbanken innan du försöker ladda upp!",
|
143 |
-
"释放文件以上传": "Släpp filen för att ladda upp"
|
|
|
|
|
|
|
144 |
}
|
|
|
140 |
"🧹 新的对话": "🧹 Ny Dialog",
|
141 |
"正在获取IP地址信息,请稍候...": "Hämtar IP-adressinformation, vänta...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Ta bort historikfilen i kunskapsbanken innan du försöker ladda upp!",
|
143 |
+
"释放文件以上传": "Släpp filen för att ladda upp",
|
144 |
+
"关闭": "Stäng",
|
145 |
+
"立即重启": "Starta om nu",
|
146 |
+
"正在尝试重启...": "Försöker starta om..."
|
147 |
}
|
locale/vi_VN.json
CHANGED
@@ -140,5 +140,8 @@
|
|
140 |
"🧹 新的对话": "🧹 Cuộc trò chuyện mới",
|
141 |
"正在获取IP地址信息,请稍候...": "Đang lấy thông tin địa chỉ IP, vui lòng đợi...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Vui lòng xóa tệp lịch sử trong cơ sở kiến thức trước khi tải lên!",
|
143 |
-
"释放文件以上传": "Thả tệp để tải lên"
|
|
|
|
|
|
|
144 |
}
|
|
|
140 |
"🧹 新的对话": "🧹 Cuộc trò chuyện mới",
|
141 |
"正在获取IP地址信息,请稍候...": "Đang lấy thông tin địa chỉ IP, vui lòng đợi...",
|
142 |
"⚠️请先删除知识库中的历史文件,再尝试上传!": "⚠️ Vui lòng xóa tệp lịch sử trong cơ sở kiến thức trước khi tải lên!",
|
143 |
+
"释放文件以上传": "Thả tệp để tải lên",
|
144 |
+
"关闭": "Đóng",
|
145 |
+
"立即重启": "Khởi động lại ngay",
|
146 |
+
"正在尝试重启...": "Đang cố gắng khởi động lại..."
|
147 |
}
|
modules/utils.py
CHANGED
@@ -1405,3 +1405,8 @@ def setup_wizard():
|
|
1405 |
wizard.save()
|
1406 |
print(colorama.Back.GREEN + i18n("设置完成。现在请重启本程序。") + colorama.Style.RESET_ALL)
|
1407 |
exit()
|
|
|
|
|
|
|
|
|
|
|
|
1405 |
wizard.save()
|
1406 |
print(colorama.Back.GREEN + i18n("设置完成。现在请重启本程序。") + colorama.Style.RESET_ALL)
|
1407 |
exit()
|
1408 |
+
|
1409 |
+
def reboot_chuanhu():
|
1410 |
+
import sys
|
1411 |
+
print(colorama.Back.GREEN + i18n("正在尝试重启...") + colorama.Style.RESET_ALL)
|
1412 |
+
os.execl(sys.executable, sys.executable, *sys.argv)
|
web_assets/html/update.html
CHANGED
@@ -25,5 +25,9 @@
|
|
25 |
<button class="btn-update lg secondary svelte-cmf5ev" id="seenew-button" onclick="getUpdateInfo()">{seenew_btn}</button>
|
26 |
<button class="btn-update lg primary svelte-cmf5ev" id="ok-button" onclick="cancelUpdate()">{ok_btn}</button>
|
27 |
</div>
|
|
|
|
|
|
|
|
|
28 |
</div>
|
29 |
</div>
|
|
|
25 |
<button class="btn-update lg secondary svelte-cmf5ev" id="seenew-button" onclick="getUpdateInfo()">{seenew_btn}</button>
|
26 |
<button class="btn-update lg primary svelte-cmf5ev" id="ok-button" onclick="cancelUpdate()">{ok_btn}</button>
|
27 |
</div>
|
28 |
+
<div id="success-update-btn" class="btn-update-group hideK">
|
29 |
+
<button class="btn-update lg secondary svelte-cmf5ev" id="close-button" onclick="cancelUpdate()">{close_btn}</button>
|
30 |
+
<button class="btn-update lg primary svelte-cmf5ev" id="reboot-button" onclick="bgRebootChuanhu()">{reboot_btn}</button>
|
31 |
+
</div>
|
32 |
</div>
|
33 |
</div>
|
web_assets/javascript/ChuanhuChat.js
CHANGED
@@ -26,6 +26,7 @@ var sendBtn = null;
|
|
26 |
var cancelBtn = null;
|
27 |
var sliders = null;
|
28 |
var updateChuanhuBtn = null;
|
|
|
29 |
var statusDisplay = null;
|
30 |
|
31 |
var historySelector = null;
|
@@ -82,6 +83,7 @@ function initialize() {
|
|
82 |
cancelBtn = gradioApp().getElementById("cancel-btn");
|
83 |
sliders = gradioApp().querySelectorAll('input[type="range"]');
|
84 |
updateChuanhuBtn = gradioApp().getElementById("update-chuanhu-btn");
|
|
|
85 |
statusDisplay = gradioApp().querySelector('#status-display');
|
86 |
|
87 |
historySelector = gradioApp().querySelector('#history-select-dropdown');
|
|
|
26 |
var cancelBtn = null;
|
27 |
var sliders = null;
|
28 |
var updateChuanhuBtn = null;
|
29 |
+
var rebootChuanhuBtn = null;
|
30 |
var statusDisplay = null;
|
31 |
|
32 |
var historySelector = null;
|
|
|
83 |
cancelBtn = gradioApp().getElementById("cancel-btn");
|
84 |
sliders = gradioApp().querySelectorAll('input[type="range"]');
|
85 |
updateChuanhuBtn = gradioApp().getElementById("update-chuanhu-btn");
|
86 |
+
rebootChuanhuBtn = gradioApp().getElementById("reboot-chuanhu-btn");
|
87 |
statusDisplay = gradioApp().querySelector('#status-display');
|
88 |
|
89 |
historySelector = gradioApp().querySelector('#history-select-dropdown');
|
web_assets/javascript/fake-gradio.js
CHANGED
@@ -115,3 +115,7 @@ function bgSelectHistory(a,b){
|
|
115 |
let file = historySelectorInput.value;
|
116 |
return [a,file]
|
117 |
}
|
|
|
|
|
|
|
|
|
|
115 |
let file = historySelectorInput.value;
|
116 |
return [a,file]
|
117 |
}
|
118 |
+
|
119 |
+
function bgRebootChuanhu() {
|
120 |
+
rebootChuanhuBtn.click()
|
121 |
+
}
|
web_assets/javascript/updater.js
CHANGED
@@ -27,8 +27,8 @@ var statusObserver = new MutationObserver(function (mutationsList) {
|
|
27 |
if (mutation.type === 'attributes' || mutation.type === 'childList') {
|
28 |
if (statusDisplay.innerHTML.includes('id="update-status"')) {
|
29 |
if (getUpdateStatus() === "success") {
|
30 |
-
|
31 |
-
|
32 |
localStorage.setItem('isLatestVersion', 'true');
|
33 |
isLatestVersion = true;
|
34 |
gradioApp().classList.remove('is-outdated');
|
@@ -187,6 +187,14 @@ function manualCheckUpdate() {
|
|
187 |
currentTime = new Date().getTime();
|
188 |
localStorage.setItem('lastCheckTime', currentTime);
|
189 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
function noUpdate(message="") {
|
191 |
localStorage.setItem('isLatestVersion', 'true');
|
192 |
isLatestVersion = true;
|
|
|
27 |
if (mutation.type === 'attributes' || mutation.type === 'childList') {
|
28 |
if (statusDisplay.innerHTML.includes('id="update-status"')) {
|
29 |
if (getUpdateStatus() === "success") {
|
30 |
+
// noUpdateHtml();
|
31 |
+
updateSuccessHtml();
|
32 |
localStorage.setItem('isLatestVersion', 'true');
|
33 |
isLatestVersion = true;
|
34 |
gradioApp().classList.remove('is-outdated');
|
|
|
187 |
currentTime = new Date().getTime();
|
188 |
localStorage.setItem('lastCheckTime', currentTime);
|
189 |
}
|
190 |
+
|
191 |
+
function updateSuccessHtml() {
|
192 |
+
updatingInfoElement.innerText = i18n(updateSuccess_i18n);
|
193 |
+
const gotoUpdateBtn = document.getElementById('goto-update-btn');
|
194 |
+
const successUpdateBtn = document.getElementById('success-update-btn');
|
195 |
+
gotoUpdateBtn.classList.add('hideK');
|
196 |
+
successUpdateBtn.classList.remove('hideK');
|
197 |
+
}
|
198 |
function noUpdate(message="") {
|
199 |
localStorage.setItem('isLatestVersion', 'true');
|
200 |
isLatestVersion = true;
|
web_assets/javascript/utils.js
CHANGED
@@ -85,6 +85,14 @@ function bindFancyBox() {
|
|
85 |
});
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
/* NOTE: These reload functions are not used in the current version of the code.
|
90 |
* From stable-diffusion-webui
|
|
|
85 |
});
|
86 |
}
|
87 |
|
88 |
+
function rebootingChuanhu() {
|
89 |
+
reloadSpinner = new Spin.Spinner({color:'#06AE56',lines:9}).spin();
|
90 |
+
pageInfo = document.createElement('div');
|
91 |
+
pageInfo.appendChild(reloadSpinner.el);
|
92 |
+
pageInfo.innerHTML += '<h1 style="position: absolute; left: 50%; top: 50%; transform: translateX(-50%); color: lightgray; text-align: center; font-family: sans-serif;">Rebooting...</h1>'
|
93 |
+
document.body.innerHTML = '';
|
94 |
+
document.body.appendChild(pageInfo);
|
95 |
+
}
|
96 |
|
97 |
/* NOTE: These reload functions are not used in the current version of the code.
|
98 |
* From stable-diffusion-webui
|