balibabu
commited on
Commit
·
1660911
1
Parent(s):
1a2e406
Feat: Bind the route to the navigation bar in the head #3221 (#3863)
Browse files### What problem does this PR solve?
Feat: Bind the route to the navigation bar in the head #3221
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
- web/src/components/knowledge-base-item.tsx +2 -2
- web/src/components/ui/skeleton.tsx +39 -0
- web/src/hooks/knowledge-hooks.ts +1 -1
- web/src/hooks/logic-hooks/navigate-hooks.ts +21 -0
- web/src/layouts/next-header.tsx +39 -15
- web/src/pages/agent/index.tsx +3 -0
- web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx +2 -2
- web/src/pages/flow/canvas/node/retrieval-node.tsx +2 -2
- web/src/pages/home/datasets.tsx +67 -71
- web/src/pages/next-chat/index.tsx +3 -0
- web/src/pages/next-search/index.tsx +3 -0
- web/src/pages/search/index.tsx +2 -2
- web/src/pages/search/sidebar.tsx +2 -2
- web/src/routes.ts +60 -16
web/src/components/knowledge-base-item.tsx
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
-
import {
|
3 |
import { UserOutlined } from '@ant-design/icons';
|
4 |
import { Avatar, Form, Select, Space } from 'antd';
|
5 |
|
6 |
const KnowledgeBaseItem = () => {
|
7 |
const { t } = useTranslate('chat');
|
8 |
|
9 |
-
const { list: knowledgeList } =
|
10 |
|
11 |
const knowledgeOptions = knowledgeList.map((x) => ({
|
12 |
label: (
|
|
|
1 |
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
+
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
3 |
import { UserOutlined } from '@ant-design/icons';
|
4 |
import { Avatar, Form, Select, Space } from 'antd';
|
5 |
|
6 |
const KnowledgeBaseItem = () => {
|
7 |
const { t } = useTranslate('chat');
|
8 |
|
9 |
+
const { list: knowledgeList } = useFetchKnowledgeList(true);
|
10 |
|
11 |
const knowledgeOptions = knowledgeList.map((x) => ({
|
12 |
label: (
|
web/src/components/ui/skeleton.tsx
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { cn } from '@/lib/utils';
|
2 |
+
|
3 |
+
function Skeleton({
|
4 |
+
className,
|
5 |
+
...props
|
6 |
+
}: React.HTMLAttributes<HTMLDivElement>) {
|
7 |
+
return (
|
8 |
+
<div
|
9 |
+
className={cn('animate-pulse rounded-md bg-muted', className)}
|
10 |
+
{...props}
|
11 |
+
/>
|
12 |
+
);
|
13 |
+
}
|
14 |
+
|
15 |
+
function ParagraphSkeleton() {
|
16 |
+
return (
|
17 |
+
<div className="flex items-center space-x-4">
|
18 |
+
<Skeleton className="h-12 w-12 rounded-full" />
|
19 |
+
<div className="space-y-2">
|
20 |
+
<Skeleton className="h-4 w-[250px]" />
|
21 |
+
<Skeleton className="h-4 w-[200px]" />
|
22 |
+
</div>
|
23 |
+
</div>
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
function CardSkeleton() {
|
28 |
+
return (
|
29 |
+
<div className="flex flex-col space-y-3">
|
30 |
+
<Skeleton className="h-[125px] w-[250px] rounded-xl" />
|
31 |
+
<div className="space-y-2">
|
32 |
+
<Skeleton className="h-4 w-[250px]" />
|
33 |
+
<Skeleton className="h-4 w-[200px]" />
|
34 |
+
</div>
|
35 |
+
</div>
|
36 |
+
);
|
37 |
+
}
|
38 |
+
|
39 |
+
export { CardSkeleton, ParagraphSkeleton, Skeleton };
|
web/src/hooks/knowledge-hooks.ts
CHANGED
@@ -41,7 +41,7 @@ export const useFetchKnowledgeBaseConfiguration = () => {
|
|
41 |
return { data, loading };
|
42 |
};
|
43 |
|
44 |
-
export const
|
45 |
shouldFilterListWithoutDocument: boolean = false,
|
46 |
): {
|
47 |
list: IKnowledge[];
|
|
|
41 |
return { data, loading };
|
42 |
};
|
43 |
|
44 |
+
export const useFetchKnowledgeList = (
|
45 |
shouldFilterListWithoutDocument: boolean = false,
|
46 |
): {
|
47 |
list: IKnowledge[];
|
web/src/hooks/logic-hooks/navigate-hooks.ts
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import { Routes } from '@/routes';
|
2 |
+
import { useCallback } from 'react';
|
3 |
+
import { useNavigate } from 'umi';
|
4 |
+
|
5 |
+
export const useNavigatePage = () => {
|
6 |
+
const navigate = useNavigate();
|
7 |
+
|
8 |
+
const navigateToDatasetList = useCallback(() => {
|
9 |
+
navigate(Routes.Datasets);
|
10 |
+
}, [navigate]);
|
11 |
+
|
12 |
+
const navigateToDataset = useCallback(() => {
|
13 |
+
navigate(Routes.Dataset);
|
14 |
+
}, [navigate]);
|
15 |
+
|
16 |
+
const navigateToHome = useCallback(() => {
|
17 |
+
navigate(Routes.Home);
|
18 |
+
}, [navigate]);
|
19 |
+
|
20 |
+
return { navigateToDatasetList, navigateToDataset, navigateToHome };
|
21 |
+
};
|
web/src/layouts/next-header.tsx
CHANGED
@@ -3,32 +3,37 @@ import { Button } from '@/components/ui/button';
|
|
3 |
import { Container } from '@/components/ui/container';
|
4 |
import { Segmented, SegmentedValue } from '@/components/ui/segmented ';
|
5 |
import { useTranslate } from '@/hooks/common-hooks';
|
|
|
6 |
import { useNavigateWithFromState } from '@/hooks/route-hook';
|
|
|
|
|
7 |
import {
|
8 |
ChevronDown,
|
9 |
Cpu,
|
10 |
Github,
|
|
|
11 |
Library,
|
12 |
MessageSquareText,
|
13 |
Search,
|
14 |
Star,
|
15 |
Zap,
|
16 |
} from 'lucide-react';
|
17 |
-
import { useCallback, useMemo
|
18 |
import { useLocation } from 'umi';
|
19 |
|
20 |
export function Header() {
|
21 |
const { t } = useTranslate('header');
|
22 |
const { pathname } = useLocation();
|
23 |
const navigate = useNavigateWithFromState();
|
24 |
-
const [currentPath, setCurrentPath] = useState(
|
|
|
25 |
|
26 |
const tagsData = useMemo(
|
27 |
() => [
|
28 |
-
{ path:
|
29 |
-
{ path:
|
30 |
-
{ path:
|
31 |
-
{ path:
|
32 |
// { path: '/file', name: t('fileManager'), icon: FileIcon },
|
33 |
],
|
34 |
[t],
|
@@ -50,17 +55,21 @@ export function Header() {
|
|
50 |
});
|
51 |
}, [tagsData]);
|
52 |
|
53 |
-
|
54 |
-
|
55 |
-
|
|
|
|
|
|
|
|
|
56 |
|
57 |
const handleChange = (path: SegmentedValue) => {
|
58 |
-
|
59 |
-
setCurrentPath(path as
|
60 |
};
|
61 |
|
62 |
const handleLogoClick = useCallback(() => {
|
63 |
-
navigate(
|
64 |
}, [navigate]);
|
65 |
|
66 |
return (
|
@@ -81,7 +90,22 @@ export function Header() {
|
|
81 |
<Star />
|
82 |
</Button>
|
83 |
</div>
|
84 |
-
<div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
85 |
<Segmented
|
86 |
options={options}
|
87 |
value={currentPath}
|
@@ -90,7 +114,7 @@ export function Header() {
|
|
90 |
></Segmented>
|
91 |
</div>
|
92 |
<div className="flex items-center gap-4">
|
93 |
-
<Container className="bg-colors-background-inverse-standard">
|
94 |
V 0.13.0
|
95 |
<Button variant="secondary" className="size-8">
|
96 |
<ChevronDown />
|
@@ -101,7 +125,7 @@ export function Header() {
|
|
101 |
<AvatarImage src="https://github.com/shadcn.png" />
|
102 |
<AvatarFallback>CN</AvatarFallback>
|
103 |
</Avatar>
|
104 | |
105 |
<Button
|
106 |
variant="destructive"
|
107 |
className="py-[2px] px-[8px] h-[23px] rounded-[4px]"
|
|
|
3 |
import { Container } from '@/components/ui/container';
|
4 |
import { Segmented, SegmentedValue } from '@/components/ui/segmented ';
|
5 |
import { useTranslate } from '@/hooks/common-hooks';
|
6 |
+
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
7 |
import { useNavigateWithFromState } from '@/hooks/route-hook';
|
8 |
+
import { cn } from '@/lib/utils';
|
9 |
+
import { Routes } from '@/routes';
|
10 |
import {
|
11 |
ChevronDown,
|
12 |
Cpu,
|
13 |
Github,
|
14 |
+
House,
|
15 |
Library,
|
16 |
MessageSquareText,
|
17 |
Search,
|
18 |
Star,
|
19 |
Zap,
|
20 |
} from 'lucide-react';
|
21 |
+
import { useCallback, useMemo } from 'react';
|
22 |
import { useLocation } from 'umi';
|
23 |
|
24 |
export function Header() {
|
25 |
const { t } = useTranslate('header');
|
26 |
const { pathname } = useLocation();
|
27 |
const navigate = useNavigateWithFromState();
|
28 |
+
// const [currentPath, setCurrentPath] = useState(Routes.Home);
|
29 |
+
const { navigateToHome } = useNavigatePage();
|
30 |
|
31 |
const tagsData = useMemo(
|
32 |
() => [
|
33 |
+
{ path: Routes.Datasets, name: t('knowledgeBase'), icon: Library },
|
34 |
+
{ path: Routes.Chat, name: t('chat'), icon: MessageSquareText },
|
35 |
+
{ path: Routes.Search, name: t('search'), icon: Search },
|
36 |
+
{ path: Routes.Agent, name: t('flow'), icon: Cpu },
|
37 |
// { path: '/file', name: t('fileManager'), icon: FileIcon },
|
38 |
],
|
39 |
[t],
|
|
|
55 |
});
|
56 |
}, [tagsData]);
|
57 |
|
58 |
+
const currentPath = useMemo(() => {
|
59 |
+
return (
|
60 |
+
tagsData.find((x) => pathname.startsWith(x.path))?.path || Routes.Home
|
61 |
+
);
|
62 |
+
}, [pathname, tagsData]);
|
63 |
+
|
64 |
+
const isHome = Routes.Home === currentPath;
|
65 |
|
66 |
const handleChange = (path: SegmentedValue) => {
|
67 |
+
navigate(path as Routes);
|
68 |
+
// setCurrentPath(path as Routes);
|
69 |
};
|
70 |
|
71 |
const handleLogoClick = useCallback(() => {
|
72 |
+
navigate(Routes.Home);
|
73 |
}, [navigate]);
|
74 |
|
75 |
return (
|
|
|
90 |
<Star />
|
91 |
</Button>
|
92 |
</div>
|
93 |
+
<div className="flex gap-2 items-center">
|
94 |
+
<Button
|
95 |
+
variant={'icon'}
|
96 |
+
size={'icon'}
|
97 |
+
onClick={navigateToHome}
|
98 |
+
className={cn({
|
99 |
+
'bg-colors-background-inverse-strong': isHome,
|
100 |
+
})}
|
101 |
+
>
|
102 |
+
<House
|
103 |
+
className={cn({
|
104 |
+
'text-colors-text-inverse-strong': isHome,
|
105 |
+
})}
|
106 |
+
/>
|
107 |
+
</Button>
|
108 |
+
<div className="h-8 w-[1px] bg-colors-outline-neutral-strong"></div>
|
109 |
<Segmented
|
110 |
options={options}
|
111 |
value={currentPath}
|
|
|
114 |
></Segmented>
|
115 |
</div>
|
116 |
<div className="flex items-center gap-4">
|
117 |
+
<Container className="bg-colors-background-inverse-standard hidden xl:flex">
|
118 |
V 0.13.0
|
119 |
<Button variant="secondary" className="size-8">
|
120 |
<ChevronDown />
|
|
|
125 |
<AvatarImage src="https://github.com/shadcn.png" />
|
126 |
<AvatarFallback>CN</AvatarFallback>
|
127 |
</Avatar>
|
128 |
+
<span className="max-w-14 truncate"> [email protected]</span>
|
129 |
<Button
|
130 |
variant="destructive"
|
131 |
className="py-[2px] px-[8px] h-[23px] rounded-[4px]"
|
web/src/pages/agent/index.tsx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
export default function Agent() {
|
2 |
+
return <div>Agent</div>;
|
3 |
+
}
|
web/src/pages/file-manager/connect-to-knowledge-modal/index.tsx
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
-
import {
|
3 |
import { IModalProps } from '@/interfaces/common';
|
4 |
import { filterOptionsByInput } from '@/utils/common-util';
|
5 |
import { Form, Modal, Select } from 'antd';
|
@@ -13,7 +13,7 @@ const ConnectToKnowledgeModal = ({
|
|
13 |
loading,
|
14 |
}: IModalProps<string[]> & { initialValue: string[] }) => {
|
15 |
const [form] = Form.useForm();
|
16 |
-
const { list } =
|
17 |
const { t } = useTranslate('fileManager');
|
18 |
|
19 |
const options = list?.map((item) => ({
|
|
|
1 |
import { useTranslate } from '@/hooks/common-hooks';
|
2 |
+
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
3 |
import { IModalProps } from '@/interfaces/common';
|
4 |
import { filterOptionsByInput } from '@/utils/common-util';
|
5 |
import { Form, Modal, Select } from 'antd';
|
|
|
13 |
loading,
|
14 |
}: IModalProps<string[]> & { initialValue: string[] }) => {
|
15 |
const [form] = Form.useForm();
|
16 |
+
const { list } = useFetchKnowledgeList();
|
17 |
const { t } = useTranslate('fileManager');
|
18 |
|
19 |
const options = list?.map((item) => ({
|
web/src/pages/flow/canvas/node/retrieval-node.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import {
|
2 |
import { UserOutlined } from '@ant-design/icons';
|
3 |
import { Avatar, Flex } from 'antd';
|
4 |
import classNames from 'classnames';
|
@@ -17,7 +17,7 @@ export function RetrievalNode({
|
|
17 |
selected,
|
18 |
}: NodeProps<NodeData>) {
|
19 |
const knowledgeBaseIds: string[] = get(data, 'form.kb_ids', []);
|
20 |
-
const { list: knowledgeList } =
|
21 |
const knowledgeBases = useMemo(() => {
|
22 |
return knowledgeBaseIds.map((x) => {
|
23 |
const item = knowledgeList.find((y) => x === y.id);
|
|
|
1 |
+
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
2 |
import { UserOutlined } from '@ant-design/icons';
|
3 |
import { Avatar, Flex } from 'antd';
|
4 |
import classNames from 'classnames';
|
|
|
17 |
selected,
|
18 |
}: NodeProps<NodeData>) {
|
19 |
const knowledgeBaseIds: string[] = get(data, 'form.kb_ids', []);
|
20 |
+
const { list: knowledgeList } = useFetchKnowledgeList(true);
|
21 |
const knowledgeBases = useMemo(() => {
|
22 |
return knowledgeBaseIds.map((x) => {
|
23 |
const item = knowledgeList.find((y) => x === y.id);
|
web/src/pages/home/datasets.tsx
CHANGED
@@ -1,82 +1,78 @@
|
|
|
|
1 |
import { Button } from '@/components/ui/button';
|
2 |
import { Card, CardContent } from '@/components/ui/card';
|
3 |
-
import {
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
title: 'Legal knowledge base',
|
9 |
-
files: '1,242 files',
|
10 |
-
size: '152 MB',
|
11 |
-
created: '12.02.2024',
|
12 |
-
image: 'https://github.com/shadcn.png',
|
13 |
-
},
|
14 |
-
{
|
15 |
-
id: 2,
|
16 |
-
title: 'HR knowledge base',
|
17 |
-
files: '1,242 files',
|
18 |
-
size: '152 MB',
|
19 |
-
created: '12.02.2024',
|
20 |
-
image: 'https://github.com/shadcn.png',
|
21 |
-
},
|
22 |
-
{
|
23 |
-
id: 3,
|
24 |
-
title: 'IT knowledge base',
|
25 |
-
files: '1,242 files',
|
26 |
-
size: '152 MB',
|
27 |
-
created: '12.02.2024',
|
28 |
-
image: 'https://github.com/shadcn.png',
|
29 |
-
},
|
30 |
-
{
|
31 |
-
id: 4,
|
32 |
-
title: 'Legal knowledge base',
|
33 |
-
files: '1,242 files',
|
34 |
-
size: '152 MB',
|
35 |
-
created: '12.02.2024',
|
36 |
-
image: 'https://github.com/shadcn.png',
|
37 |
-
},
|
38 |
-
];
|
39 |
|
40 |
export function Datasets() {
|
|
|
|
|
|
|
41 |
return (
|
42 |
<section>
|
43 |
<h2 className="text-2xl font-bold mb-6">Datasets</h2>
|
44 |
<div className="flex gap-6">
|
45 |
-
{
|
46 |
-
<
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
<
|
57 |
-
<
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
<
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
See all
|
81 |
</Button>
|
82 |
</div>
|
|
|
1 |
+
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
2 |
import { Button } from '@/components/ui/button';
|
3 |
import { Card, CardContent } from '@/components/ui/card';
|
4 |
+
import { CardSkeleton } from '@/components/ui/skeleton';
|
5 |
+
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
6 |
+
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
7 |
+
import { formatDate } from '@/utils/date';
|
8 |
+
import { ChevronRight, Trash2 } from 'lucide-react';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
export function Datasets() {
|
11 |
+
const { navigateToDatasetList, navigateToDataset } = useNavigatePage();
|
12 |
+
const { list, loading } = useFetchKnowledgeList();
|
13 |
+
|
14 |
return (
|
15 |
<section>
|
16 |
<h2 className="text-2xl font-bold mb-6">Datasets</h2>
|
17 |
<div className="flex gap-6">
|
18 |
+
{loading ? (
|
19 |
+
<div className="flex-1">
|
20 |
+
<CardSkeleton />
|
21 |
+
</div>
|
22 |
+
) : (
|
23 |
+
<div className="flex gap-4 flex-1">
|
24 |
+
{list.slice(0, 3).map((dataset) => (
|
25 |
+
<Card
|
26 |
+
key={dataset.id}
|
27 |
+
className="bg-colors-background-inverse-weak flex-1 border-colors-outline-neutral-standard"
|
28 |
+
>
|
29 |
+
<CardContent className="p-4">
|
30 |
+
<div className="flex justify-between mb-4">
|
31 |
+
{dataset.avatar ? (
|
32 |
+
<div
|
33 |
+
className="w-[70px] h-[70px] rounded-xl bg-cover"
|
34 |
+
style={{ backgroundImage: `url(${dataset.avatar})` }}
|
35 |
+
/>
|
36 |
+
) : (
|
37 |
+
<Avatar>
|
38 |
+
<AvatarImage src="https://github.com/shadcn.png" />
|
39 |
+
<AvatarFallback>CN</AvatarFallback>
|
40 |
+
</Avatar>
|
41 |
+
)}
|
42 |
+
<Button variant="ghost" size="icon">
|
43 |
+
<Trash2 />
|
44 |
+
</Button>
|
45 |
+
</div>
|
46 |
+
<div className="flex justify-between items-end">
|
47 |
+
<div>
|
48 |
+
<h3 className="text-lg font-semibold mb-2">
|
49 |
+
{dataset.name}
|
50 |
+
</h3>
|
51 |
+
<div className="text-sm opacity-80">
|
52 |
+
{dataset.doc_num} files
|
53 |
+
</div>
|
54 |
+
<p className="text-sm opacity-80">
|
55 |
+
Created {formatDate(dataset.update_time)}
|
56 |
+
</p>
|
57 |
+
</div>
|
58 |
+
<Button
|
59 |
+
variant="icon"
|
60 |
+
size="icon"
|
61 |
+
onClick={navigateToDataset}
|
62 |
+
>
|
63 |
+
<ChevronRight className="h-6 w-6" />
|
64 |
+
</Button>
|
65 |
+
</div>
|
66 |
+
</CardContent>
|
67 |
+
</Card>
|
68 |
+
))}
|
69 |
+
</div>
|
70 |
+
)}
|
71 |
+
<Button
|
72 |
+
className="h-auto "
|
73 |
+
variant={'tertiary'}
|
74 |
+
onClick={navigateToDatasetList}
|
75 |
+
>
|
76 |
See all
|
77 |
</Button>
|
78 |
</div>
|
web/src/pages/next-chat/index.tsx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
export default function Chat() {
|
2 |
+
return <div>chat</div>;
|
3 |
+
}
|
web/src/pages/next-search/index.tsx
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
export default function Search() {
|
2 |
+
return <div>Search</div>;
|
3 |
+
}
|
web/src/pages/search/index.tsx
CHANGED
@@ -6,7 +6,7 @@ import { useClickDrawer } from '@/components/pdf-drawer/hooks';
|
|
6 |
import RetrievalDocuments from '@/components/retrieval-documents';
|
7 |
import SvgIcon from '@/components/svg-icon';
|
8 |
import {
|
9 |
-
|
10 |
useSelectTestingResult,
|
11 |
} from '@/hooks/knowledge-hooks';
|
12 |
import { useGetPaginationWithRouter } from '@/hooks/logic-hooks';
|
@@ -45,7 +45,7 @@ const SearchPage = () => {
|
|
45 |
const { t } = useTranslation();
|
46 |
const [checkedList, setCheckedList] = useState<string[]>([]);
|
47 |
const { chunks, total } = useSelectTestingResult();
|
48 |
-
const { list: knowledgeList } =
|
49 |
const checkedWithoutEmbeddingIdList = useMemo(() => {
|
50 |
return checkedList.filter((x) => knowledgeList.some((y) => y.id === x));
|
51 |
}, [checkedList, knowledgeList]);
|
|
|
6 |
import RetrievalDocuments from '@/components/retrieval-documents';
|
7 |
import SvgIcon from '@/components/svg-icon';
|
8 |
import {
|
9 |
+
useFetchKnowledgeList,
|
10 |
useSelectTestingResult,
|
11 |
} from '@/hooks/knowledge-hooks';
|
12 |
import { useGetPaginationWithRouter } from '@/hooks/logic-hooks';
|
|
|
45 |
const { t } = useTranslation();
|
46 |
const [checkedList, setCheckedList] = useState<string[]>([]);
|
47 |
const { chunks, total } = useSelectTestingResult();
|
48 |
+
const { list: knowledgeList } = useFetchKnowledgeList();
|
49 |
const checkedWithoutEmbeddingIdList = useMemo(() => {
|
50 |
return checkedList.filter((x) => knowledgeList.some((y) => y.id === x));
|
51 |
}, [checkedList, knowledgeList]);
|
web/src/pages/search/sidebar.tsx
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
import {
|
2 |
import { UserOutlined } from '@ant-design/icons';
|
3 |
import type { TreeDataNode, TreeProps } from 'antd';
|
4 |
import { Avatar, Layout, Space, Spin, Tree, Typography } from 'antd';
|
@@ -27,7 +27,7 @@ const SearchSidebar = ({
|
|
27 |
checkedList,
|
28 |
setCheckedList,
|
29 |
}: IProps) => {
|
30 |
-
const { list, loading } =
|
31 |
|
32 |
const groupedList = useMemo(() => {
|
33 |
return list.reduce((pre: TreeDataNode[], cur) => {
|
|
|
1 |
+
import { useFetchKnowledgeList } from '@/hooks/knowledge-hooks';
|
2 |
import { UserOutlined } from '@ant-design/icons';
|
3 |
import type { TreeDataNode, TreeProps } from 'antd';
|
4 |
import { Avatar, Layout, Space, Spin, Tree, Typography } from 'antd';
|
|
|
27 |
checkedList,
|
28 |
setCheckedList,
|
29 |
}: IProps) => {
|
30 |
+
const { list, loading } = useFetchKnowledgeList();
|
31 |
|
32 |
const groupedList = useMemo(() => {
|
33 |
return list.reduce((pre: TreeDataNode[], cur) => {
|
web/src/routes.ts
CHANGED
@@ -1,3 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
const routes = [
|
2 |
{
|
3 |
path: '/login',
|
@@ -127,48 +138,81 @@ const routes = [
|
|
127 |
layout: false,
|
128 |
},
|
129 |
{
|
130 |
-
path:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
131 |
layout: false,
|
132 |
component: '@/layouts/next',
|
133 |
routes: [
|
134 |
{
|
135 |
-
path:
|
136 |
-
component:
|
137 |
},
|
138 |
],
|
139 |
},
|
140 |
{
|
141 |
-
path:
|
142 |
layout: false,
|
143 |
component: '@/layouts/next',
|
144 |
routes: [
|
145 |
{
|
146 |
-
path:
|
147 |
-
component:
|
148 |
},
|
149 |
],
|
150 |
},
|
151 |
{
|
152 |
-
path:
|
153 |
layout: false,
|
154 |
component: '@/layouts/next',
|
155 |
routes: [
|
156 |
-
{ path:
|
157 |
{
|
158 |
-
path:
|
159 |
-
component:
|
160 |
routes: [
|
161 |
{
|
162 |
-
path:
|
163 |
-
component:
|
164 |
},
|
165 |
{
|
166 |
-
path:
|
167 |
-
component:
|
168 |
},
|
169 |
{
|
170 |
-
path:
|
171 |
-
component:
|
172 |
},
|
173 |
],
|
174 |
},
|
|
|
1 |
+
export enum Routes {
|
2 |
+
Login = '/login',
|
3 |
+
Home = '/home',
|
4 |
+
Datasets = '/datasets',
|
5 |
+
DatasetBase = '/dataset',
|
6 |
+
Dataset = `${Routes.DatasetBase}${Routes.DatasetBase}`,
|
7 |
+
Agent = '/agent',
|
8 |
+
Search = '/next-search',
|
9 |
+
Chat = '/next-chat',
|
10 |
+
}
|
11 |
+
|
12 |
const routes = [
|
13 |
{
|
14 |
path: '/login',
|
|
|
138 |
layout: false,
|
139 |
},
|
140 |
{
|
141 |
+
path: Routes.Home,
|
142 |
+
layout: false,
|
143 |
+
component: '@/layouts/next',
|
144 |
+
routes: [
|
145 |
+
{
|
146 |
+
path: Routes.Home,
|
147 |
+
component: `@/pages${Routes.Home}`,
|
148 |
+
},
|
149 |
+
],
|
150 |
+
},
|
151 |
+
{
|
152 |
+
path: Routes.Datasets,
|
153 |
+
layout: false,
|
154 |
+
component: '@/layouts/next',
|
155 |
+
routes: [
|
156 |
+
{
|
157 |
+
path: Routes.Datasets,
|
158 |
+
component: `@/pages${Routes.Datasets}`,
|
159 |
+
},
|
160 |
+
],
|
161 |
+
},
|
162 |
+
{
|
163 |
+
path: Routes.Chat,
|
164 |
+
layout: false,
|
165 |
+
component: '@/layouts/next',
|
166 |
+
routes: [
|
167 |
+
{
|
168 |
+
path: Routes.Chat,
|
169 |
+
component: `@/pages${Routes.Chat}`,
|
170 |
+
},
|
171 |
+
],
|
172 |
+
},
|
173 |
+
{
|
174 |
+
path: Routes.Search,
|
175 |
layout: false,
|
176 |
component: '@/layouts/next',
|
177 |
routes: [
|
178 |
{
|
179 |
+
path: Routes.Search,
|
180 |
+
component: `@/pages${Routes.Search}`,
|
181 |
},
|
182 |
],
|
183 |
},
|
184 |
{
|
185 |
+
path: Routes.Agent,
|
186 |
layout: false,
|
187 |
component: '@/layouts/next',
|
188 |
routes: [
|
189 |
{
|
190 |
+
path: Routes.Agent,
|
191 |
+
component: `@/pages${Routes.Agent}`,
|
192 |
},
|
193 |
],
|
194 |
},
|
195 |
{
|
196 |
+
path: Routes.DatasetBase,
|
197 |
layout: false,
|
198 |
component: '@/layouts/next',
|
199 |
routes: [
|
200 |
+
{ path: Routes.DatasetBase, redirect: Routes.Dataset },
|
201 |
{
|
202 |
+
path: Routes.DatasetBase,
|
203 |
+
component: `@/pages${Routes.DatasetBase}`,
|
204 |
routes: [
|
205 |
{
|
206 |
+
path: Routes.Dataset,
|
207 |
+
component: `@/pages${Routes.Dataset}`,
|
208 |
},
|
209 |
{
|
210 |
+
path: `${Routes.DatasetBase}/configuration`,
|
211 |
+
component: `@/pages${Routes.DatasetBase}/settings`,
|
212 |
},
|
213 |
{
|
214 |
+
path: `${Routes.DatasetBase}/testing`,
|
215 |
+
component: `@/pages${Routes.DatasetBase}/testing`,
|
216 |
},
|
217 |
],
|
218 |
},
|