Przeglądaj źródła

文件总数,总字符数,切片总数。画面修改。

S0025136190 7 miesięcy temu
rodzic
commit
87c4f33f0d

+ 4 - 3
src/apis/index.ts

@@ -100,6 +100,7 @@ export type ModifySliceApiParams = {
     knowledgeId: string,
     sliceId: string,
     sliceText: string,
+    documentId: string,
 };
 
 // Api函数类型
@@ -146,7 +147,7 @@ export type DeleteTakaiDocumentLibApi = (id: string) => Promise<any>;
 export type FetchTakaiDocumentSettingLibApi = (id: string) => Promise<any>;
 export type ModifyTakaiDocumentSettingLibApi = (id: string, data: ModifyDocumentSettingApiParams) => Promise<any>;
 export type FetchTakaiSliceListApi = (data: FetchSliceListApiParams) => Promise<any>;
-export type deleteTakaiSliceLibApi = (sliceId: string, knowledgeId: string) => Promise<any>;
+export type deleteTakaiSliceLibApi = (sliceId: string, knowledgeId: string, documentId: string) => Promise<any>;
 export type FetchTakaiSliceDetailLibApi = (sliceId: string, knowledgeId: string) => Promise<any>;
 export type modifyTakaiSliceInfoLibApi = (data: ModifySliceApiParams) => Promise<any>;
 export type FetchTakaiChatHistoryListApi = (data: FetchChatHistoryListApiParams) => Promise<any>;
@@ -370,8 +371,8 @@ const fetchTakaiSliceListApi: FetchTakaiSliceListApi = async (data) => {
 };
 
 // 获取takai切片列表
