mirror of
http://112.124.100.131/huang.ze/ebiz-dify-ai.git
synced 2025-12-09 02:46:52 +08:00
Feat: Add documents limitation (#2662)
This commit is contained in:
@@ -16,6 +16,7 @@ export const ALL_PLANS: Record<Plan, PlanInfo> = {
|
||||
teamMembers: 1,
|
||||
buildApps: 10,
|
||||
vectorSpace: 5,
|
||||
documentsUploadQuota: 50,
|
||||
documentProcessingPriority: Priority.standard,
|
||||
logHistory: 30,
|
||||
customTools: unAvailable,
|
||||
@@ -32,6 +33,7 @@ export const ALL_PLANS: Record<Plan, PlanInfo> = {
|
||||
teamMembers: 3,
|
||||
buildApps: 50,
|
||||
vectorSpace: 200,
|
||||
documentsUploadQuota: 500,
|
||||
documentProcessingPriority: Priority.priority,
|
||||
logHistory: NUM_INFINITE,
|
||||
customTools: 10,
|
||||
@@ -48,6 +50,7 @@ export const ALL_PLANS: Record<Plan, PlanInfo> = {
|
||||
teamMembers: NUM_INFINITE,
|
||||
buildApps: NUM_INFINITE,
|
||||
vectorSpace: 1000,
|
||||
documentsUploadQuota: 1000,
|
||||
documentProcessingPriority: Priority.topPriority,
|
||||
logHistory: NUM_INFINITE,
|
||||
customTools: NUM_INFINITE,
|
||||
@@ -64,6 +67,7 @@ export const ALL_PLANS: Record<Plan, PlanInfo> = {
|
||||
teamMembers: NUM_INFINITE,
|
||||
buildApps: NUM_INFINITE,
|
||||
vectorSpace: NUM_INFINITE,
|
||||
documentsUploadQuota: NUM_INFINITE,
|
||||
documentProcessingPriority: Priority.topPriority,
|
||||
logHistory: NUM_INFINITE,
|
||||
customTools: NUM_INFINITE,
|
||||
|
||||
@@ -129,6 +129,9 @@ const PlanItem: FC<Props> = ({
|
||||
<div className='mt-3.5 flex items-center space-x-1'>
|
||||
<div>+ {t('billing.plansCommon.supportItems.logoChange')}</div>
|
||||
</div>
|
||||
<div className='mt-3.5 flex items-center space-x-1'>
|
||||
<div>+ {t('billing.plansCommon.supportItems.bulkUpload')}</div>
|
||||
</div>
|
||||
<div className='mt-3.5 flex items-center space-x-1'>
|
||||
<div className='flex items-center'>
|
||||
+
|
||||
@@ -264,6 +267,10 @@ const PlanItem: FC<Props> = ({
|
||||
value={planInfo.vectorSpace === NUM_INFINITE ? t('billing.plansCommon.unlimited') as string : (planInfo.vectorSpace >= 1000 ? `${planInfo.vectorSpace / 1000}G` : `${planInfo.vectorSpace}MB`)}
|
||||
tooltip={t('billing.plansCommon.vectorSpaceBillingTooltip') as string}
|
||||
/>
|
||||
<KeyValue
|
||||
label={t('billing.plansCommon.documentsUploadQuota')}
|
||||
value={planInfo.vectorSpace === NUM_INFINITE ? t('billing.plansCommon.unlimited') as string : planInfo.documentsUploadQuota}
|
||||
/>
|
||||
<KeyValue
|
||||
label={t('billing.plansCommon.documentProcessingPriority')}
|
||||
value={t(`billing.plansCommon.priority.${planInfo.documentProcessingPriority}`) as string}
|
||||
|
||||
@@ -17,6 +17,7 @@ export type PlanInfo = {
|
||||
teamMembers: number
|
||||
buildApps: number
|
||||
vectorSpace: number
|
||||
documentsUploadQuota: number
|
||||
documentProcessingPriority: Priority
|
||||
logHistory: number
|
||||
customTools: string | number
|
||||
|
||||
@@ -23,6 +23,7 @@ type IFileUploaderProps = {
|
||||
onFileUpdate: (fileItem: FileItem, progress: number, list: FileItem[]) => void
|
||||
onFileListUpdate?: (files: FileItem[]) => void
|
||||
onPreview: (file: File) => void
|
||||
notSupportBatchUpload?: boolean
|
||||
}
|
||||
|
||||
const FileUploader = ({
|
||||
@@ -32,6 +33,7 @@ const FileUploader = ({
|
||||
onFileUpdate,
|
||||
onFileListUpdate,
|
||||
onPreview,
|
||||
notSupportBatchUpload,
|
||||
}: IFileUploaderProps) => {
|
||||
const { t } = useTranslation()
|
||||
const { notify } = useContext(ToastContext)
|
||||
@@ -40,6 +42,7 @@ const FileUploader = ({
|
||||
const dropRef = useRef<HTMLDivElement>(null)
|
||||
const dragRef = useRef<HTMLDivElement>(null)
|
||||
const fileUploader = useRef<HTMLInputElement>(null)
|
||||
const hideUpload = notSupportBatchUpload && fileList.length > 0
|
||||
|
||||
const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig)
|
||||
const { data: supportFileTypesResponse } = useSWR({ url: '/files/support-type' }, fetchSupportFileTypes)
|
||||
@@ -131,7 +134,7 @@ const FileUploader = ({
|
||||
xhr: new XMLHttpRequest(),
|
||||
data: formData,
|
||||
onprogress: onProgress,
|
||||
})
|
||||
}, false, undefined, '?source=datasets')
|
||||
.then((res: File) => {
|
||||
const completeFile = {
|
||||
fileID: fileItem.fileID,
|
||||
@@ -143,8 +146,8 @@ const FileUploader = ({
|
||||
onFileUpdate(completeFile, 100, fileListCopy)
|
||||
return Promise.resolve({ ...completeFile })
|
||||
})
|
||||
.catch(() => {
|
||||
notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.failed') })
|
||||
.catch((e) => {
|
||||
notify({ type: 'error', message: e?.response?.code === 'forbidden' ? e?.response?.message : t('datasetCreation.stepOne.uploader.failed') })
|
||||
onFileUpdate(fileItem, -2, fileListCopy)
|
||||
return Promise.resolve({ ...fileItem })
|
||||
})
|
||||
@@ -252,30 +255,36 @@ const FileUploader = ({
|
||||
|
||||
return (
|
||||
<div className={s.fileUploader}>
|
||||
<input
|
||||
ref={fileUploader}
|
||||
id="fileUploader"
|
||||
style={{ display: 'none' }}
|
||||
type="file"
|
||||
multiple
|
||||
accept={ACCEPTS.join(',')}
|
||||
onChange={fileChangeHandle}
|
||||
/>
|
||||
{!hideUpload && (
|
||||
<input
|
||||
ref={fileUploader}
|
||||
id="fileUploader"
|
||||
style={{ display: 'none' }}
|
||||
type="file"
|
||||
multiple={!notSupportBatchUpload}
|
||||
accept={ACCEPTS.join(',')}
|
||||
onChange={fileChangeHandle}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className={cn(s.title, titleClassName)}>{t('datasetCreation.stepOne.uploader.title')}</div>
|
||||
<div ref={dropRef} className={cn(s.uploader, dragging && s.dragging)}>
|
||||
<div className='flex justify-center items-center min-h-6 mb-2'>
|
||||
<span className={s.uploadIcon} />
|
||||
<span>
|
||||
{t('datasetCreation.stepOne.uploader.button')}
|
||||
<label className={s.browse} onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.browse')}</label>
|
||||
</span>
|
||||
{!hideUpload && (
|
||||
|
||||
<div ref={dropRef} className={cn(s.uploader, dragging && s.dragging)}>
|
||||
<div className='flex justify-center items-center min-h-6 mb-2'>
|
||||
<span className={s.uploadIcon} />
|
||||
<span>
|
||||
{t('datasetCreation.stepOne.uploader.button')}
|
||||
<label className={s.browse} onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.browse')}</label>
|
||||
</span>
|
||||
</div>
|
||||
<div className={s.tip}>{t('datasetCreation.stepOne.uploader.tip', {
|
||||
size: fileUploadConfig.file_size_limit,
|
||||
supportTypes: supportTypesShowNames,
|
||||
})}</div>
|
||||
{dragging && <div ref={dragRef} className={s.draggingCover} />}
|
||||
</div>
|
||||
<div className={s.tip}>{t('datasetCreation.stepOne.uploader.tip', {
|
||||
size: fileUploadConfig.file_size_limit,
|
||||
supportTypes: supportTypesShowNames,
|
||||
})}</div>
|
||||
{dragging && <div ref={dragRef} className={s.draggingCover} />}
|
||||
</div>
|
||||
)}
|
||||
<div className={s.fileList}>
|
||||
{fileList.map((fileItem, index) => (
|
||||
<div
|
||||
|
||||
@@ -39,7 +39,7 @@ export const NotionConnector = ({ onSetting }: NotionConnectorProps) => {
|
||||
|
||||
return (
|
||||
<div className={s.notionConnectionTip}>
|
||||
<span className={s.notionIcon}/>
|
||||
<span className={s.notionIcon} />
|
||||
<div className={s.title}>{t('datasetCreation.stepOne.notionSyncTitle')}</div>
|
||||
<div className={s.tip}>{t('datasetCreation.stepOne.notionSyncTip')}</div>
|
||||
<Button className='h-8' type='primary' onClick={onSetting}>{t('datasetCreation.stepOne.connect')}</Button>
|
||||
@@ -92,7 +92,7 @@ const StepOne = ({
|
||||
const hasNotin = notionPages.length > 0
|
||||
const isVectorSpaceFull = plan.usage.vectorSpace >= plan.total.vectorSpace
|
||||
const isShowVectorSpaceFull = (allFileLoaded || hasNotin) && isVectorSpaceFull && enableBilling
|
||||
|
||||
const notSupportBatchUpload = enableBilling && plan.type === 'sandbox'
|
||||
const nextDisabled = useMemo(() => {
|
||||
if (!files.length)
|
||||
return true
|
||||
@@ -169,6 +169,7 @@ const StepOne = ({
|
||||
onFileListUpdate={updateFileList}
|
||||
onFileUpdate={updateFile}
|
||||
onPreview={updateCurrentFile}
|
||||
notSupportBatchUpload={notSupportBatchUpload}
|
||||
/>
|
||||
{isShowVectorSpaceFull && (
|
||||
<div className='max-w-[640px] mb-4'>
|
||||
|
||||
@@ -32,6 +32,7 @@ const translation = {
|
||||
vectorSpace: 'Vector Space',
|
||||
vectorSpaceBillingTooltip: 'Each 1MB can store about 1.2million characters of vectorized data(estimated using OpenAI Embeddings, varies across models).',
|
||||
vectorSpaceTooltip: 'Vector Space is the long-term memory system required for LLMs to comprehend your data.',
|
||||
documentsUploadQuota: 'Documents Upload Quota',
|
||||
documentProcessingPriority: 'Document Processing Priority',
|
||||
documentProcessingPriorityTip: 'For higher document processing priority, please upgrade your plan.',
|
||||
documentProcessingPriorityUpgrade: 'Process more data with higher accuracy at faster speeds.',
|
||||
@@ -56,6 +57,7 @@ const translation = {
|
||||
dedicatedAPISupport: 'Dedicated API support',
|
||||
customIntegration: 'Custom integration and support',
|
||||
ragAPIRequest: 'RAG API Requests',
|
||||
bulkUpload: 'Bulk upload documents',
|
||||
agentMode: 'Agent Mode',
|
||||
workflow: 'Workflow',
|
||||
},
|
||||
|
||||
@@ -32,6 +32,7 @@ const translation = {
|
||||
vectorSpace: '向量空间',
|
||||
vectorSpaceTooltip: '向量空间是 LLMs 理解您的数据所需的长期记忆系统。',
|
||||
vectorSpaceBillingTooltip: '向量存储是将知识库向量化处理后为让 LLMs 理解数据而使用的长期记忆存储,1MB 大约能满足1.2 million character 的向量化后数据存储(以 OpenAI Embedding 模型估算,不同模型计算方式有差异)。在向量化过程中,实际的压缩或尺寸减小取决于内容的复杂性和冗余性。',
|
||||
documentsUploadQuota: '文档上传配额',
|
||||
documentProcessingPriority: '文档处理优先级',
|
||||
documentProcessingPriorityTip: '如需更高的文档处理优先级,请升级您的套餐',
|
||||
documentProcessingPriorityUpgrade: '以更快的速度、更高的精度处理更多的数据。',
|
||||
@@ -56,6 +57,7 @@ const translation = {
|
||||
dedicatedAPISupport: '专用 API 支持',
|
||||
customIntegration: '自定义集成和支持',
|
||||
ragAPIRequest: 'RAG API 请求',
|
||||
bulkUpload: '批量上传文档',
|
||||
agentMode: '代理模式',
|
||||
workflow: '工作流',
|
||||
},
|
||||
|
||||
@@ -308,7 +308,7 @@ const baseFetch = <T>(
|
||||
]) as Promise<T>
|
||||
}
|
||||
|
||||
export const upload = (options: any, isPublicAPI?: boolean, url?: string): Promise<any> => {
|
||||
export const upload = (options: any, isPublicAPI?: boolean, url?: string, searchParams?: string): Promise<any> => {
|
||||
const urlPrefix = isPublicAPI ? PUBLIC_API_PREFIX : API_PREFIX
|
||||
let token = ''
|
||||
if (isPublicAPI) {
|
||||
@@ -329,7 +329,7 @@ export const upload = (options: any, isPublicAPI?: boolean, url?: string): Promi
|
||||
}
|
||||
const defaultOptions = {
|
||||
method: 'POST',
|
||||
url: url ? `${urlPrefix}${url}` : `${urlPrefix}/files/upload`,
|
||||
url: (url ? `${urlPrefix}${url}` : `${urlPrefix}/files/upload`) + (searchParams || ''),
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user