🐛 fix: Ensure Default ModelSpecs Are Set Correctly (#5218)

* 🐛 fix: default modelSpecs not being set

* feat: Add imageDetail parameter for OpenAI endpoints in tQueryParamsSchema

* feat: Implement processModelSpecs function to enhance model specs processing from configuration

* feat: Refactor configuration schemas and types for improved structure and clarity

* feat: Add append_current_datetime parameter to tQueryParamsSchema for enhanced endpoint functionality

* fix: Add endpointType to getSaveOptions and enhance endpoint handling in Settings component

* fix: Change endpointType to be nullable and optional in tConversationSchema for improved flexibility

* fix: allow save & submit for google endpoint
This commit is contained in:
Danny Avila 2025-01-08 21:57:00 -05:00 committed by GitHub
parent 916faf6447
commit 69a9b8b911
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 201 additions and 148 deletions

View file

@ -4,7 +4,6 @@ import { useRecoilState, useSetRecoilState } from 'recoil';
import { LocalStorageKeys } from 'librechat-data-provider';
import { useAvailablePluginsQuery } from 'librechat-data-provider/react-query';
import type { TStartupConfig, TPlugin, TUser } from 'librechat-data-provider';
import { data as modelSpecs } from '~/components/Chat/Menus/Models/fakeData';
import { mapPlugins, selectPlugins, processPlugins } from '~/utils';
import useConfigOverride from './useConfigOverride';
import store from '~/store';
@ -36,18 +35,22 @@ export default function useAppStartup({
/** Set the app title */
useEffect(() => {
if (startupConfig?.appTitle) {
document.title = startupConfig.appTitle;
localStorage.setItem(LocalStorageKeys.APP_TITLE, startupConfig.appTitle);
const appTitle = startupConfig?.appTitle ?? '';
if (!appTitle) {
return;
}
document.title = appTitle;
localStorage.setItem(LocalStorageKeys.APP_TITLE, appTitle);
}, [startupConfig]);
/** Set the default spec's preset as default */
useEffect(() => {
if (defaultPreset && defaultPreset.spec) {
if (defaultPreset && defaultPreset.spec != null) {
return;
}
const modelSpecs = startupConfig?.modelSpecs?.list;
if (!modelSpecs || !modelSpecs.length) {
return;
}
@ -63,7 +66,7 @@ export default function useAppStartup({
iconURL: defaultSpec.iconURL,
spec: defaultSpec.name,
});
}, [defaultPreset, setDefaultPreset]);
}, [defaultPreset, setDefaultPreset, startupConfig?.modelSpecs?.list]);
/** Set the available Plugins */
useEffect(() => {
@ -75,17 +78,20 @@ export default function useAppStartup({
return;
}
if (!user.plugins || user.plugins.length === 0) {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
const userPlugins = user.plugins ?? [];
if (userPlugins.length === 0) {
setAvailableTools({ pluginStore });
return;
}
const tools = [...user.plugins]
const tools = [...userPlugins]
.map((el) => allPlugins.map[el])
.filter((el): el is TPlugin => el !== undefined);
.filter((el: TPlugin | undefined): el is TPlugin => el !== undefined);
/* Filter Last Selected Tools */
const localStorageItem = localStorage.getItem(LocalStorageKeys.LAST_TOOLS);
const localStorageItem = localStorage.getItem(LocalStorageKeys.LAST_TOOLS) ?? '';
if (!localStorageItem) {
return setAvailableTools({ pluginStore, ...mapPlugins(tools) });
}
@ -94,7 +100,7 @@ export default function useAppStartup({
.filter((tool: TPlugin) =>
tools.some((existingTool) => existingTool.pluginKey === tool.pluginKey),
)
.filter((tool: TPlugin) => !!tool);
.filter((tool: TPlugin | undefined) => !!tool);
localStorage.setItem(LocalStorageKeys.LAST_TOOLS, JSON.stringify(filteredTools));
setAvailableTools({ pluginStore, ...mapPlugins(tools) });