import IconFont from '@/components/icon-font'; import HotKeys from '@/config/hotkeys'; import { modelCategoriesMap } from '@/pages/llmodels/config'; import { PageContainer } from '@ant-design/pro-components'; import { useIntl } from '@umijs/max'; import { Button, Space } from 'antd'; import classNames from 'classnames'; import _ from 'lodash'; import { useCallback, useEffect, useRef, useState } from 'react'; import { useHotkeys } from 'react-hotkeys-hook'; import { queryModelsList } from './apis'; import GroundEmbedding from './components/ground-embedding'; import './style/play-ground.less'; const PlaygroundEmbedding: React.FC = () => { const intl = useIntl(); const groundLeftRef = useRef(null); const ref = useRef(null); const [modelList, setModelList] = useState[]>([]); const [loaded, setLoaded] = useState(false); const handleViewCode = useCallback(() => { ref.current?.viewCode?.(); }, [ref.current]); const handleToggleCollapse = useCallback(() => { ref.current?.setCollapse?.(); }, [ref.current]); useEffect(() => { const getModelListByEmbedding = async () => { try { const params = { categories: modelCategoriesMap.embedding, with_meta: true }; const res = await queryModelsList(params); const list = _.map(res.data || [], (item: any) => { return { value: item.id, label: item.id }; }) as Global.BaseOption[]; return list; } catch (error) { console.error(error); return []; } }; const fetchData = async () => { try { const [dataList] = await Promise.all([getModelListByEmbedding()]); setModelList(dataList); } catch (error) { setLoaded(true); } }; fetchData(); }, []); const renderExtra = () => { return ( ); }; useHotkeys( HotKeys.RIGHT.join(','), () => { groundLeftRef.current?.setCollapse?.(); }, { preventDefault: true } ); return (
); }; export default PlaygroundEmbedding;