Merge branch 'release' of https://github.com/SillyTavern/SillyTavern into release

This commit is contained in:
Cohee 2023-09-19 14:08:57 +03:00
commit 3d4054f10e
3 changed files with 42 additions and 28 deletions

View File

@ -73,6 +73,7 @@
"#@markdown Enables ChromaDB for Infinity Context plugin\n", "#@markdown Enables ChromaDB for Infinity Context plugin\n",
"\n", "\n",
"import subprocess\n", "import subprocess\n",
"import secrets\n",
"\n", "\n",
"# ---\n", "# ---\n",
"# SillyTavern extras\n", "# SillyTavern extras\n",
@ -131,6 +132,13 @@
"!wget https://github.com/cloudflare/cloudflared/releases/download/2023.5.0/cloudflared-linux-amd64 -O /tmp/cloudflared-linux-amd64\n", "!wget https://github.com/cloudflare/cloudflared/releases/download/2023.5.0/cloudflared-linux-amd64 -O /tmp/cloudflared-linux-amd64\n",
"!chmod +x /tmp/cloudflared-linux-amd64\n", "!chmod +x /tmp/cloudflared-linux-amd64\n",
"\n", "\n",
"# Generate a random API key\n",
"api_key = secrets.token_hex(5)\n",
"\n",
"# Write the API key to api_key.txt\n",
"with open('./api_key.txt', 'w') as f:\n",
" f.write(api_key)\n",
"print(f\"API Key generated: {api_key}\")\n",
"\n", "\n",
"cmd = f\"python server.py {' '.join(params)}\"\n", "cmd = f\"python server.py {' '.join(params)}\"\n",
"print(cmd)\n", "print(cmd)\n",

View File

@ -5172,39 +5172,46 @@ export async function getChatsFromFiles(data, isGroupChat) {
let chat_dict = {}; let chat_dict = {};
let chat_list = Object.values(data).sort((a, b) => a["file_name"].localeCompare(b["file_name"])).reverse(); let chat_list = Object.values(data).sort((a, b) => a["file_name"].localeCompare(b["file_name"])).reverse();
for (const { file_name } of chat_list) { let chat_promise = chat_list.map(({ file_name}) => {
try { return new Promise(async (res, rej) => {
const endpoint = isGroupChat ? '/getgroupchat' : '/getchat'; try {
const requestBody = isGroupChat const endpoint = isGroupChat ? '/getgroupchat' : '/getchat';
? JSON.stringify({ id: file_name }) const requestBody = isGroupChat
: JSON.stringify({ ? JSON.stringify({ id: file_name })
ch_name: characters[context.characterId].name, : JSON.stringify({
file_name: file_name.replace('.jsonl', ''), ch_name: characters[context.characterId].name,
avatar_url: characters[context.characterId].avatar file_name: file_name.replace('.jsonl', ''),
avatar_url: characters[context.characterId].avatar
});
const chatResponse = await fetch(endpoint, {
method: 'POST',
headers: getRequestHeaders(),
body: requestBody,
cache: 'no-cache',
}); });
const chatResponse = await fetch(endpoint, { if (!chatResponse.ok) {
method: 'POST', return res();
headers: getRequestHeaders(), // continue;
body: requestBody, }
cache: 'no-cache',
});
if (!chatResponse.ok) { const currentChat = await chatResponse.json();
continue; if (!isGroupChat) {
// remove the first message, which is metadata, only for individual chats
currentChat.shift();
}
chat_dict[file_name] = currentChat;
} catch (error) {
console.error(error);
} }
const currentChat = await chatResponse.json(); return res();
if (!isGroupChat) { })
// remove the first message, which is metadata, only for individual chats })
currentChat.shift();
}
chat_dict[file_name] = currentChat;
} catch (error) { await Promise.all(chat_promise)
console.error(error);
}
}
return chat_dict; return chat_dict;
} }

View File

@ -192,7 +192,6 @@ async function doExtrasFetch(endpoint, args) {
} }
Object.assign(args.headers, { Object.assign(args.headers, {
'Authorization': `Bearer ${extension_settings.apiKey}`, 'Authorization': `Bearer ${extension_settings.apiKey}`,
'Bypass-Tunnel-Reminder': 'bypass'
}); });
const response = await fetch(endpoint, args); const response = await fetch(endpoint, args);