Load sysprompts from content manager

This commit is contained in:
Cohee 2024-09-17 10:38:14 +00:00
parent b377a2b7d3
commit 73ee869749
4 changed files with 9 additions and 1 deletions

View File

@ -43,6 +43,7 @@ const CONTENT_TYPES = {
CONTEXT: 'context',
MOVING_UI: 'moving_ui',
QUICK_REPLIES: 'quick_replies',
SYSPROMPT: 'sysprompt',
};
/**
@ -56,7 +57,7 @@ function getDefaultPresets(directories) {
const presets = [];
for (const contentItem of contentIndex) {
if (contentItem.type.endsWith('_preset') || contentItem.type === 'instruct' || contentItem.type === 'context') {
if (contentItem.type.endsWith('_preset') || contentItem.type === 'instruct' || contentItem.type === 'context' || contentItem.type === 'sysprompt') {
contentItem.name = path.parse(contentItem.filename).name;
contentItem.folder = getTargetByType(contentItem.type, directories);
presets.push(contentItem);
@ -257,6 +258,8 @@ function getTargetByType(type, directories) {
return directories.movingUI;
case CONTENT_TYPES.QUICK_REPLIES:
return directories.quickreplies;
case CONTENT_TYPES.SYSPROMPT:
return directories.sysprompt;
default:
return null;
}

View File

@ -27,6 +27,8 @@ function getPresetSettingsByAPI(apiId, directories) {
return { folder: directories.instruct, extension: '.json' };
case 'context':
return { folder: directories.context, extension: '.json' };
case 'sysprompt':
return { folder: directories.sysprompt, extension: '.json' };
default:
return { folder: null, extension: null };
}

View File

@ -251,6 +251,7 @@ router.post('/get', jsonParser, (request, response) => {
const instruct = readAndParseFromDirectory(request.user.directories.instruct);
const context = readAndParseFromDirectory(request.user.directories.context);
const sysprompt = readAndParseFromDirectory(request.user.directories.sysprompt);
response.send({
settings,
@ -268,6 +269,7 @@ router.post('/get', jsonParser, (request, response) => {
quickReplyPresets,
instruct,
context,
sysprompt,
enable_extensions: ENABLE_EXTENSIONS,
enable_extensions_auto_update: ENABLE_EXTENSIONS_AUTO_UPDATE,
enable_accounts: ENABLE_ACCOUNTS,

View File

@ -82,6 +82,7 @@ const STORAGE_KEYS = {
* @property {string} files - The directory where the uploaded files are stored
* @property {string} vectors - The directory where the vectors are stored
* @property {string} backups - The directory where the backups are stored
* @property {string} sysprompt - The directory where the system prompt data is stored
*/
/**