2024-04-06 19:09:39 +02:00
|
|
|
const PUBLIC_DIRECTORIES = {
|
2023-09-16 15:16:48 +02:00
|
|
|
images: 'public/img/',
|
|
|
|
backups: 'backups/',
|
2023-12-03 14:07:21 +01:00
|
|
|
sounds: 'public/sounds',
|
2024-04-07 00:47:07 +02:00
|
|
|
extensions: 'public/scripts/extensions',
|
2023-09-16 15:16:48 +02:00
|
|
|
};
|
|
|
|
|
2024-04-07 16:44:40 +02:00
|
|
|
const DEFAULT_AVATAR = '/img/ai4.png';
|
|
|
|
|
2024-04-06 19:09:39 +02:00
|
|
|
/**
|
|
|
|
* @type {import('./users').UserDirectoryList}
|
|
|
|
* @readonly
|
|
|
|
* @enum {string}
|
|
|
|
*/
|
|
|
|
const USER_DIRECTORY_TEMPLATE = Object.freeze({
|
|
|
|
root: '',
|
|
|
|
thumbnails: 'thumbnails',
|
|
|
|
thumbnailsBg: 'thumbnails/bg',
|
|
|
|
thumbnailsAvatar: 'thumbnails/avatar',
|
|
|
|
worlds: 'worlds',
|
|
|
|
user: 'user',
|
|
|
|
avatars: 'User Avatars',
|
|
|
|
userImages: 'user/images',
|
|
|
|
groups: 'groups',
|
|
|
|
groupChats: 'group chats',
|
|
|
|
chats: 'chats',
|
|
|
|
characters: 'characters',
|
|
|
|
backgrounds: 'backgrounds',
|
|
|
|
novelAI_Settings: 'NovelAI Settings',
|
|
|
|
koboldAI_Settings: 'KoboldAI Settings',
|
|
|
|
openAI_Settings: 'OpenAI Settings',
|
|
|
|
textGen_Settings: 'TextGen Settings',
|
|
|
|
themes: 'themes',
|
|
|
|
movingUI: 'movingUI',
|
2024-04-07 00:47:07 +02:00
|
|
|
extensions: 'extensions',
|
2024-04-06 19:09:39 +02:00
|
|
|
instruct: 'instruct',
|
|
|
|
context: 'context',
|
|
|
|
quickreplies: 'QuickReplies',
|
|
|
|
assets: 'assets',
|
|
|
|
comfyWorkflows: 'user/workflows',
|
|
|
|
files: 'user/files',
|
2024-04-07 00:47:07 +02:00
|
|
|
vectors: 'vectors',
|
2024-04-06 19:09:39 +02:00
|
|
|
});
|
|
|
|
|
2024-04-07 15:41:23 +02:00
|
|
|
/**
|
|
|
|
* @type {import('./users').User}
|
|
|
|
* @readonly
|
|
|
|
*/
|
2024-04-06 19:09:39 +02:00
|
|
|
const DEFAULT_USER = Object.freeze({
|
|
|
|
uuid: '00000000-0000-0000-0000-000000000000',
|
|
|
|
handle: 'user0',
|
|
|
|
name: 'User',
|
|
|
|
created: 0,
|
|
|
|
password: '',
|
2024-04-07 15:41:23 +02:00
|
|
|
admin: true,
|
|
|
|
enabled: true,
|
2024-04-07 16:44:40 +02:00
|
|
|
salt: '',
|
2024-04-06 19:09:39 +02:00
|
|
|
});
|
|
|
|
|
2023-09-16 15:39:07 +02:00
|
|
|
const UNSAFE_EXTENSIONS = [
|
2023-12-02 19:04:51 +01:00
|
|
|
'.php',
|
|
|
|
'.exe',
|
|
|
|
'.com',
|
|
|
|
'.dll',
|
|
|
|
'.pif',
|
|
|
|
'.application',
|
|
|
|
'.gadget',
|
|
|
|
'.msi',
|
|
|
|
'.jar',
|
|
|
|
'.cmd',
|
|
|
|
'.bat',
|
|
|
|
'.reg',
|
|
|
|
'.sh',
|
|
|
|
'.py',
|
|
|
|
'.js',
|
|
|
|
'.jse',
|
|
|
|
'.jsp',
|
|
|
|
'.pdf',
|
|
|
|
'.html',
|
|
|
|
'.htm',
|
|
|
|
'.hta',
|
|
|
|
'.vb',
|
|
|
|
'.vbs',
|
|
|
|
'.vbe',
|
|
|
|
'.cpl',
|
|
|
|
'.msc',
|
|
|
|
'.scr',
|
|
|
|
'.sql',
|
|
|
|
'.iso',
|
|
|
|
'.img',
|
|
|
|
'.dmg',
|
|
|
|
'.ps1',
|
|
|
|
'.ps1xml',
|
|
|
|
'.ps2',
|
|
|
|
'.ps2xml',
|
|
|
|
'.psc1',
|
|
|
|
'.psc2',
|
|
|
|
'.msh',
|
|
|
|
'.msh1',
|
|
|
|
'.msh2',
|
|
|
|
'.mshxml',
|
|
|
|
'.msh1xml',
|
|
|
|
'.msh2xml',
|
|
|
|
'.scf',
|
|
|
|
'.lnk',
|
|
|
|
'.inf',
|
|
|
|
'.reg',
|
|
|
|
'.doc',
|
|
|
|
'.docm',
|
|
|
|
'.docx',
|
|
|
|
'.dot',
|
|
|
|
'.dotm',
|
|
|
|
'.dotx',
|
|
|
|
'.xls',
|
|
|
|
'.xlsm',
|
|
|
|
'.xlsx',
|
|
|
|
'.xlt',
|
|
|
|
'.xltm',
|
|
|
|
'.xltx',
|
|
|
|
'.xlam',
|
|
|
|
'.ppt',
|
|
|
|
'.pptm',
|
|
|
|
'.pptx',
|
|
|
|
'.pot',
|
|
|
|
'.potm',
|
|
|
|
'.potx',
|
|
|
|
'.ppam',
|
|
|
|
'.ppsx',
|
|
|
|
'.ppsm',
|
|
|
|
'.pps',
|
|
|
|
'.ppam',
|
|
|
|
'.sldx',
|
|
|
|
'.sldm',
|
|
|
|
'.ws',
|
2023-09-16 15:39:07 +02:00
|
|
|
];
|
|
|
|
|
2023-12-14 21:18:34 +01:00
|
|
|
const GEMINI_SAFETY = [
|
2023-09-23 19:48:56 +02:00
|
|
|
{
|
2023-12-14 06:49:50 +01:00
|
|
|
category: 'HARM_CATEGORY_HARASSMENT',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
2023-09-23 19:48:56 +02:00
|
|
|
},
|
|
|
|
{
|
2023-12-14 06:49:50 +01:00
|
|
|
category: 'HARM_CATEGORY_HATE_SPEECH',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
2023-09-23 19:48:56 +02:00
|
|
|
},
|
|
|
|
{
|
2023-12-14 06:49:50 +01:00
|
|
|
category: 'HARM_CATEGORY_SEXUALLY_EXPLICIT',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
2023-09-23 19:48:56 +02:00
|
|
|
},
|
|
|
|
{
|
2023-12-14 06:49:50 +01:00
|
|
|
category: 'HARM_CATEGORY_DANGEROUS_CONTENT',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
|
|
|
},
|
2023-09-23 19:48:56 +02:00
|
|
|
];
|
|
|
|
|
2023-12-14 21:18:34 +01:00
|
|
|
const BISON_SAFETY = [
|
2023-09-23 19:48:56 +02:00
|
|
|
{
|
2023-12-02 19:04:51 +01:00
|
|
|
category: 'HARM_CATEGORY_DEROGATORY',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
2023-09-23 19:48:56 +02:00
|
|
|
},
|
|
|
|
{
|
2023-12-02 19:04:51 +01:00
|
|
|
category: 'HARM_CATEGORY_TOXICITY',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
2023-09-23 19:48:56 +02:00
|
|
|
},
|
|
|
|
{
|
2023-12-02 19:04:51 +01:00
|
|
|
category: 'HARM_CATEGORY_VIOLENCE',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
2023-09-23 19:48:56 +02:00
|
|
|
},
|
|
|
|
{
|
2023-12-02 19:04:51 +01:00
|
|
|
category: 'HARM_CATEGORY_SEXUAL',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
2023-09-23 19:48:56 +02:00
|
|
|
},
|
|
|
|
{
|
2023-12-02 19:04:51 +01:00
|
|
|
category: 'HARM_CATEGORY_MEDICAL',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
2023-09-23 19:48:56 +02:00
|
|
|
},
|
|
|
|
{
|
2023-12-02 19:04:51 +01:00
|
|
|
category: 'HARM_CATEGORY_DANGEROUS',
|
2023-12-02 21:06:57 +01:00
|
|
|
threshold: 'BLOCK_NONE',
|
|
|
|
},
|
2023-09-23 19:48:56 +02:00
|
|
|
];
|
|
|
|
|
2023-12-03 21:03:32 +01:00
|
|
|
const CHAT_COMPLETION_SOURCES = {
|
|
|
|
OPENAI: 'openai',
|
|
|
|
WINDOWAI: 'windowai',
|
|
|
|
CLAUDE: 'claude',
|
|
|
|
SCALE: 'scale',
|
|
|
|
OPENROUTER: 'openrouter',
|
|
|
|
AI21: 'ai21',
|
2023-12-14 06:49:50 +01:00
|
|
|
MAKERSUITE: 'makersuite',
|
2023-12-15 22:15:57 +01:00
|
|
|
MISTRALAI: 'mistralai',
|
2023-12-20 17:29:03 +01:00
|
|
|
CUSTOM: 'custom',
|
2024-04-01 23:20:17 +02:00
|
|
|
COHERE: 'cohere',
|
2023-12-03 21:03:32 +01:00
|
|
|
};
|
|
|
|
|
2023-09-16 16:28:28 +02:00
|
|
|
const UPLOADS_PATH = './uploads';
|
|
|
|
|
2023-12-03 21:00:25 +01:00
|
|
|
// TODO: this is copied from the client code; there should be a way to de-duplicate it eventually
|
|
|
|
const TEXTGEN_TYPES = {
|
|
|
|
OOBA: 'ooba',
|
|
|
|
MANCER: 'mancer',
|
|
|
|
APHRODITE: 'aphrodite',
|
|
|
|
TABBY: 'tabby',
|
|
|
|
KOBOLDCPP: 'koboldcpp',
|
2023-12-17 22:38:03 +01:00
|
|
|
TOGETHERAI: 'togetherai',
|
2023-12-18 21:38:28 +01:00
|
|
|
LLAMACPP: 'llamacpp',
|
2023-12-19 15:38:11 +01:00
|
|
|
OLLAMA: 'ollama',
|
2024-01-24 13:59:27 +01:00
|
|
|
INFERMATICAI: 'infermaticai',
|
2024-03-07 10:55:08 +01:00
|
|
|
DREAMGEN: 'dreamgen',
|
2024-02-25 21:47:07 +01:00
|
|
|
OPENROUTER: 'openrouter',
|
2023-12-03 21:00:25 +01:00
|
|
|
};
|
|
|
|
|
2024-01-24 13:59:27 +01:00
|
|
|
const INFERMATICAI_KEYS = [
|
|
|
|
'model',
|
2024-02-19 16:53:26 +01:00
|
|
|
'prompt',
|
2024-01-24 13:59:27 +01:00
|
|
|
'max_tokens',
|
|
|
|
'temperature',
|
2024-02-19 16:53:26 +01:00
|
|
|
'top_p',
|
|
|
|
'top_k',
|
2024-01-24 13:59:27 +01:00
|
|
|
'repetition_penalty',
|
|
|
|
'stream',
|
2024-02-19 16:53:26 +01:00
|
|
|
'stop',
|
2024-01-24 13:59:27 +01:00
|
|
|
];
|
|
|
|
|
2024-03-07 10:55:08 +01:00
|
|
|
// https://dreamgen.com/docs/api#openai-text
|
|
|
|
const DREAMGEN_KEYS = [
|
|
|
|
'model',
|
|
|
|
'prompt',
|
|
|
|
'max_tokens',
|
|
|
|
'temperature',
|
|
|
|
'top_p',
|
|
|
|
'top_k',
|
|
|
|
'min_p',
|
|
|
|
'repetition_penalty',
|
|
|
|
'frequency_penalty',
|
|
|
|
'presence_penalty',
|
|
|
|
'stop',
|
2024-03-08 09:07:26 +01:00
|
|
|
'stream',
|
2024-03-17 13:07:33 +01:00
|
|
|
'minimum_message_content_tokens',
|
2024-03-07 10:55:08 +01:00
|
|
|
];
|
|
|
|
|
2023-12-17 22:38:03 +01:00
|
|
|
// https://docs.together.ai/reference/completions
|
|
|
|
const TOGETHERAI_KEYS = [
|
|
|
|
'model',
|
|
|
|
'prompt',
|
|
|
|
'max_tokens',
|
|
|
|
'temperature',
|
|
|
|
'top_p',
|
|
|
|
'top_k',
|
|
|
|
'repetition_penalty',
|
|
|
|
'stream',
|
2024-01-26 16:40:20 +01:00
|
|
|
'stop',
|
2023-12-17 22:38:03 +01:00
|
|
|
];
|
|
|
|
|
2023-12-19 15:38:11 +01:00
|
|
|
// https://github.com/jmorganca/ollama/blob/main/docs/api.md#request-with-options
|
|
|
|
const OLLAMA_KEYS = [
|
|
|
|
'num_predict',
|
|
|
|
'stop',
|
|
|
|
'temperature',
|
|
|
|
'repeat_penalty',
|
|
|
|
'presence_penalty',
|
|
|
|
'frequency_penalty',
|
|
|
|
'top_k',
|
|
|
|
'top_p',
|
|
|
|
'tfs_z',
|
|
|
|
'typical_p',
|
|
|
|
'seed',
|
|
|
|
'repeat_last_n',
|
|
|
|
'mirostat',
|
|
|
|
'mirostat_tau',
|
|
|
|
'mirostat_eta',
|
|
|
|
];
|
|
|
|
|
2023-12-04 13:56:42 +01:00
|
|
|
const AVATAR_WIDTH = 400;
|
|
|
|
const AVATAR_HEIGHT = 600;
|
|
|
|
|
2024-02-25 21:47:07 +01:00
|
|
|
const OPENROUTER_HEADERS = {
|
|
|
|
'HTTP-Referer': 'https://sillytavern.app',
|
|
|
|
'X-Title': 'SillyTavern',
|
|
|
|
};
|
|
|
|
|
|
|
|
const OPENROUTER_KEYS = [
|
|
|
|
'max_tokens',
|
|
|
|
'temperature',
|
|
|
|
'top_k',
|
|
|
|
'top_p',
|
|
|
|
'presence_penalty',
|
|
|
|
'frequency_penalty',
|
|
|
|
'repetition_penalty',
|
|
|
|
'min_p',
|
|
|
|
'top_a',
|
|
|
|
'seed',
|
|
|
|
'logit_bias',
|
|
|
|
'model',
|
|
|
|
'stream',
|
|
|
|
'prompt',
|
|
|
|
'stop',
|
|
|
|
];
|
|
|
|
|
2023-09-16 15:16:48 +02:00
|
|
|
module.exports = {
|
2024-04-06 19:09:39 +02:00
|
|
|
DEFAULT_USER,
|
2024-04-07 16:44:40 +02:00
|
|
|
DEFAULT_AVATAR,
|
2024-04-06 19:09:39 +02:00
|
|
|
PUBLIC_DIRECTORIES,
|
|
|
|
USER_DIRECTORY_TEMPLATE,
|
2023-09-16 15:39:07 +02:00
|
|
|
UNSAFE_EXTENSIONS,
|
2023-09-16 16:28:28 +02:00
|
|
|
UPLOADS_PATH,
|
2023-12-14 21:18:34 +01:00
|
|
|
GEMINI_SAFETY,
|
|
|
|
BISON_SAFETY,
|
2023-12-03 21:00:25 +01:00
|
|
|
TEXTGEN_TYPES,
|
2023-12-03 21:03:32 +01:00
|
|
|
CHAT_COMPLETION_SOURCES,
|
2023-12-04 13:56:42 +01:00
|
|
|
AVATAR_WIDTH,
|
|
|
|
AVATAR_HEIGHT,
|
2023-12-17 22:38:03 +01:00
|
|
|
TOGETHERAI_KEYS,
|
2023-12-19 15:38:11 +01:00
|
|
|
OLLAMA_KEYS,
|
2024-01-24 13:59:27 +01:00
|
|
|
INFERMATICAI_KEYS,
|
2024-03-07 10:55:08 +01:00
|
|
|
DREAMGEN_KEYS,
|
2024-02-25 21:47:07 +01:00
|
|
|
OPENROUTER_HEADERS,
|
|
|
|
OPENROUTER_KEYS,
|
2023-12-02 20:11:06 +01:00
|
|
|
};
|