mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-22 18:26:12 +01:00
31 lines
953 B
TypeScript
31 lines
953 B
TypeScript
|
|
import { useRecoilValue } from 'recoil';
|
||
|
|
import type { TConversation, TPreset } from 'librechat-data-provider';
|
||
|
|
import { getDefaultEndpoint, buildDefaultConvo } from '~/utils';
|
||
|
|
import store from '~/store';
|
||
|
|
|
||
|
|
type TDefaultConvo = { conversation: Partial<TConversation>; preset?: Partial<TPreset> | null };
|
||
|
|
|
||
|
|
const useDefaultConvo = () => {
|
||
|
|
const endpointsConfig = useRecoilValue(store.endpointsConfig);
|
||
|
|
const modelsConfig = useRecoilValue(store.modelsConfig);
|
||
|
|
|
||
|
|
const getDefaultConversation = ({ conversation, preset }: TDefaultConvo) => {
|
||
|
|
const endpoint = getDefaultEndpoint({
|
||
|
|
convoSetup: preset as TPreset,
|
||
|
|
endpointsConfig,
|
||
|
|
});
|
||
|
|
const models = modelsConfig?.[endpoint] || [];
|
||
|
|
|
||
|
|
return buildDefaultConvo({
|
||
|
|
conversation: conversation as TConversation,
|
||
|
|
endpoint,
|
||
|
|
lastConversationSetup: preset as TConversation,
|
||
|
|
models,
|
||
|
|
});
|
||
|
|
};
|
||
|
|
|
||
|
|
return getDefaultConversation;
|
||
|
|
};
|
||
|
|
|
||
|
|
export default useDefaultConvo;
|