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",
"\n",
"import subprocess\n",
"import secrets\n",
"\n",
"# ---\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",
"!chmod +x /tmp/cloudflared-linux-amd64\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",
"cmd = f\"python server.py {' '.join(params)}\"\n",
"print(cmd)\n",

View File

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

View File

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