Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

feat: remove documents limit (#1697)

zxhlyhcb3a55dae68d
diff --git a/web/app/components/base/notion-page-selector/base.tsx b/web/app/components/base/notion-page-selector/base.tsx
index 93a00fe43b2..eeded7d6f01 100644
--- a/web/app/components/base/notion-page-selector/base.tsx
+++ b/web/app/components/base/notion-page-selector/base.tsx
@@ -1,6 +1,4 @@
import { useCallback, useEffect, useMemo, useState } from 'react'
-import { useTranslation } from 'react-i18next'
-import { useContext } from 'use-context-selector'
import useSWR from 'swr'
import cn from 'classnames'
import s from './base.module.css'
@@ -10,7 +8,6 @@ import PageSelector from './page-selector'
import { preImportNotionPages } from '@/service/datasets'
import { NotionConnector } from '@/app/components/datasets/create/step-one'
import type { DataSourceNotionPageMap, DataSourceNotionWorkspace, NotionPage } from '@/models/common'
-import { ToastContext } from '@/app/components/base/toast'
import { useModalContext } from '@/context/modal-context'
type NotionPageSelectorProps = {
@@ -20,8 +17,6 @@ type NotionPageSelectorProps = {
previewPageId?: string
onPreview?: (selectedPage: NotionPage) => void
datasetId?: string
- countLimit: number
- countUsed: number
}
const NotionPageSelector = ({
@@ -31,11 +26,7 @@ const NotionPageSelector = ({
previewPageId,
onPreview,
datasetId = '',
- countLimit,
- countUsed,
}: NotionPageSelectorProps) => {
- const { t } = useTranslation()
- const { notify } = useContext(ToastContext)
const { data, mutate } = useSWR({ url: '/notion/pre-import/pages', datasetId }, preImportNotionPages)
const [prevData, setPrevData] = useState(data)
const [searchValue, setSearchValue] = useState('')
@@ -80,10 +71,7 @@ const NotionPageSelector = ({
}, [])
const handleSelecPages = (newSelectedPagesId: Set<string>) => {
const selectedPages = Array.from(newSelectedPagesId).map(pageId => getPagesMapAndSelectedPagesId[0][pageId])
- if (selectedPages.length > countLimit - countUsed) {
- notify({ type: 'error', message: t('datasetCreation.stepOne.overCountLimit', { countLimit }) })
- return false
- }
+
setSelectedPagesId(new Set(Array.from(newSelectedPagesId)))
onSelect(selectedPages)
}
diff --git a/web/app/components/datasets/create/file-uploader/index.tsx b/web/app/components/datasets/create/file-uploader/index.tsx
index 40bb4a6d2be..a0f41eee25e 100644
--- a/web/app/components/datasets/create/file-uploader/index.tsx
+++ b/web/app/components/datasets/create/file-uploader/index.tsx
@@ -18,8 +18,6 @@ type IFileUploaderProps = {
onFileUpdate: (fileItem: FileItem, progress: number, list: FileItem[]) => void
onFileListUpdate?: (files: FileItem[]) => void
onPreview: (file: File) => void
- countLimit: number
- countUsed: number
}
const ACCEPTS = [
@@ -41,8 +39,6 @@ const FileUploader = ({
onFileUpdate,
onFileListUpdate,
onPreview,
- countLimit,
- countUsed,
}: IFileUploaderProps) => {
const { t } = useTranslation()
const { notify } = useContext(ToastContext)
@@ -149,10 +145,7 @@ const FileUploader = ({
const initialUpload = useCallback((files: File[]) => {
if (!files.length)
return false
- if (files.length > countLimit - countUsed) {
- notify({ type: 'error', message: t('datasetCreation.stepOne.overCountLimit', { countLimit }) })
- return false
- }
+
const preparedFiles = files.map((file, index) => ({
fileID: `file${index}-${Date.now()}`,
file,
diff --git a/web/app/components/datasets/create/step-one/index.tsx b/web/app/components/datasets/create/step-one/index.tsx
index f6ebd0cbd66..391d6869af2 100644
--- a/web/app/components/datasets/create/step-one/index.tsx
+++ b/web/app/components/datasets/create/step-one/index.tsx
@@ -1,6 +1,5 @@
'use client'
import React, { useMemo, useState } from 'react'
-import useSWR from 'swr'
import { useTranslation } from 'react-i18next'
import cn from 'classnames'
import FilePreview from '../file-preview'
@@ -14,7 +13,6 @@ import { DataSourceType } from '@/models/datasets'
import Button from '@/app/components/base/button'
import { NotionPageSelector } from '@/app/components/base/notion-page-selector'
import { useDatasetDetailContext } from '@/context/dataset-detail'
-import { fetchDocumentsLimit } from '@/service/common'
import { useProviderContext } from '@/context/provider-context'
import VectorSpaceFull from '@/app/components/billing/vector-space-full'
@@ -63,7 +61,6 @@ const StepOne = ({
notionPages = [],
updateNotionPages,
}: IStepOneProps) => {
- const { data: limitsData } = useSWR('/datasets/limit', fetchDocumentsLimit)
const { dataset } = useDatasetDetailContext()
const [showModal, setShowModal] = useState(false)
const [currentFile, setCurrentFile] = useState<File | undefined>()
@@ -163,7 +160,7 @@ const StepOne = ({
</div>
)
}
- {dataSourceType === DataSourceType.FILE && limitsData && (
+ {dataSourceType === DataSourceType.FILE && (
<>
<FileUploader
fileList={files}
@@ -172,8 +169,6 @@ const StepOne = ({
onFileListUpdate={updateFileList}
onFileUpdate={updateFile}
onPreview={updateCurrentFile}
- countLimit={limitsData.documents_limit}
- countUsed={limitsData.documents_count}
/>
{isShowVectorSpaceFull && (
<div className='max-w-[640px] mb-4'>
@@ -186,15 +181,13 @@ const StepOne = ({
{dataSourceType === DataSourceType.NOTION && (
<>
{!hasConnection && <NotionConnector onSetting={onSetting} />}
- {hasConnection && limitsData && (
+ {hasConnection && (
<>
<div className='mb-8 w-[640px]'>
<NotionPageSelector
value={notionPages.map(page => page.page_id)}
onSelect={updateNotionPages}
onPreview={updateCurrentPage}
- countLimit={limitsData.documents_limit}
- countUsed={limitsData.documents_count}
/>
</div>
{isShowVectorSpaceFull && (
diff --git a/web/i18n/lang/dataset-creation.en.ts b/web/i18n/lang/dataset-creation.en.ts
index 8c0d7a1b8e8..9d07334f6d9 100644
--- a/web/i18n/lang/dataset-creation.en.ts
+++ b/web/i18n/lang/dataset-creation.en.ts
@@ -49,7 +49,6 @@ const translation = {
confirmButton: 'Create',
failed: 'Creation failed',
},
- overCountLimit: 'All your documents have overed limit {{countLimit}}.',
},
stepTwo: {
segmentation: 'Chunk settings',
diff --git a/web/i18n/lang/dataset-creation.zh.ts b/web/i18n/lang/dataset-creation.zh.ts
index be8d1eec06b..b647be1fa47 100644
--- a/web/i18n/lang/dataset-creation.zh.ts
+++ b/web/i18n/lang/dataset-creation.zh.ts
@@ -49,7 +49,6 @@ const translation = {
confirmButton: '创建',
failed: '创建失败',
},
- overCountLimit: '您的文件总数已超出限制 {{countLimit}}。',
},
stepTwo: {
segmentation: '分段设置',
diff --git a/web/models/common.ts b/web/models/common.ts
index e4d90f83475..3f7bddf1605 100644
--- a/web/models/common.ts
+++ b/web/models/common.ts
@@ -179,11 +179,6 @@ export type FileUploadConfigResponse = {
image_file_size_limit?: number | string
}
-export type DocumentsLimitResponse = {
- documents_count: number
- documents_limit: number
-}
-
export type InvitationResult = {
status: 'success'
email: string
diff --git a/web/service/common.ts b/web/service/common.ts
index b43f37c69ef..e6c4e65a710 100644
--- a/web/service/common.ts
+++ b/web/service/common.ts
@@ -6,7 +6,6 @@ import type {
CodeBasedExtension,
CommonResponse,
DataSourceNotion,
- DocumentsLimitResponse,
FileUploadConfigResponse,
ICurrentWorkspace,
IWorkspace,
@@ -195,10 +194,6 @@ export const fetchFileUploadConfig: Fetcher<FileUploadConfigResponse, { url: str
return get<FileUploadConfigResponse>(url)
}
-export const fetchDocumentsLimit: Fetcher<DocumentsLimitResponse, string> = (url) => {
- return get<DocumentsLimitResponse>(url)
-}
-
export const fetchFreeQuotaVerify: Fetcher<{ result: string; flag: boolean; reason: string }, string> = (url) => {
return get(url) as Promise<{ result: string; flag: boolean; reason: string }>
}