2023-04-02 14:34:12 -04:00
|
|
|
import React, { useEffect } from 'react';
|
2023-04-05 02:46:22 +08:00
|
|
|
import { useRecoilState, useRecoilValue } from 'recoil';
|
2023-04-06 05:47:37 -07:00
|
|
|
import SelectDropDown from '../../ui/SelectDropDown';
|
2023-04-02 14:34:12 -04:00
|
|
|
import { cn } from '~/utils/';
|
|
|
|
|
|
|
|
|
|
import store from '~/store';
|
|
|
|
|
|
|
|
|
|
function ChatGPTOptions() {
|
|
|
|
|
const [conversation, setConversation] = useRecoilState(store.conversation) || {};
|
|
|
|
|
const { endpoint, conversationId } = conversation;
|
|
|
|
|
const { model } = conversation;
|
|
|
|
|
|
2023-04-05 02:46:22 +08:00
|
|
|
const endpointsConfig = useRecoilValue(store.endpointsConfig);
|
|
|
|
|
|
2023-04-02 14:34:12 -04:00
|
|
|
if (endpoint !== 'chatGPTBrowser') return null;
|
|
|
|
|
if (conversationId !== 'new') return null;
|
|
|
|
|
|
2023-04-05 02:46:22 +08:00
|
|
|
const models = endpointsConfig?.['chatGPTBrowser']?.['availableModels'] || [];
|
|
|
|
|
|
2023-04-02 14:34:12 -04:00
|
|
|
const setOption = param => newValue => {
|
|
|
|
|
let update = {};
|
|
|
|
|
update[param] = newValue;
|
|
|
|
|
setConversation(prevState => ({
|
|
|
|
|
...prevState,
|
|
|
|
|
...update
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const cardStyle =
|
|
|
|
|
'transition-colors shadow-md rounded-md min-w-[75px] font-normal bg-white border-black/10 hover:border-black/10 focus:border-black/10 dark:border-black/10 dark:hover:border-black/10 dark:focus:border-black/10 border dark:bg-gray-700 text-black dark:text-white';
|
|
|
|
|
|
|
|
|
|
return (
|
2023-04-05 16:27:11 +08:00
|
|
|
<div className="openAIOptions-simple-container show flex w-full flex-wrap items-center justify-center gap-2">
|
2023-04-06 05:47:37 -07:00
|
|
|
<SelectDropDown
|
2023-04-05 02:46:22 +08:00
|
|
|
value={model}
|
|
|
|
|
setValue={setOption('model')}
|
|
|
|
|
availableValues={models}
|
2023-04-02 14:34:12 -04:00
|
|
|
showAbove={true}
|
|
|
|
|
showLabel={false}
|
|
|
|
|
className={cn(
|
|
|
|
|
cardStyle,
|
2023-04-05 21:21:02 +08:00
|
|
|
'z-50 flex h-[40px] w-[260px] min-w-[260px] flex-none items-center justify-center px-4 ring-0 hover:cursor-pointer hover:bg-slate-50 focus:ring-0 focus:ring-offset-0 data-[state=open]:bg-slate-50 dark:bg-gray-700 dark:hover:bg-gray-600 dark:data-[state=open]:bg-gray-600'
|
2023-04-02 14:34:12 -04:00
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default ChatGPTOptions;
|