balibabu
commited on
Commit
·
c34c86c
1
Parent(s):
403ecb1
Feat: If there is no result in the recall test, an empty data image will be displayed. #4182 (#4183)
Browse files### What problem does this PR solve?
Feat: If there is no result in the recall test, an empty data image will
be displayed. #4182
### Type of change
- [x] New Feature (non-breaking change which adds functionality)
web/src/hooks/knowledge-hooks.ts
CHANGED
@@ -248,4 +248,14 @@ export const useSelectTestingResult = (): ITestingResult => {
|
|
248 |
total: 0,
|
249 |
}) as ITestingResult;
|
250 |
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
//#endregion
|
|
|
248 |
total: 0,
|
249 |
}) as ITestingResult;
|
250 |
};
|
251 |
+
|
252 |
+
export const useSelectIsTestingSuccess = () => {
|
253 |
+
const status = useMutationState({
|
254 |
+
filters: { mutationKey: ['testChunk'] },
|
255 |
+
select: (mutation) => {
|
256 |
+
return mutation.state.status;
|
257 |
+
},
|
258 |
+
});
|
259 |
+
return status.at(-1) === 'success';
|
260 |
+
};
|
261 |
//#endregion
|
web/src/pages/add-knowledge/components/knowledge-testing/testing-result/index.tsx
CHANGED
@@ -5,6 +5,7 @@ import { ITestingChunk } from '@/interfaces/database/knowledge';
|
|
5 |
import {
|
6 |
Card,
|
7 |
Collapse,
|
|
|
8 |
Flex,
|
9 |
Pagination,
|
10 |
PaginationProps,
|
@@ -14,7 +15,10 @@ import {
|
|
14 |
import camelCase from 'lodash/camelCase';
|
15 |
import SelectFiles from './select-files';
|
16 |
|
17 |
-
import {
|
|
|
|
|
|
|
18 |
import { useGetPaginationWithRouter } from '@/hooks/logic-hooks';
|
19 |
import { useCallback, useState } from 'react';
|
20 |
import styles from './index.less';
|
@@ -50,6 +54,7 @@ const TestingResult = ({ handleTesting }: IProps) => {
|
|
50 |
const { documents, chunks, total } = useSelectTestingResult();
|
51 |
const { t } = useTranslate('knowledgeDetails');
|
52 |
const { pagination, setPagination } = useGetPaginationWithRouter();
|
|
|
53 |
|
54 |
const onChange: PaginationProps['onChange'] = (pageNumber, pageSize) => {
|
55 |
pagination.onChange?.(pageNumber, pageSize);
|
@@ -105,26 +110,30 @@ const TestingResult = ({ handleTesting }: IProps) => {
|
|
105 |
flex={1}
|
106 |
className={styles.selectFilesCollapse}
|
107 |
>
|
108 |
-
{chunks
|
109 |
-
|
110 |
-
<
|
111 |
-
{
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
|
|
|
|
|
|
|
|
128 |
</Flex>
|
129 |
<Pagination
|
130 |
{...pagination}
|
|
|
5 |
import {
|
6 |
Card,
|
7 |
Collapse,
|
8 |
+
Empty,
|
9 |
Flex,
|
10 |
Pagination,
|
11 |
PaginationProps,
|
|
|
15 |
import camelCase from 'lodash/camelCase';
|
16 |
import SelectFiles from './select-files';
|
17 |
|
18 |
+
import {
|
19 |
+
useSelectIsTestingSuccess,
|
20 |
+
useSelectTestingResult,
|
21 |
+
} from '@/hooks/knowledge-hooks';
|
22 |
import { useGetPaginationWithRouter } from '@/hooks/logic-hooks';
|
23 |
import { useCallback, useState } from 'react';
|
24 |
import styles from './index.less';
|
|
|
54 |
const { documents, chunks, total } = useSelectTestingResult();
|
55 |
const { t } = useTranslate('knowledgeDetails');
|
56 |
const { pagination, setPagination } = useGetPaginationWithRouter();
|
57 |
+
const isSuccess = useSelectIsTestingSuccess();
|
58 |
|
59 |
const onChange: PaginationProps['onChange'] = (pageNumber, pageSize) => {
|
60 |
pagination.onChange?.(pageNumber, pageSize);
|
|
|
110 |
flex={1}
|
111 |
className={styles.selectFilesCollapse}
|
112 |
>
|
113 |
+
{isSuccess && chunks.length > 0 ? (
|
114 |
+
chunks?.map((x) => (
|
115 |
+
<Card key={x.chunk_id} title={<ChunkTitle item={x}></ChunkTitle>}>
|
116 |
+
<Flex gap={'middle'}>
|
117 |
+
{x.img_id && (
|
118 |
+
<Popover
|
119 |
+
placement="left"
|
120 |
+
content={
|
121 |
+
<Image
|
122 |
+
id={x.img_id}
|
123 |
+
className={styles.imagePreview}
|
124 |
+
></Image>
|
125 |
+
}
|
126 |
+
>
|
127 |
+
<Image id={x.img_id} className={styles.image}></Image>
|
128 |
+
</Popover>
|
129 |
+
)}
|
130 |
+
<div>{x.content_with_weight}</div>
|
131 |
+
</Flex>
|
132 |
+
</Card>
|
133 |
+
))
|
134 |
+
) : isSuccess && chunks.length === 0 ? (
|
135 |
+
<Empty></Empty>
|
136 |
+
) : null}
|
137 |
</Flex>
|
138 |
<Pagination
|
139 |
{...pagination}
|