refactor: 优化代码结构和UI组件,移除前台和后台功能冲突的组件 (#34)

本次提交主要对代码进行了重构,移除了未使用的代码和注释,优化了部分UI组件的布局和样式。具体包括:
1. 移除了多个文件中的未使用代码和注释。
2. 调整了部分UI组件的布局,使其更加简洁和一致。
3. 更新了logo.svg文件,优化了图标的设计。
4. 修复了部分组件中的样式问题,提升了用户体验。
This commit is contained in:
zstar 2025-04-18 10:18:07 +08:00 committed by GitHub
parent fa17fd40bd
commit 61d924a4fa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 495 additions and 480 deletions

View File

@ -45,15 +45,15 @@ def signal_handler(sig, frame):
if __name__ == '__main__':
logging.info(r"""
____ ___ ______ ______ __
/ __ \ / | / ____// ____// /____ _ __
/ /_/ // /| | / / __ / /_ / // __ \| | /| / /
/ _, _// ___ |/ /_/ // __/ / // /_/ /| |/ |/ /
/_/ |_|/_/ |_|\____//_/ /_/ \____/ |__/|__/
_____ ___ _____ _____ _ _____ _ __ _____ _ _ _ _____
| _ \ / | / ___| | ___| | | / _ \ | | / / | _ \ | | | | | | / ___/
| |_| | / /| | | | | |__ | | | | | | | | __ / / | |_| | | | | | | | | |___
| _ / / / | | | | _ | __| | | | | | | | | / | / / | ___/ | | | | | | \___ \
| | \ \ / / | | | |_| | | | | |___ | |_| | | |/ |/ / | | | |___ | |_| | ___| |
|_| \_\ /_/ |_| \_____/ |_| |_____| \_____/ |___/|___/ |_| |_____| \_____/ /_____/
""")
logging.info(
f'RAGFlow version: {get_ragflow_version()}'
f'RAGFlow base version: {get_ragflow_version()}'
)
logging.info(
f'project base: {utils.file_utils.get_project_base_directory()}'

View File

@ -162,7 +162,7 @@ def _create_task_record(doc_id, chunk_ids_list):
def get_text_from_block(block):
"""从 preproc_blocks 中的一个块提取所有文本内容 (简化版)"""
"""从 preproc_blocks 中的一个块提取所有文本内容"""
block_text = ""
if "lines" in block:
for line in block.get("lines", []):
@ -352,7 +352,7 @@ def perform_parse(doc_id, doc_info, file_info):
page_idx = 0 # 默认页面索引
bbox = [0, 0, 0, 0] # 默认 bbox
# -- 尝试匹配并获取 page_idx 和 bbox --
# 匹配并获取 page_idx 和 bbox
if middle_block_idx < len(block_info_list):
block_info = block_info_list[middle_block_idx]
page_idx = block_info.get("page_idx", 0)
@ -362,7 +362,7 @@ def perform_parse(doc_id, doc_info, file_info):
# 如果 block_info_list 耗尽,打印警告
if processed_text_chunks == len(block_info_list) + 1: # 只在第一次耗尽时警告一次
print(f"[Parser-WARNING] middle_data 提供的块信息少于 content_list 中的文本块数量。后续文本块将使用默认 page/bbox。")
# -- 匹配结束 --
try:
# 上传文本块到 MinIO
@ -393,8 +393,8 @@ def perform_parse(doc_id, doc_info, file_info):
"content_ltks": content_tokens,
"content_sm_ltks": content_tokens,
"page_num_int": [page_idx + 1],
"position_int": [[page_idx + 1] + bbox_reordered], # 格式: [[page, x1, y1, x2, y2]]
"top_int": [1], # 简化处理
"position_int": [[page_idx + 1] + bbox_reordered], # 格式: [[page, x1, x2, y1, y2]]
"top_int": [1],
"create_time": current_time_es,
"create_timestamp_flt": current_timestamp_es,
"img_id": "",

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.7 KiB

After

Width:  |  Height:  |  Size: 8.3 KiB

View File

@ -1,11 +1,8 @@
import { useSetModalState, useTranslate } from '@/hooks/common-hooks';
import apiDoc from '@parent/docs/references/http_api_reference.md';
import MarkdownPreview from '@uiw/react-markdown-preview';
import { Button, Card, Flex, Space } from 'antd';
import ChatApiKeyModal from '../chat-api-key-modal';
import { usePreviewChat } from '../hooks';
import BackendServiceApi from './backend-service-api';
import MarkdownToc from './markdown-toc';
const ApiContent = ({
id,
@ -43,10 +40,10 @@ const ApiContent = ({
</Flex>
</Card>
)}
<div style={{ position: 'relative' }}>
{/* <div style={{ position: 'relative' }}>
<MarkdownToc content={apiDoc} />
</div>
<MarkdownPreview source={apiDoc}></MarkdownPreview>
<MarkdownPreview source={apiDoc}></MarkdownPreview> */}
</Flex>
{apiKeyVisible && (
<ChatApiKeyModal

View File

@ -431,7 +431,7 @@ General实体和关系提取提示来自 GitHub - microsoft/graphrag基于
knowledgeBasesMessage: '请选择',
knowledgeBasesTip: '选择关联的知识库。',
system: '系统提示词',
systemInitialValue: `你是一个智能助手,请总结知识库的内容来回答问题,请列举知识库中的数据详细回答。当所有知识库内容都与问题无关时,你的回答必须包括“知识库中未找到您要的答案!”这句话。回答需要考虑聊天历史
systemInitialValue: `你是一个学术领域的专家,请根据知识库的内容来尽可能详细的回答问题
{knowledge}
`,

View File

@ -1,23 +1,23 @@
import { ReactComponent as CancelIcon } from '@/assets/svg/cancel.svg';
import { ReactComponent as DeleteIcon } from '@/assets/svg/delete.svg';
import { ReactComponent as DisableIcon } from '@/assets/svg/disable.svg';
import { ReactComponent as EnableIcon } from '@/assets/svg/enable.svg';
import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks';
// import { ReactComponent as CancelIcon } from '@/assets/svg/cancel.svg';
// import { ReactComponent as DeleteIcon } from '@/assets/svg/delete.svg';
// import { ReactComponent as DisableIcon } from '@/assets/svg/disable.svg';
// import { ReactComponent as EnableIcon } from '@/assets/svg/enable.svg';
// import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
import { useTranslate } from '@/hooks/common-hooks';
// import {
// useRemoveNextDocument,
// useRunNextDocument,
// useSetNextDocumentStatus,
// } from '@/hooks/document-hooks';
import {
useRemoveNextDocument,
useRunNextDocument,
useSetNextDocumentStatus,
} from '@/hooks/document-hooks';
import {
DownOutlined,
FileOutlined,
FileTextOutlined,
PlusOutlined,
// DownOutlined,
// FileOutlined,
// FileTextOutlined,
// PlusOutlined,
SearchOutlined,
} from '@ant-design/icons';
import { Button, Dropdown, Flex, Input, MenuProps, Space } from 'antd';
import { useCallback, useMemo } from 'react';
import { Input, Space } from 'antd';
// import { useCallback, useMemo } from 'react';
import styles from './index.less';
@ -32,163 +32,163 @@ interface IProps {
const DocumentToolbar = ({
searchString,
selectedRowKeys,
showCreateModal,
showDocumentUploadModal,
// selectedRowKeys,
// showCreateModal,
// showDocumentUploadModal,
handleInputChange,
}: IProps) => {
const { t } = useTranslate('knowledgeDetails');
const { removeDocument } = useRemoveNextDocument();
const showDeleteConfirm = useShowDeleteConfirm();
const { runDocumentByIds } = useRunNextDocument();
const { setDocumentStatus } = useSetNextDocumentStatus();
// const { removeDocument } = useRemoveNextDocument();
// const showDeleteConfirm = useShowDeleteConfirm();
// const { runDocumentByIds } = useRunNextDocument();
// const { setDocumentStatus } = useSetNextDocumentStatus();
const actionItems: MenuProps['items'] = useMemo(() => {
return [
{
key: '1',
onClick: showDocumentUploadModal,
label: (
<div>
<Button type="link">
<Space>
<FileTextOutlined />
{t('localFiles')}
</Space>
</Button>
</div>
),
},
{ type: 'divider' },
{
key: '3',
onClick: showCreateModal,
label: (
<div>
<Button type="link">
<FileOutlined />
{t('emptyFiles')}
</Button>
</div>
),
},
];
}, [showDocumentUploadModal, showCreateModal, t]);
// const actionItems: MenuProps['items'] = useMemo(() => {
// return [
// {
// key: '1',
// onClick: showDocumentUploadModal,
// label: (
// <div>
// <Button type="link">
// <Space>
// <FileTextOutlined />
// {t('localFiles')}
// </Space>
// </Button>
// </div>
// ),
// },
// { type: 'divider' },
// {
// key: '3',
// onClick: showCreateModal,
// label: (
// <div>
// <Button type="link">
// <FileOutlined />
// {t('emptyFiles')}
// </Button>
// </div>
// ),
// },
// ];
// }, [showDocumentUploadModal, showCreateModal, t]);
const handleDelete = useCallback(() => {
showDeleteConfirm({
onOk: () => {
removeDocument(selectedRowKeys);
},
});
}, [removeDocument, showDeleteConfirm, selectedRowKeys]);
// const handleDelete = useCallback(() => {
// showDeleteConfirm({
// onOk: () => {
// removeDocument(selectedRowKeys);
// },
// });
// }, [removeDocument, showDeleteConfirm, selectedRowKeys]);
const runDocument = useCallback(
(run: number) => {
runDocumentByIds({
documentIds: selectedRowKeys,
run,
});
},
[runDocumentByIds, selectedRowKeys],
);
// const runDocument = useCallback(
// (run: number) => {
// runDocumentByIds({
// documentIds: selectedRowKeys,
// run,
// });
// },
// [runDocumentByIds, selectedRowKeys],
// );
const handleRunClick = useCallback(() => {
runDocument(1);
}, [runDocument]);
// const handleRunClick = useCallback(() => {
// runDocument(1);
// }, [runDocument]);
const handleCancelClick = useCallback(() => {
runDocument(2);
}, [runDocument]);
// const handleCancelClick = useCallback(() => {
// runDocument(2);
// }, [runDocument]);
const onChangeStatus = useCallback(
(enabled: boolean) => {
selectedRowKeys.forEach((id) => {
setDocumentStatus({ status: enabled, documentId: id });
});
},
[selectedRowKeys, setDocumentStatus],
);
// const onChangeStatus = useCallback(
// (enabled: boolean) => {
// selectedRowKeys.forEach((id) => {
// setDocumentStatus({ status: enabled, documentId: id });
// });
// },
// [selectedRowKeys, setDocumentStatus],
// );
const handleEnableClick = useCallback(() => {
onChangeStatus(true);
}, [onChangeStatus]);
// const handleEnableClick = useCallback(() => {
// onChangeStatus(true);
// }, [onChangeStatus]);
const handleDisableClick = useCallback(() => {
onChangeStatus(false);
}, [onChangeStatus]);
// const handleDisableClick = useCallback(() => {
// onChangeStatus(false);
// }, [onChangeStatus]);
const disabled = selectedRowKeys.length === 0;
// const disabled = selectedRowKeys.length === 0;
const items: MenuProps['items'] = useMemo(() => {
return [
{
key: '0',
onClick: handleEnableClick,
label: (
<Flex gap={10}>
<EnableIcon></EnableIcon>
<b>{t('enabled')}</b>
</Flex>
),
},
{
key: '1',
onClick: handleDisableClick,
label: (
<Flex gap={10}>
<DisableIcon></DisableIcon>
<b>{t('disabled')}</b>
</Flex>
),
},
{ type: 'divider' },
{
key: '2',
onClick: handleRunClick,
label: (
<Flex gap={10}>
<RunIcon></RunIcon>
<b>{t('run')}</b>
</Flex>
),
},
{
key: '3',
onClick: handleCancelClick,
label: (
<Flex gap={10}>
<CancelIcon />
<b>{t('cancel')}</b>
</Flex>
),
},
{ type: 'divider' },
{
key: '4',
onClick: handleDelete,
label: (
<Flex gap={10}>
<span className={styles.deleteIconWrapper}>
<DeleteIcon width={18} />
</span>
<b>{t('delete', { keyPrefix: 'common' })}</b>
</Flex>
),
},
];
}, [
handleDelete,
handleRunClick,
handleCancelClick,
t,
handleDisableClick,
handleEnableClick,
]);
// const items: MenuProps['items'] = useMemo(() => {
// return [
// {
// key: '0',
// onClick: handleEnableClick,
// label: (
// <Flex gap={10}>
// <EnableIcon></EnableIcon>
// <b>{t('enabled')}</b>
// </Flex>
// ),
// },
// {
// key: '1',
// onClick: handleDisableClick,
// label: (
// <Flex gap={10}>
// <DisableIcon></DisableIcon>
// <b>{t('disabled')}</b>
// </Flex>
// ),
// },
// { type: 'divider' },
// {
// key: '2',
// onClick: handleRunClick,
// label: (
// <Flex gap={10}>
// <RunIcon></RunIcon>
// <b>{t('run')}</b>
// </Flex>
// ),
// },
// {
// key: '3',
// onClick: handleCancelClick,
// label: (
// <Flex gap={10}>
// <CancelIcon />
// <b>{t('cancel')}</b>
// </Flex>
// ),
// },
// { type: 'divider' },
// {
// key: '4',
// onClick: handleDelete,
// label: (
// <Flex gap={10}>
// <span className={styles.deleteIconWrapper}>
// <DeleteIcon width={18} />
// </span>
// <b>{t('delete', { keyPrefix: 'common' })}</b>
// </Flex>
// ),
// },
// ];
// }, [
// handleDelete,
// handleRunClick,
// handleCancelClick,
// t,
// handleDisableClick,
// handleEnableClick,
// ]);
return (
<div className={styles.filter}>
<Dropdown
{/* <Dropdown
menu={{ items }}
placement="bottom"
arrow={false}
@ -200,8 +200,8 @@ const DocumentToolbar = ({
<DownOutlined />
</Space>
</Button>
</Dropdown>
<Space>
</Dropdown> */}
<Space style={{ width: '100%', justifyContent: 'flex-end' }}>
<Input
placeholder={t('searchFiles')}
value={searchString}
@ -211,11 +211,11 @@ const DocumentToolbar = ({
prefix={<SearchOutlined />}
/>
<Dropdown menu={{ items: actionItems }} trigger={['click']}>
{/* <Dropdown menu={{ items: actionItems }} trigger={['click']}>
<Button type="primary" icon={<PlusOutlined />}>
{t('addFile')}
</Button>
</Dropdown>
</Dropdown> */}
</Space>
</div>
);

View File

@ -22,7 +22,6 @@ import {
useRenameDocument,
useShowMetaModal,
} from './hooks';
import ParsingActionCell from './parsing-action-cell';
import ParsingStatusCell from './parsing-status-cell';
import RenameModal from './rename-modal';
import WebCrawlModal from './web-crawl-modal';
@ -163,19 +162,19 @@ const KnowledgeFile = () => {
return <ParsingStatusCell record={record}></ParsingStatusCell>;
},
},
{
title: t('action'),
key: 'action',
render: (_, record) => (
<ParsingActionCell
setCurrentRecord={setRecord}
showRenameModal={showRenameModal}
showChangeParserModal={showChangeParserModal}
showSetMetaModal={showSetMetaModal}
record={record}
></ParsingActionCell>
),
},
// {
// title: t('action'),
// key: 'action',
// render: (_, record) => (
// <ParsingActionCell
// setCurrentRecord={setRecord}
// showRenameModal={showRenameModal}
// showChangeParserModal={showChangeParserModal}
// showSetMetaModal={showSetMetaModal}
// record={record}
// ></ParsingActionCell>
// ),
// },
];
const finalColumns = columns.map((x) => ({

View File

@ -1,19 +1,19 @@
import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks';
import { useRemoveNextDocument } from '@/hooks/document-hooks';
import { IDocumentInfo } from '@/interfaces/database/document';
import { downloadDocument } from '@/utils/file-util';
import {
DeleteOutlined,
DownloadOutlined,
EditOutlined,
ToolOutlined,
} from '@ant-design/icons';
import { Button, Dropdown, MenuProps, Space, Tooltip } from 'antd';
import { isParserRunning } from '../utils';
// import { useShowDeleteConfirm, useTranslate } from '@/hooks/common-hooks';
// import { useRemoveNextDocument } from '@/hooks/document-hooks';
// import { IDocumentInfo } from '@/interfaces/database/document';
// import { downloadDocument } from '@/utils/file-util';
// import {
// DeleteOutlined,
// DownloadOutlined,
// EditOutlined,
// ToolOutlined,
// } from '@ant-design/icons';
import { Space } from 'antd';
// import { isParserRunning } from '../utils';
import { useCallback } from 'react';
import { DocumentType } from '../constant';
import styles from './index.less';
// import { useCallback } from 'react';
// import { DocumentType } from '../constant';
// import styles from './index.less';
interface IProps {
record: IDocumentInfo;
@ -23,83 +23,85 @@ interface IProps {
showSetMetaModal: () => void;
}
const ParsingActionCell = ({
record,
setCurrentRecord,
showRenameModal,
showChangeParserModal,
showSetMetaModal,
}: IProps) => {
const documentId = record.id;
const isRunning = isParserRunning(record.run);
const { t } = useTranslate('knowledgeDetails');
const { removeDocument } = useRemoveNextDocument();
const showDeleteConfirm = useShowDeleteConfirm();
const isVirtualDocument = record.type === DocumentType.Virtual;
const onRmDocument = () => {
if (!isRunning) {
showDeleteConfirm({
onOk: () => removeDocument([documentId]),
content: record?.parser_config?.graphrag?.use_graphrag
? t('deleteDocumentConfirmContent')
: '',
});
}
};
const onDownloadDocument = () => {
downloadDocument({
id: documentId,
filename: record.name,
});
};
const setRecord = useCallback(() => {
setCurrentRecord(record);
}, [record, setCurrentRecord]);
const onShowRenameModal = () => {
setRecord();
showRenameModal();
};
const onShowChangeParserModal = () => {
setRecord();
showChangeParserModal();
};
const onShowSetMetaModal = useCallback(() => {
setRecord();
showSetMetaModal();
}, [setRecord, showSetMetaModal]);
const chunkItems: MenuProps['items'] = [
const ParsingActionCell = (
{
key: '1',
label: (
<div className="flex flex-col">
<Button type="link" onClick={onShowChangeParserModal}>
{t('chunkMethod')}
</Button>
</div>
),
},
{ type: 'divider' },
{
key: '2',
label: (
<div className="flex flex-col">
<Button type="link" onClick={onShowSetMetaModal}>
{t('setMetaData')}
</Button>
</div>
),
},
];
// record,
// setCurrentRecord,
// showRenameModal,
// showChangeParserModal,
// showSetMetaModal,
}: IProps,
) => {
// const documentId = record.id;
// const isRunning = isParserRunning(record.run);
// const { t } = useTranslate('knowledgeDetails');
// const { removeDocument } = useRemoveNextDocument();
// const showDeleteConfirm = useShowDeleteConfirm();
// const isVirtualDocument = record.type === DocumentType.Virtual;
// const onRmDocument = () => {
// if (!isRunning) {
// showDeleteConfirm({
// onOk: () => removeDocument([documentId]),
// content: record?.parser_config?.graphrag?.use_graphrag
// ? t('deleteDocumentConfirmContent')
// : '',
// });
// }
// };
// const onDownloadDocument = () => {
// downloadDocument({
// id: documentId,
// filename: record.name,
// });
// };
// const setRecord = useCallback(() => {
// setCurrentRecord(record);
// }, [record, setCurrentRecord]);
// const onShowRenameModal = () => {
// setRecord();
// showRenameModal();
// };
// const onShowChangeParserModal = () => {
// setRecord();
// showChangeParserModal();
// };
// const onShowSetMetaModal = useCallback(() => {
// setRecord();
// showSetMetaModal();
// }, [setRecord, showSetMetaModal]);
// const chunkItems: MenuProps['items'] = [
// {
// key: '1',
// label: (
// <div className="flex flex-col">
// <Button type="link" onClick={onShowChangeParserModal}>
// {t('chunkMethod')}
// </Button>
// </div>
// ),
// },
// { type: 'divider' },
// {
// key: '2',
// label: (
// <div className="flex flex-col">
// <Button type="link" onClick={onShowSetMetaModal}>
// {t('setMetaData')}
// </Button>
// </div>
// ),
// },
// ];
return (
<Space size={0}>
{isVirtualDocument || (
{/* {isVirtualDocument || (
<Dropdown
menu={{ items: chunkItems }}
trigger={['click']}
@ -141,7 +143,7 @@ const ParsingActionCell = ({
<DownloadOutlined size={20} />
</Button>
</Tooltip>
)}
)} */}
</Space>
);
};

View File

@ -3,16 +3,7 @@ import { ReactComponent as RefreshIcon } from '@/assets/svg/refresh.svg';
import { ReactComponent as RunIcon } from '@/assets/svg/run.svg';
import { useTranslate } from '@/hooks/common-hooks';
import { IDocumentInfo } from '@/interfaces/database/document';
import {
Badge,
DescriptionsProps,
Flex,
Popconfirm,
Popover,
Space,
Tag,
} from 'antd';
import classNames from 'classnames';
import { Badge, DescriptionsProps, Flex, Popover, Space, Tag } from 'antd';
import { useTranslation } from 'react-i18next';
import reactStringReplace from 'react-string-replace';
import { DocumentType, RunningStatus, RunningStatusMap } from '../constant';
@ -121,7 +112,7 @@ export const ParsingStatusCell = ({ record }: IProps) => {
)}
</Tag>
</Popover>
<Popconfirm
{/* <Popconfirm
title={t(`knowledgeDetails.redo`, { chunkNum: record.chunk_num })}
onConfirm={handleOperationIconClick(true)}
onCancel={handleOperationIconClick(false)}
@ -139,7 +130,7 @@ export const ParsingStatusCell = ({ record }: IProps) => {
>
<OperationIcon />
</div>
</Popconfirm>
</Popconfirm> */}
</Flex>
);
};

View File

@ -65,7 +65,7 @@ const CategoryPanel = ({ chunkMethod }: { chunkMethod: string }) => {
</>
) : (
<Empty description={''} image={null}>
<p>{t('methodEmpty')}</p>
{/* <p>{t('methodEmpty')}</p> */}
<SvgIcon name={'chunk-method/chunk-empty'} width={'100%'}></SvgIcon>
</Empty>
)}

View File

@ -109,7 +109,7 @@ export const ConfigurationForm = ({ form }: { form: FormInstance }) => {
</Radio.Group>
</Form.Item>
<ConfigurationComponent></ConfigurationComponent>
{/* <ConfigurationComponent></ConfigurationComponent> */}
<Form.Item>
<div className={styles.buttonWrapper}>

View File

@ -6,7 +6,6 @@ import { Button, Card, Divider, Flex, Form, Input } from 'antd';
import { FormInstance } from 'antd/lib';
import { LabelWordCloud } from './label-word-cloud';
import { UseKnowledgeGraphItem } from '@/components/use-knowledge-graph-item';
import styles from './index.less';
type FieldType = {
@ -39,7 +38,7 @@ const TestingControl = ({ form, handleTesting }: IProps) => {
<Form name="testing" layout="vertical" form={form}>
<SimilaritySlider isTooltipShown></SimilaritySlider>
<Rerank></Rerank>
<UseKnowledgeGraphItem filedName={['use_kg']}></UseKnowledgeGraphItem>
{/* <UseKnowledgeGraphItem filedName={['use_kg']}></UseKnowledgeGraphItem> */}
<Card size="small" title={t('testText')}>
<Form.Item<FieldType>
name={'question'}

View File

@ -1,5 +1,4 @@
import KnowledgeBaseItem from '@/components/knowledge-base-item';
import { TavilyItem } from '@/components/tavily-item';
import { useTranslate } from '@/hooks/common-hooks';
import { useFetchTenantInfo } from '@/hooks/user-setting-hooks';
import { PlusOutlined } from '@ant-design/icons';
@ -130,7 +129,7 @@ const AssistantSetting = ({
>
<Switch />
</Form.Item>
<Form.Item
{/* <Form.Item
label={t('keyword')}
valuePropName="checked"
name={['prompt_config', 'keyword']}
@ -138,8 +137,8 @@ const AssistantSetting = ({
initialValue={false}
>
<Switch />
</Form.Item>
<Form.Item
</Form.Item> */}
{/* <Form.Item
label={t('tts')}
valuePropName="checked"
name={['prompt_config', 'tts']}
@ -147,8 +146,8 @@ const AssistantSetting = ({
initialValue={false}
>
<Switch onChange={handleTtsChange} />
</Form.Item>
<TavilyItem></TavilyItem>
</Form.Item> */}
{/* <TavilyItem></TavilyItem> */}
<KnowledgeBaseItem
required={false}
onChange={handleChange}

View File

@ -1,7 +1,6 @@
import SimilaritySlider from '@/components/similarity-slider';
import { DeleteOutlined, QuestionCircleOutlined } from '@ant-design/icons';
import {
Button,
Col,
Divider,
Form,
@ -20,7 +19,6 @@ import {
useImperativeHandle,
useState,
} from 'react';
import { v4 as uuid } from 'uuid';
import {
VariableTableDataType as DataType,
IPromptConfigParameters,
@ -30,7 +28,7 @@ import { EditableCell, EditableRow } from './editable-cell';
import Rerank from '@/components/rerank';
import TopNItem from '@/components/top-n-item';
import { UseKnowledgeGraphItem } from '@/components/use-knowledge-graph-item';
// import { UseKnowledgeGraphItem } from '@/components/use-knowledge-graph-item';
import { useTranslate } from '@/hooks/common-hooks';
import { useSelectPromptConfigParameters } from '../hooks';
import styles from './index.less';
@ -66,16 +64,16 @@ const PromptEngine = (
setDataSource(newData);
};
const handleAdd = () => {
setDataSource((state) => [
...state,
{
key: uuid(),
variable: '',
optional: true,
},
]);
};
// const handleAdd = () => {
// setDataSource((state) => [
// ...state,
// {
// key: uuid(),
// variable: '',
// optional: true,
// },
// ]);
// };
const handleOptionalChange = (row: DataType) => (checked: boolean) => {
const newData = [...dataSource];
@ -157,25 +155,25 @@ const PromptEngine = (
<Divider></Divider>
<SimilaritySlider isTooltipShown></SimilaritySlider>
<TopNItem></TopNItem>
<Form.Item
{/* <Form.Item
label={t('multiTurn')}
tooltip={t('multiTurnTip')}
name={['prompt_config', 'refine_multiturn']}
initialValue={false}
>
<Switch></Switch>
</Form.Item>
<UseKnowledgeGraphItem
</Form.Item> */}
{/* <UseKnowledgeGraphItem
filedName={['prompt_config', 'use_kg']}
></UseKnowledgeGraphItem>
<Form.Item
></UseKnowledgeGraphItem> */}
{/* <Form.Item
label={t('reasoning')}
tooltip={t('reasoningTip')}
name={['prompt_config', 'reasoning']}
initialValue={false}
>
<Switch></Switch>
</Form.Item>
</Form.Item> */}
<Rerank></Rerank>
<section className={classNames(styles.variableContainer)}>
<Row align={'middle'} justify="end">
@ -188,9 +186,9 @@ const PromptEngine = (
</label>
</Col>
<Col span={15} className={styles.variableAlign}>
<Button size="small" onClick={handleAdd}>
{/* <Button size="small" onClick={handleAdd}>
{t('add')}
</Button>
</Button> */}
</Col>
</Row>
{dataSource.length > 0 && (

View File

@ -103,7 +103,7 @@ export const useSelectPromptConfigParameters = (): VariableTableDataType[] => {
const parameters = currentDialog?.prompt_config?.parameters ?? [];
if (!currentDialog.id) {
// The newly created chat has a default parameter
return [{ key: uuid(), variable: 'knowledge', optional: false }];
return [{ key: uuid(), variable: 'knowledge', optional: true }];
}
return parameters.map((x) => ({
key: uuid(),

View File

@ -1,20 +1,19 @@
import NewDocumentLink from '@/components/new-document-link';
import { useTranslate } from '@/hooks/common-hooks';
import { useDownloadFile } from '@/hooks/file-manager-hooks';
// import { useDownloadFile } from '@/hooks/file-manager-hooks';
import { IFile } from '@/interfaces/database/file-manager';
import {
getExtension,
isSupportedPreviewDocumentType,
} from '@/utils/document-util';
import {
DownloadOutlined,
EditOutlined,
// DownloadOutlined,
// EditOutlined,
EyeOutlined,
LinkOutlined,
} from '@ant-design/icons';
import { Button, Space, Tooltip } from 'antd';
import { FolderInput, Trash2 } from 'lucide-react';
import { useHandleDeleteFile } from '../hooks';
// import { FolderInput, Trash2 } from 'lucide-react';
// import { useHandleDeleteFile } from '../hooks';
interface IProps {
record: IFile;
@ -27,65 +26,64 @@ interface IProps {
const ActionCell = ({
record,
setCurrentRecord,
showRenameModal,
showConnectToKnowledgeModal,
setSelectedRowKeys,
showMoveFileModal,
// setCurrentRecord,
// showRenameModal,
// showConnectToKnowledgeModal,
// setSelectedRowKeys,
// showMoveFileModal,
}: IProps) => {
const documentId = record.id;
const beingUsed = false;
// const beingUsed = false;
const { t } = useTranslate('fileManager');
const { handleRemoveFile } = useHandleDeleteFile(
[documentId],
setSelectedRowKeys,
);
const { downloadFile, loading } = useDownloadFile();
// const { handleRemoveFile } = useHandleDeleteFile(
// [documentId],
// setSelectedRowKeys,
// );
// const { downloadFile, loading } = useDownloadFile();
const extension = getExtension(record.name);
const isKnowledgeBase = record.source_type === 'knowledgebase';
// const isKnowledgeBase = record.source_type === 'knowledgebase';
const onDownloadDocument = () => {
downloadFile({
id: documentId,
filename: record.name,
});
};
// const onDownloadDocument = () => {
// downloadFile({
// id: documentId,
// filename: record.name,
// });
// };
const setRecord = () => {
setCurrentRecord(record);
};
// const setRecord = () => {
// setCurrentRecord(record);
// };
const onShowRenameModal = () => {
setRecord();
showRenameModal(record);
};
// const onShowRenameModal = () => {
// setRecord();
// showRenameModal(record);
// };
const onShowConnectToKnowledgeModal = () => {
showConnectToKnowledgeModal(record);
};
// const onShowConnectToKnowledgeModal = () => {
// showConnectToKnowledgeModal(record);
// };
const onShowMoveFileModal = () => {
showMoveFileModal([documentId]);
};
// const onShowMoveFileModal = () => {
// showMoveFileModal([documentId]);
// };
return (
<Space size={0}>
{isKnowledgeBase || (
{/* {isKnowledgeBase || (
<Tooltip title={t('addToKnowledge')}>
<Button type="text" onClick={onShowConnectToKnowledgeModal}>
<LinkOutlined size={20} />
</Button>
</Tooltip>
)}
{isKnowledgeBase || (
)} */}
{/* { {isKnowledgeBase || (
<Tooltip title={t('rename', { keyPrefix: 'common' })}>
<Button type="text" disabled={beingUsed} onClick={onShowRenameModal}>
<EditOutlined size={20} />
</Button>
</Tooltip>
)}
{isKnowledgeBase || (
)} }
{ {isKnowledgeBase || (
<Tooltip title={t('move', { keyPrefix: 'common' })}>
<Button
type="text"
@ -96,8 +94,8 @@ const ActionCell = ({
<FolderInput className="size-4" />
</Button>
</Tooltip>
)}
{isKnowledgeBase || (
)} }
{ {isKnowledgeBase || (
<Tooltip title={t('delete', { keyPrefix: 'common' })}>
<Button
type="text"
@ -108,8 +106,8 @@ const ActionCell = ({
<Trash2 className="size-4" />
</Button>
</Tooltip>
)}
{record.type !== 'folder' && (
)} }
{ {record.type !== 'folder' && (
<Tooltip title={t('download', { keyPrefix: 'common' })}>
<Button
type="text"
@ -120,7 +118,9 @@ const ActionCell = ({
<DownloadOutlined size={20} />
</Button>
</Tooltip>
)}
)} }
*/}
{isSupportedPreviewDocumentType(extension) && (
<NewDocumentLink
documentId={documentId}

View File

@ -1,33 +1,30 @@
import { useTranslate } from '@/hooks/common-hooks';
import { IListResult } from '@/hooks/file-manager-hooks';
import {
IListResult,
useFetchParentFolderList,
} from '@/hooks/file-manager-hooks';
import {
DownOutlined,
FileTextOutlined,
FolderOpenOutlined,
PlusOutlined,
// DownOutlined,
// FileTextOutlined,
// FolderOpenOutlined,
// PlusOutlined,
SearchOutlined,
} from '@ant-design/icons';
import {
Breadcrumb,
BreadcrumbProps,
Button,
Dropdown,
Flex,
// Button,
// Dropdown,
// Flex,
Input,
MenuProps,
// MenuProps,
Space,
} from 'antd';
import { useCallback, useMemo } from 'react';
// import { useCallback, useMemo } from 'react';
import {
useHandleBreadcrumbClick,
useHandleDeleteFile,
// useHandleDeleteFile,
useSelectBreadcrumbItems,
} from './hooks';
import { FolderInput, Trash2 } from 'lucide-react';
// import { FolderInput, Trash2 } from 'lucide-react';
import styles from './index.less';
interface IProps
@ -40,20 +37,20 @@ interface IProps
}
const FileToolbar = ({
selectedRowKeys,
showFolderCreateModal,
showFileUploadModal,
setSelectedRowKeys,
// selectedRowKeys,
// showFolderCreateModal,
// showFileUploadModal,
// setSelectedRowKeys,
searchString,
handleInputChange,
showMoveFileModal,
// showMoveFileModal,
}: IProps) => {
const { t } = useTranslate('knowledgeDetails');
const breadcrumbItems = useSelectBreadcrumbItems();
const { handleBreadcrumbClick } = useHandleBreadcrumbClick();
const parentFolderList = useFetchParentFolderList();
const isKnowledgeBase =
parentFolderList.at(-1)?.source_type === 'knowledgebase';
// const parentFolderList = useFetchParentFolderList();
// const isKnowledgeBase =
// parentFolderList.at(-1)?.source_type === 'knowledgebase';
const itemRender: BreadcrumbProps['itemRender'] = (
currentRoute,
@ -74,85 +71,85 @@ const FileToolbar = ({
);
};
const actionItems: MenuProps['items'] = useMemo(() => {
return [
{
key: '1',
onClick: showFileUploadModal,
label: (
<div>
<Button type="link">
<Space>
<FileTextOutlined />
{t('uploadFile', { keyPrefix: 'fileManager' })}
</Space>
</Button>
</div>
),
},
{ type: 'divider' },
{
key: '2',
onClick: showFolderCreateModal,
label: (
<div>
<Button type="link">
<Space>
<FolderOpenOutlined />
{t('newFolder', { keyPrefix: 'fileManager' })}
</Space>
</Button>
</div>
),
},
];
}, [t, showFolderCreateModal, showFileUploadModal]);
// const actionItems: MenuProps['items'] = useMemo(() => {
// return [
// {
// key: '1',
// onClick: showFileUploadModal,
// label: (
// <div>
// <Button type="link">
// <Space>
// <FileTextOutlined />
// {t('uploadFile', { keyPrefix: 'fileManager' })}
// </Space>
// </Button>
// </div>
// ),
// },
// { type: 'divider' },
// {
// key: '2',
// onClick: showFolderCreateModal,
// label: (
// <div>
// <Button type="link">
// <Space>
// <FolderOpenOutlined />
// {t('newFolder', { keyPrefix: 'fileManager' })}
// </Space>
// </Button>
// </div>
// ),
// },
// ];
// }, [t, showFolderCreateModal, showFileUploadModal]);
const { handleRemoveFile } = useHandleDeleteFile(
selectedRowKeys,
setSelectedRowKeys,
);
// const { handleRemoveFile } = useHandleDeleteFile(
// selectedRowKeys,
// setSelectedRowKeys,
// );
const handleShowMoveFileModal = useCallback(() => {
showMoveFileModal(selectedRowKeys);
}, [selectedRowKeys, showMoveFileModal]);
// const handleShowMoveFileModal = useCallback(() => {
// showMoveFileModal(selectedRowKeys);
// }, [selectedRowKeys, showMoveFileModal]);
const disabled = selectedRowKeys.length === 0;
// const disabled = selectedRowKeys.length === 0;
const items: MenuProps['items'] = useMemo(() => {
return [
{
key: '4',
onClick: handleRemoveFile,
label: (
<Flex gap={10}>
<span className="flex items-center justify-center">
<Trash2 className="size-4" />
</span>
<b>{t('delete', { keyPrefix: 'common' })}</b>
</Flex>
),
},
{
key: '5',
onClick: handleShowMoveFileModal,
label: (
<Flex gap={10}>
<span className="flex items-center justify-center">
<FolderInput className="size-4"></FolderInput>
</span>
<b>{t('move', { keyPrefix: 'common' })}</b>
</Flex>
),
},
];
}, [handleShowMoveFileModal, t, handleRemoveFile]);
// const items: MenuProps['items'] = useMemo(() => {
// return [
// {
// key: '4',
// onClick: handleRemoveFile,
// label: (
// <Flex gap={10}>
// <span className="flex items-center justify-center">
// <Trash2 className="size-4" />
// </span>
// <b>{t('delete', { keyPrefix: 'common' })}</b>
// </Flex>
// ),
// },
// {
// key: '5',
// onClick: handleShowMoveFileModal,
// label: (
// <Flex gap={10}>
// <span className="flex items-center justify-center">
// <FolderInput className="size-4"></FolderInput>
// </span>
// <b>{t('move', { keyPrefix: 'common' })}</b>
// </Flex>
// ),
// },
// ];
// }, [handleShowMoveFileModal, t, handleRemoveFile]);
return (
<div className={styles.filter}>
<Breadcrumb items={breadcrumbItems} itemRender={itemRender} />
<Space>
{isKnowledgeBase || (
{/* {isKnowledgeBase || (
<Dropdown
menu={{ items }}
placement="bottom"
@ -166,7 +163,7 @@ const FileToolbar = ({
</Space>
</Button>
</Dropdown>
)}
)} */}
<Input
placeholder={t('searchFiles')}
value={searchString}
@ -176,13 +173,13 @@ const FileToolbar = ({
prefix={<SearchOutlined />}
/>
{isKnowledgeBase || (
{/* {isKnowledgeBase || (
<Dropdown menu={{ items: actionItems }} trigger={['click']}>
<Button type="primary" icon={<PlusOutlined />}>
{t('addFile')}
</Button>
</Dropdown>
)}
)} */}
</Space>
</div>
);

View File

@ -50,13 +50,13 @@ const BedrockModal = ({
footer={(originNode: React.ReactNode) => {
return (
<Flex justify={'space-between'}>
<a
{/* <a
href="https://console.aws.amazon.com/"
target="_blank"
rel="noreferrer"
>
{t('ollamaLink', { name: llmFactory })}
</a>
</a> */}
<Space>{originNode}</Space>
</Flex>
);

View File

@ -111,10 +111,10 @@ const OllamaModal = ({
okButtonProps={{ loading }}
footer={(originNode: React.ReactNode) => {
return (
<Flex justify={'space-between'}>
<a href={url} target="_blank" rel="noreferrer">
<Flex justify={'flex-end'}>
{/* <a href={url} target="_blank" rel="noreferrer">
{t('ollamaLink', { name: llmFactory })}
</a>
</a> */}
<Space>{originNode}</Space>
</Flex>
);

View File

@ -81,13 +81,13 @@ const SystemModelSettingModal = ({
<Select options={allOptions[LlmModelType.Image2text]} allowClear />
</Form.Item>
<Form.Item
{/* <Form.Item
label={t('sequence2txtModel')}
name="asr_id"
tooltip={t('sequence2txtModelTip')}
>
<Select options={allOptions[LlmModelType.Speech2text]} allowClear />
</Form.Item>
</Form.Item> */}
<Form.Item
label={t('rerankModel')}
name="rerank_id"
@ -95,13 +95,13 @@ const SystemModelSettingModal = ({
>
<Select options={allOptions[LlmModelType.Rerank]} allowClear />
</Form.Item>
<Form.Item
{/* <Form.Item
label={t('ttsModel')}
name="tts_id"
tooltip={t('ttsModelTip')}
>
<Select options={allOptions[LlmModelType.TTS]} allowClear />
</Form.Item>
</Form.Item> */}
</Form>
</Modal>
);

View File

@ -53,13 +53,13 @@ const VolcEngineModal = ({
footer={(originNode: React.ReactNode) => {
return (
<Flex justify={'space-between'}>
<a
{/* <a
href="https://www.volcengine.com/docs/82379/1302008"
target="_blank"
rel="noreferrer"
>
{t('ollamaLink', { name: llmFactory })}
</a>
</a> */}
<Space>{originNode}</Space>
</Flex>
);