refactor(client): Refactors recent typescript changes for best practices (#763)

* create common types in client

* remove unnecessary rules from eslint config

* cleanup types

* put back eslintrc rules
This commit is contained in:
Dan Orlando 2023-08-05 13:45:26 -07:00 committed by GitHub
parent 5828200197
commit 96d29f7390
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 233 additions and 245 deletions

View file

@ -1,8 +1,8 @@
import { SelectDropDown } from '~/components/ui';
import { cn, cardStyle } from '~/utils/';
import { ModelSelectProps } from 'librechat-data-provider';
import type { TModelSelectProps } from '~/common';
export default function Anthropic({ conversation, setOption, models }: ModelSelectProps) {
export default function Anthropic({ conversation, setOption, models }: TModelSelectProps) {
return (
<SelectDropDown
value={conversation?.model ?? ''}

View file

@ -1,10 +1,10 @@
import { useRecoilValue } from 'recoil';
import { SelectDropDown, Tabs, TabsList, TabsTrigger } from '~/components/ui';
import { cn, cardStyle } from '~/utils/';
import { ModelSelectProps } from 'librechat-data-provider';
import type { TModelSelectProps } from '~/common';
import store from '~/store';
export default function BingAI({ conversation, setOption, models }: ModelSelectProps) {
export default function BingAI({ conversation, setOption, models }: TModelSelectProps) {
const showBingToneSetting = useRecoilValue(store.showBingToneSetting);
if (!conversation) {
return null;

View file

@ -1,8 +1,8 @@
import { SelectDropDown } from '~/components/ui';
import { cn, cardStyle } from '~/utils/';
import { ModelSelectProps } from 'librechat-data-provider';
import type { TModelSelectProps } from '~/common';
export default function ChatGPT({ conversation, setOption, models }: ModelSelectProps) {
export default function ChatGPT({ conversation, setOption, models }: TModelSelectProps) {
if (!conversation) {
return null;
}

View file

@ -1,8 +1,8 @@
import { SelectDropDown } from '~/components/ui';
import { cn, cardStyle } from '~/utils/';
import { ModelSelectProps } from 'librechat-data-provider';
import type { TModelSelectProps } from '~/common';
export default function Google({ conversation, setOption, models }: ModelSelectProps) {
export default function Google({ conversation, setOption, models }: TModelSelectProps) {
return (
<SelectDropDown
value={conversation?.model ?? ''}

View file

@ -6,12 +6,22 @@ import Plugins from './Plugins';
import ChatGPT from './ChatGPT';
import Anthropic from './Anthropic';
import { useRecoilValue } from 'recoil';
import { SelectProps, ModelSelectProps } from 'librechat-data-provider';
import type { TConversation } from 'librechat-data-provider';
import type { TSetOption, TModelSelectProps } from '~/common';
import store from '~/store';
type OptionComponentType = React.FC<ModelSelectProps>;
type TGoogleProps = {
showExamples: boolean;
isCodeChat: boolean;
};
const optionComponents: { [key: string]: OptionComponentType } = {
type TSelectProps = {
conversation: TConversation | null;
setOption: TSetOption;
extraProps?: TGoogleProps;
};
const optionComponents: { [key: string]: React.FC<TModelSelectProps> } = {
openAI: OpenAI,
azureOpenAI: OpenAI,
bingAI: BingAI,
@ -21,7 +31,7 @@ const optionComponents: { [key: string]: OptionComponentType } = {
chatGPTBrowser: ChatGPT,
};
export default function ModelSelect({ conversation, setOption }: SelectProps) {
export default function ModelSelect({ conversation, setOption }: TSelectProps) {
const endpointsConfig = useRecoilValue(store.endpointsConfig);
if (!conversation?.endpoint) {
return null;

View file

@ -1,8 +1,8 @@
import { SelectDropDown } from '~/components/ui';
import { cn, cardStyle } from '~/utils/';
import { ModelSelectProps } from 'librechat-data-provider';
import type { TModelSelectProps } from '~/common';
export default function OpenAI({ conversation, setOption, models }: ModelSelectProps) {
export default function OpenAI({ conversation, setOption, models }: TModelSelectProps) {
return (
<SelectDropDown
value={conversation?.model ?? ''}

View file

@ -1,7 +1,8 @@
import { useRecoilState } from 'recoil';
import { useState, useEffect } from 'react';
import { ChevronDownIcon } from 'lucide-react';
import { ModelSelectProps, useAvailablePluginsQuery, TPlugin } from 'librechat-data-provider';
import { useAvailablePluginsQuery, TPlugin } from 'librechat-data-provider';
import type { TModelSelectProps } from '~/common';
import { SelectDropDown, MultiSelectDropDown, Button } from '~/components/ui';
import { useSetOptions, useAuthContext, useMediaQuery } from '~/hooks';
import { cn, cardStyle } from '~/utils/';
@ -17,7 +18,7 @@ const pluginStore: TPlugin = {
authenticated: false,
};
export default function Plugins({ conversation, setOption, models }: ModelSelectProps) {
export default function Plugins({ conversation, setOption, models }: TModelSelectProps) {
const { data: allPlugins } = useAvailablePluginsQuery();
const [visible, setVisibility] = useState<boolean>(true);
const [availableTools, setAvailableTools] = useRecoilState(store.availableTools);