import { ReactComponent as MoreModelIcon } from '@/assets/svg/more-model.svg';
import { useSetModalState } from '@/hooks/commonHooks';
import {
LlmItem,
useFetchLlmFactoryListOnMount,
useFetchMyLlmListOnMount,
} from '@/hooks/llmHooks';
import { SettingOutlined } from '@ant-design/icons';
import {
Avatar,
Button,
Card,
Col,
Divider,
Flex,
List,
Row,
Space,
Typography,
} from 'antd';
import { useCallback } from 'react';
import SettingTitle from '../components/setting-title';
import ApiKeyModal from './api-key-modal';
import { useSubmitApiKey, useSubmitSystemModelSetting } from './hooks';
import SystemModelSettingModal from './system-model-setting-modal';
import styles from './index.less';
const { Text } = Typography;
interface IModelCardProps {
item: LlmItem;
clickApiKey: (llmFactory: string) => void;
}
const ModelCard = ({ item, clickApiKey }: IModelCardProps) => {
const { visible, switchVisible } = useSetModalState();
const handleApiKeyClick = () => {
clickApiKey(item.name);
};
const handleShowMoreClick = () => {
switchVisible();
};
return (
{item.name}
{item.tags}
{visible && (
{item.name}}
/>
)}
);
};
const UserSettingModel = () => {
const factoryList = useFetchLlmFactoryListOnMount();
const llmList = useFetchMyLlmListOnMount();
const {
saveApiKeyLoading,
initialApiKey,
onApiKeySavingOk,
apiKeyVisible,
hideApiKeyModal,
showApiKeyModal,
} = useSubmitApiKey();
const {
saveSystemModelSettingLoading,
onSystemSettingSavingOk,
systemSettingVisible,
hideSystemSettingModal,
showSystemSettingModal,
} = useSubmitSystemModelSetting();
const handleApiKeyClick = useCallback(
(llmFactory: string) => {
showApiKeyModal({ llm_factory: llmFactory });
},
[showApiKeyModal],
);
const handleAddModel = (llmFactory: string) => () => {
handleApiKeyClick(llmFactory);
};
return (
<>
(
)}
/>
Models to be added
(
{item.name}
{item.tags}
)}
/>
>
);
};
export default UserSettingModel;