DB-GPT/web/components/chat/header/agent-selector.tsx
Dreammy23 471689ba20
feat(web): Unified frontend code style (#1923)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: 谨欣 <echo.cmy@antgroup.com>
Co-authored-by: 严志勇 <yanzhiyong@tiansuixiansheng.com>
Co-authored-by: yanzhiyong <932374019@qq.com>
2024-08-30 14:03:06 +08:00

32 lines
831 B
TypeScript

import { ChatContext } from '@/app/chat-context';
import { apiInterceptors, getDbgptsList } from '@/client/api';
import { useRequest } from 'ahooks';
import { Select } from 'antd';
import { useContext } from 'react';
import { useTranslation } from 'react-i18next';
function AgentSelector() {
const { t } = useTranslation();
const { agent, setAgent } = useContext(ChatContext);
const { data = [] } = useRequest(async () => {
const [, res] = await apiInterceptors(getDbgptsList());
return res ?? [];
});
return (
<Select
className='w-60'
value={agent}
placeholder={t('Select_Plugins')}
options={data.map(item => ({ label: item.app_name, value: item.app_code }))}
allowClear
onChange={val => {
setAgent?.(val);
}}
/>
);
}
export default AgentSelector;