mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
💽 refactor(client): Optimize ModelsConfig Query Cache (#2330)
* refactor(client): remove double caching of models via recoil to rely exclusively on react-query * chore(useConversation): add modelsQuery.data dep to callback
This commit is contained in:
parent
fb80af05be
commit
f6a84887e1
11 changed files with 76 additions and 94 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import { useRecoilValue } from 'recoil';
|
||||
import { SettingsViews } from 'librechat-data-provider';
|
||||
import { useGetModelsQuery } from 'librechat-data-provider/react-query';
|
||||
import type { TSettingsProps } from '~/common';
|
||||
import { getSettings } from './Settings';
|
||||
import { cn } from '~/utils';
|
||||
|
|
@ -12,7 +13,7 @@ export default function Settings({
|
|||
className = '',
|
||||
isMultiChat = false,
|
||||
}: TSettingsProps & { isMultiChat?: boolean }) {
|
||||
const modelsConfig = useRecoilValue(store.modelsConfig);
|
||||
const modelsQuery = useGetModelsQuery();
|
||||
const currentSettingsView = useRecoilValue(store.currentSettingsView);
|
||||
if (!conversation?.endpoint || currentSettingsView !== SettingsViews.default) {
|
||||
return null;
|
||||
|
|
@ -20,7 +21,7 @@ export default function Settings({
|
|||
|
||||
const { settings, multiViewSettings } = getSettings(isMultiChat);
|
||||
const { endpoint: _endpoint, endpointType } = conversation;
|
||||
const models = modelsConfig?.[_endpoint] ?? [];
|
||||
const models = modelsQuery?.data?.[_endpoint] ?? [];
|
||||
const endpoint = endpointType ?? _endpoint;
|
||||
const OptionComponent = settings[endpoint];
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
import { useRecoilValue } from 'recoil';
|
||||
import type { TConversation } from 'librechat-data-provider';
|
||||
import type { TSetOption } from '~/common';
|
||||
import { options, multiChatOptions } from './options';
|
||||
import store from '~/store';
|
||||
import { useGetModelsQuery } from 'librechat-data-provider/react-query';
|
||||
|
||||
type TGoogleProps = {
|
||||
showExamples: boolean;
|
||||
|
|
@ -23,13 +22,14 @@ export default function ModelSelect({
|
|||
isMultiChat = false,
|
||||
showAbove = true,
|
||||
}: TSelectProps) {
|
||||
const modelsConfig = useRecoilValue(store.modelsConfig);
|
||||
const modelsQuery = useGetModelsQuery();
|
||||
|
||||
if (!conversation?.endpoint) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const { endpoint: _endpoint, endpointType } = conversation;
|
||||
const models = modelsConfig?.[_endpoint] ?? [];
|
||||
const models = modelsQuery?.data?.[_endpoint] ?? [];
|
||||
const endpoint = endpointType ?? _endpoint;
|
||||
|
||||
const OptionComponent = isMultiChat ? multiChatOptions[endpoint] : options[endpoint];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue