💽 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:
Danny Avila 2024-04-05 17:08:37 -04:00 committed by GitHub
parent fb80af05be
commit f6a84887e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 76 additions and 94 deletions

View file

@ -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];