mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-07 00:30:19 +01:00
* refactor(client): remove double caching of models via recoil to rely exclusively on react-query * chore(useConversation): add modelsQuery.data dep to callback
54 lines
1.6 KiB
TypeScript
54 lines
1.6 KiB
TypeScript
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';
|
|
import store from '~/store';
|
|
|
|
export default function Settings({
|
|
conversation,
|
|
setOption,
|
|
isPreset = false,
|
|
className = '',
|
|
isMultiChat = false,
|
|
}: TSettingsProps & { isMultiChat?: boolean }) {
|
|
const modelsQuery = useGetModelsQuery();
|
|
const currentSettingsView = useRecoilValue(store.currentSettingsView);
|
|
if (!conversation?.endpoint || currentSettingsView !== SettingsViews.default) {
|
|
return null;
|
|
}
|
|
|
|
const { settings, multiViewSettings } = getSettings(isMultiChat);
|
|
const { endpoint: _endpoint, endpointType } = conversation;
|
|
const models = modelsQuery?.data?.[_endpoint] ?? [];
|
|
const endpoint = endpointType ?? _endpoint;
|
|
const OptionComponent = settings[endpoint];
|
|
|
|
if (OptionComponent) {
|
|
return (
|
|
<div
|
|
className={cn('hide-scrollbar h-[500px] overflow-y-auto md:mb-2 md:h-[350px]', className)}
|
|
>
|
|
<OptionComponent
|
|
conversation={conversation}
|
|
setOption={setOption}
|
|
models={models}
|
|
isPreset={isPreset}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const MultiViewComponent = multiViewSettings[endpoint];
|
|
|
|
if (!MultiViewComponent) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div className={cn('hide-scrollbar h-[500px] overflow-y-auto md:mb-2 md:h-[350px]', className)}>
|
|
<MultiViewComponent conversation={conversation} models={models} isPreset={isPreset} />
|
|
</div>
|
|
);
|
|
}
|