From 59c64e29b982854784cce692913cbc859bb60452 Mon Sep 17 00:00:00 2001 From: billchen Date: Mon, 4 Mar 2024 15:54:19 +0800 Subject: [PATCH 1/2] feat: add Upload to AssistantSetting --- .../components/knowledge-file/index.tsx | 22 +++++++++------ .../assistant-setting.tsx | 28 +++++++++++++++++-- .../chat/chat-configuration-modal/index.tsx | 19 +++++++++++-- web/src/pages/chat/index.tsx | 5 ++-- 4 files changed, 58 insertions(+), 16 deletions(-) diff --git a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx index eafed785ef..70576f86ff 100644 --- a/web/src/pages/add-knowledge/components/knowledge-file/index.tsx +++ b/web/src/pages/add-knowledge/components/knowledge-file/index.tsx @@ -23,7 +23,7 @@ import { import type { ColumnsType } from 'antd/es/table'; import { PaginationProps } from 'antd/lib'; import React, { useCallback, useEffect, useMemo, useState } from 'react'; -import { Link, useDispatch, useNavigate, useSelector } from 'umi'; +import { useDispatch, useNavigate, useSelector } from 'umi'; import CreateEPModal from './createEFileModal'; import styles from './index.less'; import ParsingActionCell from './parsing-action-cell'; @@ -144,19 +144,22 @@ const KnowledgeFile = () => { }); }, [dispatch]); + const linkToUploadPage = useCallback(() => { + navigate(`/knowledge/dataset/upload?id=${knowledgeBaseId}`); + }, [navigate, knowledgeBaseId]); + const actionItems: MenuProps['items'] = useMemo(() => { return [ { key: '1', + onClick: linkToUploadPage, label: (
), @@ -164,9 +167,10 @@ const KnowledgeFile = () => { { type: 'divider' }, { key: '2', + onClick: showCEFModal, label: (
- @@ -175,7 +179,7 @@ const KnowledgeFile = () => { // disabled: true, }, ]; - }, [knowledgeBaseId, showCEFModal]); + }, [linkToUploadPage, showCEFModal]); const toChunk = (id: string) => { navigate( diff --git a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx index 0ce8af7c74..c2e9c4a966 100644 --- a/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx +++ b/web/src/pages/chat/chat-configuration-modal/assistant-setting.tsx @@ -1,9 +1,10 @@ -import { Form, Input, Select } from 'antd'; +import { Form, Input, Select, Upload } from 'antd'; import classNames from 'classnames'; import { ISegmentedContentProps } from '../interface'; import { useFetchKnowledgeList } from '@/hooks/knowledgeHook'; +import { PlusOutlined } from '@ant-design/icons'; import styles from './index.less'; const AssistantSetting = ({ show }: ISegmentedContentProps) => { @@ -13,6 +14,13 @@ const AssistantSetting = ({ show }: ISegmentedContentProps) => { value: x.id, })); + const normFile = (e: any) => { + if (Array.isArray(e)) { + return e; + } + return e?.fileList; + }; + return (
{ > - - + + + +