From 768073ddac486af5d4072cdccbaf13abe5382d3e Mon Sep 17 00:00:00 2001 From: Joel Date: Thu, 5 Dec 2024 17:34:29 +0800 Subject: [PATCH 1/9] feat: batch action ui --- .../detail/completed/batch-action.tsx | 21 ++++++++++++++----- .../components/datasets/documents/list.tsx | 20 ++++++++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) diff --git a/web/app/components/datasets/documents/detail/completed/batch-action.tsx b/web/app/components/datasets/documents/detail/completed/batch-action.tsx index 7a55784e70..b464334c14 100644 --- a/web/app/components/datasets/documents/detail/completed/batch-action.tsx +++ b/web/app/components/datasets/documents/detail/completed/batch-action.tsx @@ -1,14 +1,15 @@ import React, { type FC } from 'react' -import { RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine } from '@remixicon/react' +import { RiArchive2Line, RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine } from '@remixicon/react' import Divider from '@/app/components/base/divider' import classNames from '@/utils/classnames' type IBatchActionProps = { className?: string selectedIds: string[] - onBatchEnable: () => Promise - onBatchDisable: () => Promise - onBatchDelete: () => Promise + onBatchEnable: () => void + onBatchDisable: () => void + onBatchDelete: () => void + onArchive?: () => void onCancel: () => void } @@ -17,6 +18,7 @@ const BatchAction: FC = ({ selectedIds, onBatchEnable, onBatchDisable, + onArchive, onBatchDelete, onCancel, }) => { @@ -42,15 +44,24 @@ const BatchAction: FC = ({ Disable + {onArchive && ( +
+ + +
+ )}
+ diff --git a/web/app/components/datasets/documents/list.tsx b/web/app/components/datasets/documents/list.tsx index cd7162603b..a30ec339e4 100644 --- a/web/app/components/datasets/documents/list.tsx +++ b/web/app/components/datasets/documents/list.tsx @@ -21,6 +21,7 @@ import { Globe01 } from '../../base/icons/src/vender/line/mapsAndTravel' import ChunkingModeLabel from '../common/chunking-mode-label' import s from './style.module.css' import RenameModal from './rename-modal' +import BatchAction from './detail/completed/batch-action' import cn from '@/utils/classnames' import Switch from '@/app/components/base/switch' import Divider from '@/app/components/base/divider' @@ -576,6 +577,25 @@ const DocumentList: FC = ({ })} + {(selectedIds.length > 0) && ( + { }} + onBatchEnable={() => { + + }} + onBatchDisable={() => { + + }} + onBatchDelete={() => { + + }} + onCancel={() => { + onSelectedIdChange([]) + }} + /> + )} {/* Show Pagination only if the total is more than the limit */} {pagination.total && pagination.total > (pagination.limit || 10) && ( Date: Fri, 6 Dec 2024 11:20:03 +0800 Subject: [PATCH 2/9] chore: action i18n and remove confirm --- .../detail/completed/batch-action.tsx | 35 +++++++++++++++---- web/i18n/en-US/dataset.ts | 8 +++++ web/i18n/zh-Hans/dataset.ts | 8 +++++ 3 files changed, 44 insertions(+), 7 deletions(-) diff --git a/web/app/components/datasets/documents/detail/completed/batch-action.tsx b/web/app/components/datasets/documents/detail/completed/batch-action.tsx index b464334c14..542a861723 100644 --- a/web/app/components/datasets/documents/detail/completed/batch-action.tsx +++ b/web/app/components/datasets/documents/detail/completed/batch-action.tsx @@ -1,8 +1,12 @@ import React, { type FC } from 'react' import { RiArchive2Line, RiCheckboxCircleLine, RiCloseCircleLine, RiDeleteBinLine } from '@remixicon/react' +import { useTranslation } from 'react-i18next' +import { useBoolean } from 'ahooks' import Divider from '@/app/components/base/divider' import classNames from '@/utils/classnames' +import Confirm from '@/app/components/base/confirm' +const i18nPrefix = 'dataset.batchAction' type IBatchActionProps = { className?: string selectedIds: string[] @@ -22,6 +26,11 @@ const BatchAction: FC = ({ onBatchDelete, onCancel, }) => { + const { t } = useTranslation() + const [isShowDeleteConfirm, { + setTrue: showDeleteConfirm, + setFalse: hideDeleteConfirm, + }] = useBoolean(false) return (
@@ -29,41 +38,53 @@ const BatchAction: FC = ({ {selectedIds.length} - Selected + {t(`${i18nPrefix}.selected`)}
{onArchive && (
)}
-
+ { + isShowDeleteConfirm && ( + + ) + } ) } diff --git a/web/i18n/en-US/dataset.ts b/web/i18n/en-US/dataset.ts index 59f105adca..75eda76a24 100644 --- a/web/i18n/en-US/dataset.ts +++ b/web/i18n/en-US/dataset.ts @@ -150,6 +150,14 @@ const translation = { nTo1RetrievalLegacy: 'N-to-1 retrieval will be officially deprecated from September. It is recommended to use the latest Multi-path retrieval to obtain better results. ', nTo1RetrievalLegacyLink: 'Learn more', nTo1RetrievalLegacyLinkText: ' N-to-1 retrieval will be officially deprecated in September.', + batchAction: { + selected: 'Selected', + enable: 'Enable', + disable: 'Disable', + archive: 'Archive', + delete: 'Delete', + cancel: 'Cancel', + }, } export default translation diff --git a/web/i18n/zh-Hans/dataset.ts b/web/i18n/zh-Hans/dataset.ts index 801a974cbc..1d4897a69f 100644 --- a/web/i18n/zh-Hans/dataset.ts +++ b/web/i18n/zh-Hans/dataset.ts @@ -150,6 +150,14 @@ const translation = { nTo1RetrievalLegacy: '9 月 1 日起我们将不再提供此能力,推荐使用最新的多路召回获得更好的检索效果。', nTo1RetrievalLegacyLink: '了解更多', nTo1RetrievalLegacyLinkText: '9 月 1 日起我们将不再提供此能力。', + batchAction: { + selected: '已选择', + enable: '启用', + disable: '禁用', + archive: '归档', + delete: '删除', + cancel: '取消', + }, } export default translation From f3cfcb757e2fd9b29090097d5ed350ddc00e6917 Mon Sep 17 00:00:00 2001 From: Joel Date: Fri, 6 Dec 2024 11:53:28 +0800 Subject: [PATCH 3/9] feat: document update change to batch api --- .../components/datasets/documents/list.tsx | 39 +++++++++++++++++-- web/models/datasets.ts | 17 ++++++++ web/service/knowledge/use-document.ts | 18 ++++++++- 3 files changed, 68 insertions(+), 6 deletions(-) diff --git a/web/app/components/datasets/documents/list.tsx b/web/app/components/datasets/documents/list.tsx index a30ec339e4..1c9817136b 100644 --- a/web/app/components/datasets/documents/list.tsx +++ b/web/app/components/datasets/documents/list.tsx @@ -33,7 +33,7 @@ import type { ColorMap, IndicatorProps } from '@/app/components/header/indicator import Indicator from '@/app/components/header/indicator' import { asyncRunSafe } from '@/utils' import { formatNumber } from '@/utils/format' -import { archiveDocument, deleteDocument, disableDocument, enableDocument, syncDocument, syncWebsite, unArchiveDocument } from '@/service/datasets' +import { deleteDocument, disableDocument, enableDocument, syncDocument, syncWebsite, unArchiveDocument } from '@/service/datasets' import NotionIcon from '@/app/components/base/notion-icon' import ProgressBar from '@/app/components/base/progress-bar' import { ChuckingMode, DataSourceType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets' @@ -43,6 +43,8 @@ import { useDatasetDetailContextWithSelector as useDatasetDetailContext } from ' import type { Props as PaginationProps } from '@/app/components/base/pagination' import Pagination from '@/app/components/base/pagination' import Checkbox from '@/app/components/base/checkbox' +import { useDocumentBatchAction } from '@/service/knowledge/use-document' +import { BatchActionType } from '@/models/datasets' export const useIndexStatus = () => { const { t } = useTranslation() @@ -88,15 +90,34 @@ export const StatusItem: FC<{ const { enabled = false, archived = false, id = '' } = detail || {} const { notify } = useContext(ToastContext) const { t } = useTranslation() + const { mutateAsync: documentBatchActon } = useDocumentBatchAction() const onOperate = async (operationName: OperationName) => { let opApi = deleteDocument switch (operationName) { case 'enable': - opApi = enableDocument + opApi = async ({ + datasetId, + documentId, + }) => { + return documentBatchActon({ + action: BatchActionType.enable, + datasetId, + documentIds: [documentId], + }) + } break case 'disable': - opApi = disableDocument + opApi = async ({ + datasetId, + documentId, + }) => { + return documentBatchActon({ + action: BatchActionType.disable, + datasetId, + documentIds: [documentId], + }) + } break } const [e] = await asyncRunSafe(opApi({ datasetId, documentId: id }) as Promise) @@ -180,6 +201,7 @@ export const OperationAction: FC<{ const { notify } = useContext(ToastContext) const { t } = useTranslation() const router = useRouter() + const { mutateAsync: documentBatchActon } = useDocumentBatchAction() const isListScene = scene === 'list' @@ -187,7 +209,16 @@ export const OperationAction: FC<{ let opApi = deleteDocument switch (operationName) { case 'archive': - opApi = archiveDocument + opApi = async ({ + datasetId, + documentId, + }) => { + return documentBatchActon({ + action: BatchActionType.archive, + datasetId, + documentIds: [documentId], + }) + } break case 'un_archive': opApi = unArchiveDocument diff --git a/web/models/datasets.ts b/web/models/datasets.ts index 900783e78f..c10b45b066 100644 --- a/web/models/datasets.ts +++ b/web/models/datasets.ts @@ -614,3 +614,20 @@ export type ChildChunkDetail = { created_at: number type: ChildChunkType } + +export type UpdateDocumentParams = { + datasetId: string + documentId: string +} + +export enum BatchActionType { + enable = 'enable', + disable = 'disable', + archive = 'archive', +} + +export type UpdateDocumentBatchParams = { + datasetId: string + documentIds: string[] + action: BatchActionType +} diff --git a/web/service/knowledge/use-document.ts b/web/service/knowledge/use-document.ts index 909f33ac67..b31d8c9fa5 100644 --- a/web/service/knowledge/use-document.ts +++ b/web/service/knowledge/use-document.ts @@ -1,8 +1,10 @@ import { + useMutation, useQuery, } from '@tanstack/react-query' -import { get } from '../base' -import type { SimpleDocumentDetail } from '@/models/datasets' +import { get, patch } from '../base' +import type { SimpleDocumentDetail, UpdateDocumentBatchParams } from '@/models/datasets' +import type { CommonResponse } from '@/models/common' const NAME_SPACE = 'knowledge/document' @@ -23,3 +25,15 @@ export const useDocumentList = (payload: { }), }) } + +const toBatchDocumentsIdParams = (documentIds: string[]) => { + return documentIds.map(id => `document_id=${id}`).join('=') +} + +export const useDocumentBatchAction = () => { + return useMutation({ + mutationFn: ({ action, datasetId, documentIds }: UpdateDocumentBatchParams) => { + return patch(`/datasets/${datasetId}/documents/status/${action}?${toBatchDocumentsIdParams(documentIds)}`) + }, + }) +} From a893309b73f6ba9227585c3916fb577fb75d643c Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Fri, 6 Dec 2024 13:27:32 +0800 Subject: [PATCH 4/9] wip: create datasets --- .../datasets/create/step-two/index.tsx | 96 ++++++++----------- web/models/datasets.ts | 7 +- web/service/knowledge/use-create-dataset.ts | 4 +- 3 files changed, 45 insertions(+), 62 deletions(-) diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index 9ecd885c51..5e50218de6 100644 --- a/web/app/components/datasets/create/step-two/index.tsx +++ b/web/app/components/datasets/create/step-two/index.tsx @@ -27,7 +27,7 @@ import { OptionCard } from './option-card' import LanguageSelect from './language-select' import { DelimiterInput, MaxLengthInput, OverlapInput } from './inputs' import cn from '@/utils/classnames' -import type { CrawlOptions, CrawlResultItem, CreateDocumentReq, CustomFile, FullDocumentDetail, PreProcessingRule, ProcessRule, Rules, createDocumentResponse } from '@/models/datasets' +import type { CrawlOptions, CrawlResultItem, CreateDocumentReq, CustomFile, FullDocumentDetail, ParentMode, PreProcessingRule, ProcessRule, Rules, createDocumentResponse } from '@/models/datasets' import Button from '@/app/components/base/button' import FloatRightContainer from '@/app/components/base/float-right-container' @@ -38,7 +38,7 @@ import { ensureRerankModelSelected, isReRankModelSelected } from '@/app/componen import Toast from '@/app/components/base/toast' import type { NotionPage } from '@/models/common' import { DataSourceProvider } from '@/models/common' -import { DataSourceType, DocForm } from '@/models/datasets' +import { ChuckingMode, DataSourceType } from '@/models/datasets' import { useDatasetDetailContext } from '@/context/dataset-detail' import I18n from '@/context/i18n' import { RETRIEVE_METHOD } from '@/types/app' @@ -96,7 +96,7 @@ export enum IndexingType { const DEFAULT_SEGMENT_IDENTIFIER = '\\n\\n' type ParentChildConfig = { - chunkForContext: 'paragraph' | 'full_doc' + chunkForContext: ParentMode parent: { delimiter: string maxLength: number @@ -168,8 +168,8 @@ const StepTwo = ({ // QA Related const [isLanguageSelectDisabled, setIsLanguageSelectDisabled] = useState(false) - const [docForm, setDocForm] = useState( - (datasetId && documentDetail) ? documentDetail.doc_form : DocForm.TEXT, + const [docForm, setDocForm] = useState( + (datasetId && documentDetail) ? documentDetail.doc_form as ChuckingMode : ChuckingMode.text, ) const [docLanguage, setDocLanguage] = useState( @@ -181,27 +181,28 @@ const StepTwo = ({ const getIndexing_technique = () => indexingType || indexType const getProcessRule = () => { - const processRule: ProcessRule = { - rules: {} as any, // api will check this. It will be removed after api refactored. - mode: segmentationType, - } - if (segmentationType === SegmentType.CUSTOM) { - const ruleObj = { + return { + rules: { pre_processing_rules: rules, segmentation: { separator: unescape(segmentIdentifier), max_tokens: maxChunkLength, chunk_overlap: overlap, }, - } - // @ts-expect-error will be removed after api refactored. - processRule.rules = ruleObj - } - return processRule + parent_mode: parentChildConfig.chunkForContext, + subchunk_segmentation: { + separator: parentChildConfig.child.delimiter, + max_tokens: parentChildConfig.child.maxLength, + }, + }, // api will check this. It will be removed after api refactored. + mode: docForm === ChuckingMode.parentChild + ? 'hierarchical' + : segmentationType, + } as ProcessRule } const fileIndexingEstimateQuery = useFetchFileIndexingEstimateForFile({ - docForm: docForm as DocForm, + docForm, docLanguage, dataSourceType: DataSourceType.FILE, files, @@ -210,7 +211,7 @@ const StepTwo = ({ dataset_id: datasetId!, }) const notionIndexingEstimateQuery = useFetchFileIndexingEstimateForNotion({ - docForm: docForm as DocForm, + docForm, docLanguage, dataSourceType: DataSourceType.NOTION, notionPages, @@ -220,7 +221,7 @@ const StepTwo = ({ }) const websiteIndexingEstimateQuery = useFetchFileIndexingEstimateForWeb({ - docForm: docForm as DocForm, + docForm, docLanguage, dataSourceType: DataSourceType.WEB, websitePages, @@ -481,29 +482,10 @@ const StepTwo = ({ isSetting && onSave && onSave() } - const handleDocformSwitch = (isQAMode: boolean) => { - if (isQAMode) - setDocForm(DocForm.QA) - else - setDocForm(DocForm.TEXT) - } - - const previewSwitch = () => { - setIsLanguageSelectDisabled(true) - fetchEstimate() - } - - const handleSelect = (language: string) => { - setDocLanguage(language) - // Switch language, re-cutter - if (docForm === DocForm.QA) - previewSwitch() - } - const changeToEconomicalType = () => { if (!hasSetIndexType) { setIndexType(IndexingType.ECONOMICAL) - setDocForm(DocForm.TEXT) + setDocForm(ChuckingMode.text) } } @@ -520,8 +502,8 @@ const StepTwo = ({ }, []) useEffect(() => { - if (indexingType === IndexingType.ECONOMICAL && docForm === DocForm.QA) - setDocForm(DocForm.TEXT) + if (indexingType === IndexingType.ECONOMICAL && docForm === ChuckingMode.qa) + setDocForm(ChuckingMode.text) }, [indexingType, docForm]) useEffect(() => { @@ -557,8 +539,8 @@ const StepTwo = ({ icon={{t('datasetCreation.stepTwo.general')}} activeHeaderClassName='bg-gradient-to-r from-[#EFF0F9] to-[#F9FAFB]' description={t('datasetCreation.stepTwo.generalTip')} - isActive={SegmentType.AUTO === segmentationType} - onClick={() => setSegmentationType(SegmentType.AUTO)} + isActive={docForm === ChuckingMode.qa || docForm === ChuckingMode.text} + onClick={() => setDocForm(ChuckingMode.text)} actions={ <> diff --git a/web/app/components/datasets/documents/list.tsx b/web/app/components/datasets/documents/list.tsx index ac3774cda8..ce35e78a8a 100644 --- a/web/app/components/datasets/documents/list.tsx +++ b/web/app/components/datasets/documents/list.tsx @@ -28,14 +28,14 @@ import Divider from '@/app/components/base/divider' import Popover from '@/app/components/base/popover' import Confirm from '@/app/components/base/confirm' import Tooltip from '@/app/components/base/tooltip' -import { ToastContext } from '@/app/components/base/toast' +import Toast, { ToastContext } from '@/app/components/base/toast' import type { ColorMap, IndicatorProps } from '@/app/components/header/indicator' import Indicator from '@/app/components/header/indicator' import { asyncRunSafe } from '@/utils' import { formatNumber } from '@/utils/format' import NotionIcon from '@/app/components/base/notion-icon' import ProgressBar from '@/app/components/base/progress-bar' -import { ChuckingMode, DataSourceType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets' +import { ChuckingMode, DataSourceType, DocumentActionType, type DocumentDisplayStatus, type SimpleDocumentDetail } from '@/models/datasets' import type { CommonResponse } from '@/models/common' import useTimestamp from '@/hooks/use-timestamp' import { useDatasetDetailContextWithSelector as useDatasetDetailContext } from '@/context/dataset-detail' @@ -103,11 +103,11 @@ export const StatusItem: FC<{ break } const [e] = await asyncRunSafe(opApi({ datasetId, documentId: id }) as Promise) - if (!e) + if (!e) { notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) - else - notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) - onUpdate?.(operationName) + onUpdate?.(operationName) + } + else { notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) } } const { run: handleSwitch } = useDebounceFn((operationName: OperationName) => { @@ -219,13 +219,13 @@ export const OperationAction: FC<{ break } const [e] = await asyncRunSafe(opApi({ datasetId, documentId: id }) as Promise) - if (!e) + if (!e) { notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) - else - notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) + onUpdate(operationName) + } + else { notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) } if (operationName === 'delete') setDeleting(false) - onUpdate(operationName) } const { run: handleSwitch } = useDebounceFn((operationName: OperationName) => { @@ -462,6 +462,37 @@ const DocumentList: FC = ({ else onSelectedIdChange(uniq([...selectedIds, ...localDocs.map(doc => doc.id)])) }, [isAllSelected, localDocs, onSelectedIdChange, selectedIds]) + const { mutateAsync: archiveDocument } = useDocumentArchive() + const { mutateAsync: enableDocument } = useDocumentEnable() + const { mutateAsync: disableDocument } = useDocumentDisable() + const { mutateAsync: deleteDocument } = useDocumentDelete() + + const handleAction = (actionName: DocumentActionType) => { + return async () => { + let opApi = deleteDocument + switch (actionName) { + case DocumentActionType.archive: + opApi = archiveDocument + break + case DocumentActionType.enable: + opApi = enableDocument + break + case DocumentActionType.disable: + opApi = disableDocument + break + default: + opApi = deleteDocument + break + } + const [e] = await asyncRunSafe(opApi({ datasetId, documentIds: selectedIds }) as Promise) + + if (!e) { + Toast.notify({ type: 'success', message: t('common.actionMsg.modifiedSuccessfully') }) + onUpdate() + } + else { Toast.notify({ type: 'error', message: t('common.actionMsg.modifiedUnsuccessfully') }) } + } + } return (
@@ -588,16 +619,10 @@ const DocumentList: FC = ({ { }} - onBatchEnable={() => { - - }} - onBatchDisable={() => { - - }} - onBatchDelete={() => { - - }} + onArchive={handleAction(DocumentActionType.archive)} + onBatchEnable={handleAction(DocumentActionType.enable)} + onBatchDisable={handleAction(DocumentActionType.disable)} + onBatchDelete={handleAction(DocumentActionType.delete)} onCancel={() => { onSelectedIdChange([]) }} diff --git a/web/models/datasets.ts b/web/models/datasets.ts index 3bcea75a4a..a57b6ed13b 100644 --- a/web/models/datasets.ts +++ b/web/models/datasets.ts @@ -620,11 +620,13 @@ export type UpdateDocumentParams = { documentId: string } -export enum BatchActionType { +// Used in api url +export enum DocumentActionType { enable = 'enable', disable = 'disable', archive = 'archive', unArchive = 'un_archive', + delete = 'delete', } export type UpdateDocumentBatchParams = { diff --git a/web/service/knowledge/use-document.ts b/web/service/knowledge/use-document.ts index d90480dcd1..5b200d899d 100644 --- a/web/service/knowledge/use-document.ts +++ b/web/service/knowledge/use-document.ts @@ -4,7 +4,7 @@ import { } from '@tanstack/react-query' import { del, get, patch } from '../base' import type { SimpleDocumentDetail, UpdateDocumentBatchParams } from '@/models/datasets' -import { BatchActionType } from '@/models/datasets' +import { DocumentActionType } from '@/models/datasets' import type { CommonResponse } from '@/models/common' const NAME_SPACE = 'knowledge/document' @@ -29,10 +29,10 @@ export const useDocumentList = (payload: { const toBatchDocumentsIdParams = (documentIds: string[] | string) => { const ids = Array.isArray(documentIds) ? documentIds : [documentIds] - return ids.map(id => `document_id=${id}`).join('=') + return ids.map(id => `document_id=${id}`).join('&') } -export const useDocumentBatchAction = (action: BatchActionType) => { +export const useDocumentBatchAction = (action: DocumentActionType) => { return useMutation({ mutationFn: ({ datasetId, documentIds, documentId }: UpdateDocumentBatchParams) => { return patch(`/datasets/${datasetId}/documents/status/${action}?${toBatchDocumentsIdParams(documentId || documentIds!)}`) @@ -41,19 +41,19 @@ export const useDocumentBatchAction = (action: BatchActionType) => { } export const useDocumentEnable = () => { - return useDocumentBatchAction(BatchActionType.enable) + return useDocumentBatchAction(DocumentActionType.enable) } export const useDocumentDisable = () => { - return useDocumentBatchAction(BatchActionType.disable) + return useDocumentBatchAction(DocumentActionType.disable) } export const useDocumentArchive = () => { - return useDocumentBatchAction(BatchActionType.archive) + return useDocumentBatchAction(DocumentActionType.archive) } export const useDocumentUnArchive = () => { - return useDocumentBatchAction(BatchActionType.unArchive) + return useDocumentBatchAction(DocumentActionType.unArchive) } export const useDocumentDelete = () => { From 6383a64419af743921852915bb8486f4f4027530 Mon Sep 17 00:00:00 2001 From: AkaraChen Date: Fri, 6 Dec 2024 16:16:30 +0800 Subject: [PATCH 9/9] fix: step 2 preview ui padding --- web/app/components/datasets/create/step-two/index.tsx | 7 ++++--- web/app/components/datasets/preview/container.tsx | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/web/app/components/datasets/create/step-two/index.tsx b/web/app/components/datasets/create/step-two/index.tsx index 5dd7af33c9..95e2e766df 100644 --- a/web/app/components/datasets/create/step-two/index.tsx +++ b/web/app/components/datasets/create/step-two/index.tsx @@ -113,11 +113,11 @@ const defaultParentChildConfig: ParentChildConfig = { chunkForContext: 'paragraph', parent: { delimiter: '\\n\\n', - maxLength: 4000, + maxLength: 500, }, child: { delimiter: '\\n\\n', - maxLength: 4000, + maxLength: 200, }, } @@ -922,7 +922,8 @@ const StepTwo = ({
} - className={cn(s.previewWrap, isMobile && s.isMobile, 'relative h-full overflow-y-scroll space-y-4')} + className={cn(s.previewWrap, isMobile && s.isMobile, 'relative h-full overflow-y-scroll')} + mainClassName='space-y-6' > {docForm === ChuckingMode.qa && estimate?.qa_preview && ( estimate?.qa_preview.map(item => ( diff --git a/web/app/components/datasets/preview/container.tsx b/web/app/components/datasets/preview/container.tsx index b5e7feaf9f..ffc2692524 100644 --- a/web/app/components/datasets/preview/container.tsx +++ b/web/app/components/datasets/preview/container.tsx @@ -4,10 +4,11 @@ import classNames from '@/utils/classnames' export type PreviewContainerProps = ComponentProps<'div'> & { header: ReactNode + mainClassName?: string } export const PreviewContainer: FC = forwardRef((props, ref) => { - const { children, className, header, ...rest } = props + const { children, className, header, mainClassName, ...rest } = props return
= forwardRef((props, re
{header}
-
+
{children}