mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
* chore: update package version to 0.7.416 * chore: Update Role.js imports order * refactor: move updateTagsInConvo to tags route, add RBAC for tags * refactor: add updateTagsInConvoOptions * fix: loading state for bookmark form * refactor: update primaryText class in TitleButton component * refactor: remove duplicate bookmarks and theming * refactor: update EditIcon component to use React.forwardRef * refactor: add _id field to tConversationTagSchema * refactor: remove promises * refactor: move mutation logic from BookmarkForm -> BookmarkEditDialog * refactor: update button class in BookmarkForm component * fix: conversation mutations and add better logging to useConversationTagMutation * refactor: update logger message in BookmarkEditDialog component * refactor: improve UI consistency in BookmarkNav and NewChat components * refactor: update logger message in BookmarkEditDialog component * refactor: Add tags prop to BookmarkForm component * refactor: Update BookmarkForm to avoid tag mutation if the tag already exists; also close dialog on submission programmatically * refactor: general role helper function to support updating access permissions for different permission types * refactor: Update getLatestText function to handle undefined values in message.content * refactor: Update useHasAccess hook to handle null role values for authenticated users * feat: toggle bookmarks access * refactor: Update PromptsCommand to handle access permissions for prompts * feat: updateConversationSelector * refactor: rename `vars` to `tagToDelete` for clarity * fix: prevent recreation of deleted tags in BookmarkMenu on Item Click * ci: mock updateBookmarksAccess function * ci: mock updateBookmarksAccess function
83 lines
3.8 KiB
JavaScript
83 lines
3.8 KiB
JavaScript
const { SystemRoles, Permissions, removeNullishValues } = require('librechat-data-provider');
|
|
const { updatePromptsAccess, updateBookmarksAccess } = require('~/models/Role');
|
|
const { logger } = require('~/config');
|
|
|
|
/**
|
|
* Loads the default interface object.
|
|
* @param {TCustomConfig | undefined} config - The loaded custom configuration.
|
|
* @param {TConfigDefaults} configDefaults - The custom configuration default values.
|
|
* @param {SystemRoles} [roleName] - The role to load the default interface for, defaults to `'USER'`.
|
|
* @returns {Promise<TCustomConfig['interface']>} The default interface object.
|
|
*/
|
|
async function loadDefaultInterface(config, configDefaults, roleName = SystemRoles.USER) {
|
|
const { interface: interfaceConfig } = config ?? {};
|
|
const { interface: defaults } = configDefaults;
|
|
const hasModelSpecs = config?.modelSpecs?.list?.length > 0;
|
|
|
|
/** @type {TCustomConfig['interface']} */
|
|
const loadedInterface = removeNullishValues({
|
|
endpointsMenu:
|
|
interfaceConfig?.endpointsMenu ?? (hasModelSpecs ? false : defaults.endpointsMenu),
|
|
modelSelect: interfaceConfig?.modelSelect ?? (hasModelSpecs ? false : defaults.modelSelect),
|
|
parameters: interfaceConfig?.parameters ?? (hasModelSpecs ? false : defaults.parameters),
|
|
presets: interfaceConfig?.presets ?? (hasModelSpecs ? false : defaults.presets),
|
|
sidePanel: interfaceConfig?.sidePanel ?? defaults.sidePanel,
|
|
privacyPolicy: interfaceConfig?.privacyPolicy ?? defaults.privacyPolicy,
|
|
termsOfService: interfaceConfig?.termsOfService ?? defaults.termsOfService,
|
|
bookmarks: interfaceConfig?.bookmarks ?? defaults.bookmarks,
|
|
prompts: interfaceConfig?.prompts ?? defaults.prompts,
|
|
});
|
|
|
|
await updatePromptsAccess(roleName, { [Permissions.USE]: loadedInterface.prompts });
|
|
await updateBookmarksAccess(roleName, { [Permissions.USE]: loadedInterface.bookmarks });
|
|
|
|
let i = 0;
|
|
const logSettings = () => {
|
|
// log interface object and model specs object (without list) for reference
|
|
logger.warn(`\`interface\` settings:\n${JSON.stringify(loadedInterface, null, 2)}`);
|
|
logger.warn(
|
|
`\`modelSpecs\` settings:\n${JSON.stringify(
|
|
{ ...(config?.modelSpecs ?? {}), list: undefined },
|
|
null,
|
|
2,
|
|
)}`,
|
|
);
|
|
};
|
|
|
|
// warn about config.modelSpecs.prioritize if true and presets are enabled, that default presets will conflict with prioritizing model specs.
|
|
if (config?.modelSpecs?.prioritize && loadedInterface.presets) {
|
|
logger.warn(
|
|
'Note: Prioritizing model specs can conflict with default presets if a default preset is set. It\'s recommended to disable presets from the interface or disable use of a default preset.',
|
|
);
|
|
i === 0 && i++;
|
|
}
|
|
|
|
// warn about config.modelSpecs.enforce if true and if any of these, endpointsMenu, modelSelect, presets, or parameters are enabled, that enforcing model specs can conflict with these options.
|
|
if (
|
|
config?.modelSpecs?.enforce &&
|
|
(loadedInterface.endpointsMenu ||
|
|
loadedInterface.modelSelect ||
|
|
loadedInterface.presets ||
|
|
loadedInterface.parameters)
|
|
) {
|
|
logger.warn(
|
|
'Note: Enforcing model specs can conflict with the interface options: endpointsMenu, modelSelect, presets, and parameters. It\'s recommended to disable these options from the interface or disable enforcing model specs.',
|
|
);
|
|
i === 0 && i++;
|
|
}
|
|
// warn if enforce is true and prioritize is not, that enforcing model specs without prioritizing them can lead to unexpected behavior.
|
|
if (config?.modelSpecs?.enforce && !config?.modelSpecs?.prioritize) {
|
|
logger.warn(
|
|
'Note: Enforcing model specs without prioritizing them can lead to unexpected behavior. It\'s recommended to enable prioritizing model specs if enforcing them.',
|
|
);
|
|
i === 0 && i++;
|
|
}
|
|
|
|
if (i > 0) {
|
|
logSettings();
|
|
}
|
|
|
|
return loadedInterface;
|
|
}
|
|
|
|
module.exports = { loadDefaultInterface };
|