-const deleteTakaiSliceApi: deleteTakaiSliceLibApi = async (sliceId, knowledgeId) => {
-    return api.delete(`/deepseek/api/deleteSlice/${sliceId}/${knowledgeId}`);
+const deleteTakaiSliceApi: deleteTakaiSliceLibApi = async (sliceId, knowledgeId, documentId) => {
+    return api.delete(`/deepseek/api/deleteSlice/${sliceId}/${knowledgeId}/${documentId}`);
 };
 
 // 获取takai切片详情

+ 35 - 7
src/pages/takai/knowledgeLib/detail/index.tsx

@@ -4,7 +4,7 @@ import { observer } from 'mobx-react';
 import store from './store';
 import './style.less';
 import { Button, Table, TableColumnsType, Modal, TablePaginationConfig, Upload, UploadProps, message, Spin } from 'antd';
-import { EditOutlined, DeleteOutlined, InboxOutlined, PlusOutlined, FileOutlined } from '@ant-design/icons';
+import { EditOutlined, DeleteOutlined, InboxOutlined, PlusOutlined, FileOutlined, ArrowLeftOutlined } from '@ant-design/icons';
 import InfoModal from './components/InfoModal';
 import InfoModalSetting from './components/InfoModalSetting';
 import router from '@/router';
@@ -177,13 +177,27 @@ const KnowledgeLibInfo: React.FC = () => {
             render: (text) => {
                 if (text) {
                     const size = (text / 1024 / 1024).toFixed(2);
-                    return `${size}M`;
+                    return `${size} M`;
+                }else{
+                    return '--'
+                }
+            }
+        },
+        {
+            title: '字符数量',
+            dataIndex: 'wordNum',
+            width: 100,
+            render: (text) => {
+                if (text) {
+                    return `${text}`;
+                }else{
+                    return '--'
                 }
             }
         },
         {
             title: '分段',
-            dataIndex: 'custom_separator',
+            dataIndex: 'sliceTotal',
             width: 100,
             render: (text) => {
                 if (text) {
@@ -295,6 +309,11 @@ const KnowledgeLibInfo: React.FC = () => {
                     {
                         page.total === 0 &&
                         <>
+                        <div>
+                                <Button type='primary' icon={<ArrowLeftOutlined />} onClick={() => {
+                                    router.navigate(-1);
+                                }}>返回</Button>
+                            </div>
                             <div style={{ marginTop: 20, width: '100%', height: '200px' }}>
                                 <Dragger {...props}>
                                     <p className="ant-upload-drag-icon">
@@ -316,11 +335,20 @@ const KnowledgeLibInfo: React.FC = () => {
                 {
                     page.total > 0 &&
                     <>
-                        <div>
-                            <Upload {...props}>
-                                <Button type='primary' icon={<PlusOutlined />}>上传知识文件</Button>
-                            </Upload>
+                        <div style={{ display: 'flex', justifyContent: 'space-between' }}>
+                            <div>
+                                <Button type='primary' icon={<ArrowLeftOutlined />} onClick={() => {
+                                    router.navigate(-1);
+                                }}>返回</Button>
+                            </div>
+                            <div>
+                                <Upload {...props}>
+                                    <Button type='primary' icon={<PlusOutlined />}>上传知识文件</Button>
+                                </Upload>
+                            </div>
+                            
                         </div>
+                        
 
                         <Table
                             scroll={{ x: 'max-content' }}

+ 15 - 3
src/pages/takai/knowledgeLib/list/index.tsx

@@ -58,8 +58,13 @@ const KnowledgeLibList: React.FC = () => {
             title: '使用空间',
             dataIndex: 'length',
             render: (text) => {
-                const size = (text / 1024).toFixed(2);
-                return `${size}M`;
+                if(text){
+                    const size = (text / 1024 / 1024).toFixed(2);
+                    return `${size}M`;
+                }else{
+                    return '--'
+                }
+                
             }
         },
         {
@@ -67,7 +72,7 @@ const KnowledgeLibList: React.FC = () => {
             dataIndex: 'wordNum',
             render: (text) => {
                 if(text){
-                    return `${text}`;
+                    return `${text}`;
                 }else{
                     return '--';
                 }
@@ -76,6 +81,13 @@ const KnowledgeLibList: React.FC = () => {
         {
             title: '文件数量',
             dataIndex: 'documentSize',
+            render: (text) => {
+                if(text){
+                    return `${text}`;
+                }else{
+                    return '--';
+                }
+            }
         },
         {
             title: '创建时间',

+ 13 - 3
src/pages/takai/knowledgeLib/slice/detail/index.tsx

@@ -4,6 +4,7 @@ import { useParams } from 'react-router-dom';
 import { Form, Input, Button, message } from 'antd';
 import { apis } from '@/apis';
 import router from '@/router';
+import { ArrowLeftOutlined } from '@ant-design/icons';
 
 const { TextArea } = Input;
 
@@ -78,8 +79,11 @@ const SliceDetail: React.FC = () => {
                                 autoSize={{ minRows: 20, maxRows: 5000 }}
                             />
                         </FormItem>
-
+                        <Button type='primary' icon={<ArrowLeftOutlined />} onClick={() => {
+                            router.navigate(-1);
+                        }}>返回</Button>
                         <Button
+                            style={{ marginLeft: '10px' }} 
                             type='primary'
                             onClick={() => {
                                 form.validateFields().then(async (values) => {
@@ -93,18 +97,21 @@ const SliceDetail: React.FC = () => {
                                         knowledgeId: params.knowledgeId,
                                         sliceId: params.sliceId,
                                         sliceText: values.slice_text,
+                                        documentId: params.documentId,
                                     };
                                     // 编辑应用
                                     const res = await apis.modifyTakaiSliceInfo(info);
                                     if (res.code === 200 && res.data === 1) {
-                                        const info = {
+                                        const pageInfo = {
+                                            knowledge_id: params.knowledgeId,
+                                            document_id: params.documentId,
                                             text: '',
                                             pageNum: 1,
                                             pageSize: 10,
                                         }
                                         // 刷新列表
                                         await router.navigate({ pathname: '/deepseek/knowledgeLib/slice/' + params.documentId + '/' + params.knowledgeId + '/' + params.embeddingId });
-                                        await apis.fetchTakaiSliceList(info);
+                                        // await apis.fetchTakaiSliceList(pageInfo);
                                         message.success('修改成功');
                                     }
                                 }).catch((error) => {
@@ -112,6 +119,9 @@ const SliceDetail: React.FC = () => {
                                 });
                             }}
                         >保存</Button>
+
+
+
                     </Form>
                 </div>
             </div>

+ 40 - 23
src/pages/takai/knowledgeLib/slice/index.tsx

@@ -2,7 +2,7 @@ import * as React from 'react';
 import { observer } from 'mobx-react';
 import { useParams } from 'react-router-dom';
 import { List, Button, Divider, Empty, Modal, Form, Input, message } from 'antd';
-import { SettingOutlined, DeleteOutlined } from '@ant-design/icons';
+import { SettingOutlined, DeleteOutlined, ArrowLeftOutlined } from '@ant-design/icons';
 import { apis } from '@/apis';
 import { PaginationConfig } from 'antd/es/pagination';
 import router from '@/router';
@@ -18,7 +18,8 @@ const SliceList: React.FC = () => {
     interface Item {
         slice_id: string,
         document_id: string,
-        slice_text: number,
+        slice_text: string,
+        slice_char_len: number,
     };
 
     interface PageInfo {
@@ -51,6 +52,7 @@ const SliceList: React.FC = () => {
                         slice_id: item.slice_id,
                         document_id: item.document_id,
                         slice_text: item.slice_text,
+                        slice_char_len: item.slice_char_len,
                     }
                 });
                 setList(list);
@@ -79,10 +81,10 @@ const SliceList: React.FC = () => {
 
     const deleteSlice = async (slice_id: string, knowledgeId: string) => {
         try {
-            if (!params.knowledgeId) {
-                throw new Error('知识库ID未定义,请检查路由参数');
+            if (!params.knowledgeId || !params.documentId) {
+                throw new Error('knowledgeId或documentId未定义,请检查路由参数');
             }
-            const res = await apis.deleteTakaiSlice(slice_id, params.knowledgeId);
+            const res = await apis.deleteTakaiSlice(slice_id, params.knowledgeId, params.documentId);
             if (res.code === 200 && res.data === 1) {
                 appApi.fetchList({ searchText: '' });
                 message.success('删除切片成功');
@@ -127,23 +129,32 @@ const SliceList: React.FC = () => {
     return (
         <div>
             <div className='dataExport-search'>
-                <Form form={form} layout='inline' colon={false}>
-                    <FormItem label='切片' name='text'>
-                        <Input />
-                    </FormItem>
-                    <FormItem>
-                        <Button
-                            style={{ marginRight: 16 }}
-                            type='primary'
-                            onClick={handleClickSearch}
-                        >
-                            查询
-                        </Button>
-                        <Button onClick={handleClickReset}>
-                            重置
-                        </Button>
-                    </FormItem>
-                </Form>
+                <div style={{ display: 'flex', justifyContent: 'space-between' }}>
+                    <Form form={form} layout='inline' colon={false}>
+                        <FormItem label='切片' name='text'>
+                            <Input />
+                        </FormItem>
+                        <FormItem>
+                            <Button
+                                style={{ marginRight: 16 }}
+                                type='primary'
+                                onClick={handleClickSearch}
+                            >
+                                查询
+                            </Button>
+                            <Button onClick={handleClickReset}>
+                                重置
+                            </Button>
+                        </FormItem>
+                    </Form>
+
+                    <div>
+                        <Button type='primary' icon={<ArrowLeftOutlined />} onClick={() => {
+                            router.navigate(-1);
+                        }}>返回</Button>
+                    </div>
+                </div>
+
             </div>
             {
                 list.length
@@ -173,6 +184,7 @@ const SliceList: React.FC = () => {
 
                                             <Divider plain></Divider>
                                             <div style={{ display: 'flex', justifyContent: 'space-between', overflow: 'auto' }}>
+
                                                 <div style={{ overflow: 'auto' }}>
                                                     <a style={{ marginRight: 20 }} onClick={() => {
                                                         router.navigate({
@@ -196,8 +208,13 @@ const SliceList: React.FC = () => {
                                                         <DeleteOutlined /> 删除
                                                     </a>
                                                 </div>
-                                            </div>
 
+                                                <div>
+                                                    {
+                                                        item.slice_char_len
+                                                    }
+                                                </div>
+                                            </div>
                                         </div>
                                     </List.Item>
                                 )}