File size: 1,323 Bytes
9705b6c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
import React from 'react';
import OpenAI from './OpenAI';
import BingAI from './BingAI';
import Google from './Google';
import Plugins from './Plugins';
import ChatGPT from './ChatGPT';
import Anthropic from './Anthropic';
import { useRecoilValue } from 'recoil';
import type { TConversation } from 'librechat-data-provider';
import type { TSetOption, TModelSelectProps } from '~/common';
import store from '~/store';
type TGoogleProps = {
showExamples: boolean;
isCodeChat: boolean;
};
type TSelectProps = {
conversation: TConversation | null;
setOption: TSetOption;
extraProps?: TGoogleProps;
};
const optionComponents: { [key: string]: React.FC<TModelSelectProps> } = {
openAI: OpenAI,
azureOpenAI: OpenAI,
bingAI: BingAI,
google: Google,
gptPlugins: Plugins,
anthropic: Anthropic,
chatGPTBrowser: ChatGPT,
};
export default function ModelSelect({ conversation, setOption }: TSelectProps) {
const modelsConfig = useRecoilValue(store.modelsConfig);
if (!conversation?.endpoint) {
return null;
}
const { endpoint } = conversation;
const OptionComponent = optionComponents[endpoint];
const models = modelsConfig?.[endpoint] ?? [];
if (!OptionComponent) {
return null;
}
return <OptionComponent conversation={conversation} setOption={setOption} models={models} />;
}
|