File size: 1,115 Bytes
1a156e6
0a903c7
 
 
1a156e6
 
 
0a903c7
 
 
1a156e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
0a903c7
 
1a156e6
 
 
 
 
0a903c7
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Flex, Form } from 'antd';
import TestingControl from './testing-control';
import TestingResult from './testing-result';

import { useKnowledgeBaseId } from '@/hooks/knowledgeHook';
import { useEffect } from 'react';
import { useDispatch } from 'umi';
import styles from './index.less';

const KnowledgeTesting = () => {
  const [form] = Form.useForm();

  const dispatch = useDispatch();
  const knowledgeBaseId = useKnowledgeBaseId();

  const handleTesting = async () => {
    const values = await form.validateFields();
    console.info(values);
    dispatch({
      type: 'testingModel/testDocumentChunk',
      payload: {
        ...values,
        kb_id: knowledgeBaseId,
      },
    });
  };

  useEffect(() => {
    return () => {
      dispatch({ type: 'testingModel/reset' });
    };
  }, [dispatch]);

  return (
    <Flex className={styles.testingWrapper} gap={16}>
      <TestingControl
        form={form}
        handleTesting={handleTesting}
      ></TestingControl>
      <TestingResult handleTesting={handleTesting}></TestingResult>
    </Flex>
  );
};

export default KnowledgeTesting;