feat: add corresponding icons to files (#164)

This commit is contained in:
balibabu
2024-03-28 16:18:16 +08:00
committed by GitHub
parent a5384446e3
commit b6837d4ca6
13 changed files with 137 additions and 55 deletions

View File

@@ -1,28 +1,21 @@
import { useTestChunkRetrieval } from '@/hooks/knowledgeHook';
import { Flex, Form } from 'antd';
import { useEffect } from 'react';
import { useDispatch } from 'umi';
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 testChunk = useTestChunkRetrieval();
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,
},
});
testChunk(values);
};
useEffect(() => {

View File

@@ -2,10 +2,9 @@ import SimilaritySlider from '@/components/similarity-slider';
import { Button, Card, Divider, Flex, Form, Input, Slider, Tag } from 'antd';
import { FormInstance } from 'antd/lib';
import { useOneNamespaceEffectsLoading } from '@/hooks/storeHooks';
import styles from './index.less';
const list = [1, 2, 3];
type FieldType = {
similarity_threshold?: number;
vector_similarity_weight?: number;
@@ -20,6 +19,9 @@ interface IProps {
const TestingControl = ({ form, handleTesting }: IProps) => {
const question = Form.useWatch('question', { form, preserve: true });
const loading = useOneNamespaceEffectsLoading('testingModel', [
'testDocumentChunk',
]);
const buttonDisabled =
!question || (typeof question === 'string' && question.trim() === '');
@@ -65,6 +67,7 @@ const TestingControl = ({ form, handleTesting }: IProps) => {
size="small"
onClick={handleTesting}
disabled={buttonDisabled}
loading={loading}
>
Testing
</Button>

View File

@@ -35,9 +35,11 @@
}
.image {
width: 100px;
}
.imagePreview {
display: block;
width: 260px;
object-fit: contain;
}
}
.imagePreview {
display: block;
max-width: 45vw;
max-height: 40vh;
}

View File

@@ -104,7 +104,7 @@ const TestingResult = ({ handleTesting }: IProps) => {
<Flex gap={'middle'}>
{x.img_id && (
<Popover
placement="topRight"
placement="left"
content={
<Image
id={x.img_id}

View File

@@ -1,6 +1,7 @@
import { ReactComponent as NavigationPointerIcon } from '@/assets/svg/navigation-pointer.svg';
import NewDocumentLink from '@/components/new-document-link';
import { ITestingDocument } from '@/interfaces/database/knowledge';
import { isPdf } from '@/utils/documentUtils';
import { Table, TableProps } from 'antd';
import { useDispatch, useSelector } from 'umi';
@@ -33,8 +34,8 @@ const SelectFiles = ({ handleTesting }: IProps) => {
title: 'View',
key: 'view',
width: 50,
render: (_, { doc_id }) => (
<NewDocumentLink documentId={doc_id}>
render: (_, { doc_id, doc_name }) => (
<NewDocumentLink documentId={doc_id} preventDefault={!isPdf(doc_name)}>
<NavigationPointerIcon />
</NewDocumentLink>
),