1
- import { FormContainer } from '@/components/form-container' ;
2
- import { FilterButton } from '@/components/list-filter-bar' ;
3
- import { FilterPopover } from '@/components/list-filter-bar/filter-popover' ;
4
- import { FilterCollection } from '@/components/list-filter-bar/interface' ;
5
1
import { Button } from '@/components/ui/button' ;
6
- import { RAGFlowPagination } from '@/components/ui/ragflow-pagination' ;
7
- import { useTranslate } from '@/hooks/common-hooks' ;
8
2
import { useTestRetrieval } from '@/hooks/use-knowledge-request' ;
9
- import { ITestingChunk } from '@/interfaces/database/knowledge' ;
10
- import { camelCase } from 'lodash' ;
11
3
import { Plus } from 'lucide-react' ;
12
- import { useMemo } from 'react' ;
4
+ import { useCallback , useState } from 'react' ;
13
5
import { TopTitle } from '../dataset-title' ;
14
6
import TestingForm from './testing-form' ;
7
+ import { TestingResult } from './testing-result' ;
15
8
16
- const similarityList : Array < { field : keyof ITestingChunk ; label : string } > = [
17
- { field : 'similarity' , label : 'Hybrid Similarity' } ,
18
- { field : 'term_similarity' , label : 'Term Similarity' } ,
19
- { field : 'vector_similarity' , label : 'Vector Similarity' } ,
20
- ] ;
21
-
22
- const ChunkTitle = ( { item } : { item : ITestingChunk } ) => {
23
- const { t } = useTranslate ( 'knowledgeDetails' ) ;
24
- return (
25
- < div className = "flex gap-3 text-xs text-text-sub-title-invert italic" >
26
- { similarityList . map ( ( x ) => (
27
- < div key = { x . field } className = "space-x-1" >
28
- < span > { ( ( item [ x . field ] as number ) * 100 ) . toFixed ( 2 ) } </ span >
29
- < span > { t ( camelCase ( x . field ) ) } </ span >
30
- </ div >
31
- ) ) }
32
- </ div >
33
- ) ;
34
- } ;
9
+ function Vertical ( ) {
10
+ return < div > xxx</ div > ;
11
+ }
35
12
36
13
export default function RetrievalTesting ( ) {
37
14
const {
@@ -43,22 +20,18 @@ export default function RetrievalTesting() {
43
20
page,
44
21
pageSize,
45
22
handleFilterSubmit,
23
+ filterValue,
46
24
} = useTestRetrieval ( ) ;
47
25
48
- const filters : FilterCollection [ ] = useMemo ( ( ) => {
49
- return [
50
- {
51
- field : 'doc_ids' ,
52
- label : 'File' ,
53
- list :
54
- data . doc_aggs ?. map ( ( x ) => ( {
55
- id : x . doc_id ,
56
- label : x . doc_name ,
57
- count : x . count ,
58
- } ) ) ?? [ ] ,
59
- } ,
60
- ] ;
61
- } , [ data . doc_aggs ] ) ;
26
+ const [ count , setCount ] = useState ( 1 ) ;
27
+
28
+ const addCount = useCallback ( ( ) => {
29
+ setCount ( 2 ) ;
30
+ } , [ ] ) ;
31
+
32
+ const removeCount = useCallback ( ( ) => {
33
+ setCount ( 1 ) ;
34
+ } , [ ] ) ;
62
35
63
36
return (
64
37
< div className = "p-5" >
@@ -70,47 +43,66 @@ export default function RetrievalTesting() {
70
43
> </ TopTitle >
71
44
< Button > Save as Preset</ Button >
72
45
</ section >
73
- < section className = "flex divide-x h-full" >
74
- < div className = "p-4 flex-1" >
75
- < div className = "flex justify-between pb-2.5" >
76
- < span className = "text-text-title font-semibold text-2xl" >
77
- Test setting
78
- </ span >
79
- < Button variant = { 'outline' } >
80
- < Plus /> Add New Test
81
- </ Button >
82
- </ div >
83
- < TestingForm
84
- loading = { loading }
85
- setValues = { setValues }
86
- refetch = { refetch }
87
- > </ TestingForm >
88
- </ div >
89
- < div className = "p-4 flex-1" >
90
- < div className = "flex justify-between pb-2.5" >
91
- < span className = "text-text-title font-semibold text-2xl" >
92
- Test results
93
- </ span >
94
- < FilterPopover filters = { filters } onChange = { handleFilterSubmit } >
95
- < FilterButton > </ FilterButton >
96
- </ FilterPopover >
46
+ { count === 1 ? (
47
+ < section className = "flex divide-x h-full" >
48
+ < div className = "p-4 flex-1" >
49
+ < div className = "flex justify-between pb-2.5" >
50
+ < span className = "text-text-title font-semibold text-2xl" >
51
+ Test setting
52
+ </ span >
53
+ < Button variant = { 'outline' } onClick = { addCount } >
54
+ < Plus /> Add New Test
55
+ </ Button >
56
+ </ div >
57
+ < TestingForm
58
+ loading = { loading }
59
+ setValues = { setValues }
60
+ refetch = { refetch }
61
+ > </ TestingForm >
97
62
</ div >
98
- < section className = "flex flex-col gap-5 overflow-auto h-[76vh] mb-5" >
99
- { data . chunks ?. map ( ( x ) => (
100
- < FormContainer key = { x . chunk_id } className = "px-5 py-2.5" >
101
- < ChunkTitle item = { x } > </ ChunkTitle >
102
- < p className = "!mt-2.5" > { x . content_with_weight } </ p >
103
- </ FormContainer >
104
- ) ) }
105
- </ section >
106
- < RAGFlowPagination
107
- total = { data . total }
108
- onChange = { onPaginationChange }
109
- current = { page }
63
+ < TestingResult
64
+ data = { data }
65
+ page = { page }
110
66
pageSize = { pageSize }
111
- > </ RAGFlowPagination >
112
- </ div >
113
- </ section >
67
+ filterValue = { filterValue }
68
+ handleFilterSubmit = { handleFilterSubmit }
69
+ onPaginationChange = { onPaginationChange }
70
+ > </ TestingResult >
71
+ </ section >
72
+ ) : (
73
+ < section className = "flex gap-2" >
74
+ < div className = "flex-1" >
75
+ < TestingForm
76
+ loading = { loading }
77
+ setValues = { setValues }
78
+ refetch = { refetch }
79
+ > </ TestingForm >
80
+ < TestingResult
81
+ data = { data }
82
+ page = { page }
83
+ pageSize = { pageSize }
84
+ filterValue = { filterValue }
85
+ handleFilterSubmit = { handleFilterSubmit }
86
+ onPaginationChange = { onPaginationChange }
87
+ > </ TestingResult >
88
+ </ div >
89
+ < div className = "flex-1" >
90
+ < TestingForm
91
+ loading = { loading }
92
+ setValues = { setValues }
93
+ refetch = { refetch }
94
+ > </ TestingForm >
95
+ < TestingResult
96
+ data = { data }
97
+ page = { page }
98
+ pageSize = { pageSize }
99
+ filterValue = { filterValue }
100
+ handleFilterSubmit = { handleFilterSubmit }
101
+ onPaginationChange = { onPaginationChange }
102
+ > </ TestingResult >
103
+ </ div >
104
+ </ section >
105
+ ) }
114
106
</ div >
115
107
) ;
116
108
}
0 commit comments