mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-11 05:49:22 +00:00
Native data AI application framework based on AWEL+AGENT (#1152)
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com> Co-authored-by: lcx01800250 <lcx01800250@alibaba-inc.com> Co-authored-by: licunxing <864255598@qq.com> Co-authored-by: Aralhi <xiaoping0501@gmail.com> Co-authored-by: xuyuan23 <643854343@qq.com> Co-authored-by: aries_ckt <916701291@qq.com> Co-authored-by: hzh97 <2976151305@qq.com>
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
import { Popover, ConfigProvider, Button, Modal, Badge } from 'antd';
|
||||
import { Popover, ConfigProvider, Modal, Badge } from 'antd';
|
||||
import { useRouter } from 'next/router';
|
||||
import Image from 'next/image';
|
||||
import { DeleteFilled, MessageTwoTone, WarningOutlined } from '@ant-design/icons';
|
||||
import { ClockCircleOutlined, DeleteFilled, MessageFilled, UserOutlined, WarningOutlined } from '@ant-design/icons';
|
||||
import { ISpace } from '@/types/knowledge';
|
||||
import DocPanel from './doc-panel';
|
||||
import moment from 'moment';
|
||||
import { apiInterceptors, delSpace, newDialogue } from '@/client/api';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { VECTOR_ICON_MAP } from '@/utils/constants';
|
||||
import GptCard from '../common/gpt-card';
|
||||
|
||||
interface IProps {
|
||||
space: ISpace;
|
||||
@@ -41,9 +42,7 @@ export default function SpaceCard(props: IProps) {
|
||||
getSpaces();
|
||||
}
|
||||
|
||||
const handleChat = async (e: any) => {
|
||||
e.stopPropagation();
|
||||
|
||||
const handleChat = async () => {
|
||||
const [_, data] = await apiInterceptors(
|
||||
newDialogue({
|
||||
chat_mode: 'chat_knowledge',
|
||||
@@ -76,39 +75,50 @@ export default function SpaceCard(props: IProps) {
|
||||
}}
|
||||
>
|
||||
<Popover
|
||||
className="transition-all bg-white dark:bg-theme-dark-container cursor-pointer rounded"
|
||||
className="cursor-pointer"
|
||||
placement="bottom"
|
||||
trigger="click"
|
||||
content={<DocPanel space={space} onAddDoc={props.onAddDoc} onDeleteDoc={onDeleteDoc} />}
|
||||
>
|
||||
<Badge className="mb-4 min-w-[200px] sm:w-60 lg:w-72" count={space.docs || 0}>
|
||||
<div className="flex justify-between mx-6 mt-3">
|
||||
<div className="text-lg font-bold text-black truncate">
|
||||
{renderVectorIcon(space.vector_type)}
|
||||
<span className="dark:text-white ml-2">{space?.name}</span>
|
||||
</div>
|
||||
<DeleteFilled
|
||||
className="text-[#ff1b2e] !text-lg"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.nativeEvent.stopImmediatePropagation();
|
||||
showDeleteConfirm();
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="text-sm mt-2 p-6 pt-2 h-40">
|
||||
<p className="font-semibold">{t('Owner')}:</p>
|
||||
<p className=" truncate">{space?.owner}</p>
|
||||
<p className="font-semibold mt-2">{t('Description')}:</p>
|
||||
<p className=" line-clamp-2">{space?.desc}</p>
|
||||
<p className="font-semibold mt-2">Last modify:</p>
|
||||
<p className=" truncate">{moment(space.gmt_modified).format('YYYY-MM-DD HH:MM:SS')}</p>
|
||||
</div>
|
||||
<div className="flex justify-center">
|
||||
<Button size="middle" onClick={handleChat} className="mr-4 dark:text-white mb-2" shape="round" icon={<MessageTwoTone />}>
|
||||
{t('Chat')}
|
||||
</Button>
|
||||
</div>
|
||||
<GptCard
|
||||
title={space.name}
|
||||
desc={space.desc}
|
||||
icon={VECTOR_ICON_MAP[space.vector_type] || '/LOGO_SMALL.png'}
|
||||
iconBorder={false}
|
||||
tags={[
|
||||
{
|
||||
text: (
|
||||
<>
|
||||
<UserOutlined className="mr-1" />
|
||||
{space?.owner}
|
||||
</>
|
||||
),
|
||||
},
|
||||
{
|
||||
text: (
|
||||
<>
|
||||
<ClockCircleOutlined className="mr-1" />
|
||||
{moment(space.gmt_modified).format('YYYY-MM-DD')}
|
||||
</>
|
||||
),
|
||||
},
|
||||
]}
|
||||
operations={[
|
||||
{
|
||||
label: t('Chat'),
|
||||
children: <MessageFilled />,
|
||||
onClick: handleChat,
|
||||
},
|
||||
{
|
||||
label: t('Delete'),
|
||||
children: <DeleteFilled />,
|
||||
onClick: () => {
|
||||
showDeleteConfirm();
|
||||
},
|
||||
},
|
||||
]}
|
||||
/>
|
||||
</Badge>
|
||||
</Popover>
|
||||
</ConfigProvider>
|
||||
|
Reference in New Issue
Block a user