Skip to content

Commit

Permalink
Merge branch 'xqdoo00o:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
zfgw1553 authored Jul 15, 2023
2 parents cbca683 + 97f0e19 commit 9b1c186
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,7 @@

#apiSelect {
position: absolute;
top: 36px;
top: 37px;
padding: 4px 0;
background: var(--chat-back);
width: 100%;
Expand Down Expand Up @@ -2335,7 +2335,7 @@
<div>
<label for="preSetSystem" data-i18n-key="presetRole"></label>
<select id="preSetSystem">
<option value="" data-i18n-key="default"></option>
<option value="default" data-i18n-key="default"></option>
<option value="normal" data-i18n-key="assistant"></option>
<option value="cat" data-i18n-key="cat"></option>
<option value="emoji" data-i18n-key="emoji"></option>
Expand Down Expand Up @@ -2935,6 +2935,7 @@
"cat": "Cat girl",
"emoji": "Emoji",
"withImg": "Image",
"defaultText": "",
"assistantText": "You are a helpful assistant, answer as concisely as possible.",
"catText": "You are a cute cat girl, you must end every sentence with 'meow'",
"emojiText": "Your personality is very lively, there must be at least one emoji icon in every sentence",
Expand Down Expand Up @@ -3087,6 +3088,7 @@
"cat": "猫娘",
"emoji": "表情",
"withImg": "有图",
"defaultText": "",
"assistantText": "你是一个乐于助人的助手,尽量简明扼要地回答",
"catText": "你是一个可爱的猫娘,每句话结尾都要带个'喵'",
"emojiText": "你的性格很活泼,每句话中都要有至少一个emoji图标",
Expand Down Expand Up @@ -3332,6 +3334,7 @@
const searchChatEle = document.getElementById("searchChat");
const voiceRecEle = document.getElementById("voiceRecIcon");
const voiceRecSetEle = document.getElementById("voiceRecSetting");
const preEle = document.getElementById("preSetSystem");
let voiceType = 1; // 设置 0: 提问语音,1:回答语音
let voiceRole = []; // 语音
let voiceTestText; // 测试语音文本
Expand Down Expand Up @@ -4180,6 +4183,7 @@
const API_URL = "v1/chat/completions";
let loading = false;
let presetRoleData = {
"default": translations[locale]["defaultText"],
"normal": translations[locale]["assistantText"],
"cat": translations[locale]["catText"],
"emoji": translations[locale]["emojiText"],
Expand Down Expand Up @@ -4438,6 +4442,7 @@
token.attrSet("onerror", "scrollToBottomLoad(this);this.removeAttribute('onload');this.removeAttribute('onerror')");
return slf.renderToken(tokens, idx, options)
}
let currentVoiceIdx;
let editingIdx;
let originText;
const resumeSend = () => {
Expand Down Expand Up @@ -4910,6 +4915,8 @@
};
const addNewChat = () => {
let chat = {name: translations[locale]["newChatName"], data: []};
if (presetRoleData.default) chat.data.unshift({role: "system", content: presetRoleData.default});
preEle.selectedIndex = 0;
chatsData.push(chat);
chatIdxs.push(chatsData.length - 1);
updateChats();
Expand Down Expand Up @@ -5096,11 +5103,9 @@
if (data[0] && data[0].role === "system") {
systemRole = data[0].content;
systemEle.value = systemRole;
localStorage.setItem("system", systemRole);
} else {
systemRole = "";
systemRole = void 0;
systemEle.value = "";
localStorage.setItem("system", systemRole);
}
chatlog.innerHTML = "";
if (systemRole ? data.length - 1 : data.length) {
Expand Down Expand Up @@ -5373,7 +5378,7 @@
if (val !== void 0) localStorage.setItem(key, val);
else localStorage.removeItem(key);
}
initSetting(true);
initSetting();
initVoiceVal();
speechServiceEle.dispatchEvent(new Event("change"));
initRecSetting();
Expand All @@ -5396,7 +5401,7 @@
let key = localSetKeys[i];
let val = localStorage.removeItem(key);
}
initSetting(true);
initSetting();
initVoiceVal();
speechServiceEle.dispatchEvent(new Event("change"));
initRecSetting();
Expand All @@ -5415,7 +5420,6 @@
if (currentVoiceIdx !== void 0) currentVoiceIdx += plus;
if (editingIdx !== void 0) editingIdx += plus;
}

const hotKeyVals = {};
const ctrlHotKeyEv = (ev) => {
if (ev.ctrlKey || ev.metaKey) {
Expand Down Expand Up @@ -5517,7 +5521,7 @@
initHotKey();
document.addEventListener("keydown", ctrlHotKeyEv);
document.addEventListener("keydown", ctrlAltHotKeyEv);
const initSetting = (force = false) => {
const initSetting = () => {
const modelEle = document.getElementById("preSetModel");
let localModel = localStorage.getItem("modelVersion");
modelVersion = modelEle.value = localModel || "gpt-3.5-turbo";
Expand Down Expand Up @@ -5638,20 +5642,13 @@
updateChats();
}
if (systemRole === void 0) {
if (localSystem) {
systemRole = localSystem;
systemEle.value = localSystem;
systemRole = systemEle.value = localSystem || presetRoleData.default || "";
if (systemRole) {
data.unshift({role: "system", content: systemRole});
processIdx(1);
updateChats();
} else {
systemRole = systemEle.value;
}
} else if (force) {
systemRole = systemEle.value = localSystem || systemEle.getAttribute("value") || "";
systemEle.dispatchEvent(new Event("change"));
}
const preEle = document.getElementById("preSetSystem");
preEle.onchange = () => {
let val = preEle.value;
if (val && presetRoleData[val]) {
Expand Down Expand Up @@ -5931,7 +5928,6 @@
return `wss://${azureRegion}.tts.speech.microsoft.com/cognitiveservices/websocket/v1?Authorization=bearer%20${azureToken}`
}
const edgeTTSURL = "wss://speech.platform.bing.com/consumer/speech/synthesize/readaloud/edge/v1?trustedclienttoken=6A5AA1D4EAFF4E9FB37E23D68491D6F4";
let currentVoiceIdx;
const resetSpeakIcon = () => {
if (currentVoiceIdx !== void 0) {
chatlog.children[systemRole ? currentVoiceIdx - 1 : currentVoiceIdx].classList.remove("showVoiceCls");
Expand Down Expand Up @@ -6766,7 +6762,6 @@
<link crossorigin="anonymous" href="//cdn.staticfile.org/KaTeX/0.16.7/katex.min.css" rel="stylesheet">
<link crossorigin="anonymous" href="//npm.elemecdn.com/[email protected]/css/texmath.css" rel="stylesheet">
<script defer>
const preEle = document.getElementById("preSetSystem");
let downRoleController = new AbortController();
const loadPrompt = () => {
downRoleController.abort();
Expand Down

0 comments on commit 9b1c186

Please sign in to comment.