| 'HOSTED_ANTHROPIC_PAID_ENABLED': 'False', | 'HOSTED_ANTHROPIC_PAID_ENABLED': 'False', | ||||
| 'HOSTED_ANTHROPIC_PAID_INCREASE_QUOTA': 1, | 'HOSTED_ANTHROPIC_PAID_INCREASE_QUOTA': 1, | ||||
| 'TENANT_DOCUMENT_COUNT': 100, | 'TENANT_DOCUMENT_COUNT': 100, | ||||
| 'CLEAN_DAY_SETTING': 30 | |||||
| 'CLEAN_DAY_SETTING': 30, | |||||
| 'UPLOAD_FILE_SIZE_LIMIT': 15, | |||||
| 'UPLOAD_FILE_BATCH_LIMIT': 5, | |||||
| } | } | ||||
| self.TENANT_DOCUMENT_COUNT = get_env('TENANT_DOCUMENT_COUNT') | self.TENANT_DOCUMENT_COUNT = get_env('TENANT_DOCUMENT_COUNT') | ||||
| self.CLEAN_DAY_SETTING = get_env('CLEAN_DAY_SETTING') | self.CLEAN_DAY_SETTING = get_env('CLEAN_DAY_SETTING') | ||||
| # uploading settings | |||||
| self.UPLOAD_FILE_SIZE_LIMIT = int(get_env('UPLOAD_FILE_SIZE_LIMIT')) | |||||
| self.UPLOAD_FILE_BATCH_LIMIT = int(get_env('UPLOAD_FILE_BATCH_LIMIT')) | |||||
| class CloudEditionConfig(Config): | class CloudEditionConfig(Config): | ||||
| cache = TTLCache(maxsize=None, ttl=30) | cache = TTLCache(maxsize=None, ttl=30) | ||||
| FILE_SIZE_LIMIT = 15 * 1024 * 1024 # 15MB | |||||
| ALLOWED_EXTENSIONS = ['txt', 'markdown', 'md', 'pdf', 'html', 'htm'] | |||||
| PREVIEW_WORDS_LIMIT = 3000 | |||||
| class DataSourceApi(Resource): | class DataSourceApi(Resource): | ||||
| integrate_icon_fields = { | integrate_icon_fields = { |
| cache = TTLCache(maxsize=None, ttl=30) | cache = TTLCache(maxsize=None, ttl=30) | ||||
| FILE_SIZE_LIMIT = 15 * 1024 * 1024 # 15MB | |||||
| ALLOWED_EXTENSIONS = ['txt', 'markdown', 'md', 'pdf', 'html', 'htm', 'xlsx'] | ALLOWED_EXTENSIONS = ['txt', 'markdown', 'md', 'pdf', 'html', 'htm', 'xlsx'] | ||||
| PREVIEW_WORDS_LIMIT = 3000 | PREVIEW_WORDS_LIMIT = 3000 | ||||
| class FileApi(Resource): | class FileApi(Resource): | ||||
| upload_config_fields = { | |||||
| 'file_size_limit': fields.Integer, | |||||
| 'batch_count_limit': fields.Integer | |||||
| } | |||||
| @setup_required | |||||
| @login_required | |||||
| @account_initialization_required | |||||
| @marshal_with(upload_config_fields) | |||||
| def get(self): | |||||
| file_size_limit = current_app.config.get("UPLOAD_FILE_SIZE_LIMIT") | |||||
| batch_count_limit = current_app.config.get("UPLOAD_FILE_BATCH_LIMIT") | |||||
| return { | |||||
| 'file_size_limit': file_size_limit, | |||||
| 'batch_count_limit': batch_count_limit | |||||
| }, 200 | |||||
| file_fields = { | file_fields = { | ||||
| 'id': fields.String, | 'id': fields.String, | ||||
| 'name': fields.String, | 'name': fields.String, | ||||
| file_content = file.read() | file_content = file.read() | ||||
| file_size = len(file_content) | file_size = len(file_content) | ||||
| if file_size > FILE_SIZE_LIMIT: | |||||
| message = "({file_size} > {FILE_SIZE_LIMIT})" | |||||
| file_size_limit = current_app.config.get("UPLOAD_FILE_SIZE_LIMIT") * 1024 * 1024 | |||||
| if file_size > file_size_limit: | |||||
| message = "({file_size} > {file_size_limit})" | |||||
| raise FileTooLargeError(message) | raise FileTooLargeError(message) | ||||
| extension = file.filename.split('.')[-1] | extension = file.filename.split('.')[-1] |
| import cn from 'classnames' | import cn from 'classnames' | ||||
| import { XMarkIcon } from '@heroicons/react/20/solid' | import { XMarkIcon } from '@heroicons/react/20/solid' | ||||
| import s from './index.module.css' | import s from './index.module.css' | ||||
| import type { File } from '@/models/datasets' | |||||
| import type { CustomFile as File } from '@/models/datasets' | |||||
| import { fetchFilePreview } from '@/service/common' | import { fetchFilePreview } from '@/service/common' | ||||
| type IProps = { | type IProps = { | ||||
| } | } | ||||
| useEffect(() => { | useEffect(() => { | ||||
| if (file) { | |||||
| if (file?.id) { | |||||
| setLoading(true) | setLoading(true) | ||||
| getPreviewContent(file.id) | getPreviewContent(file.id) | ||||
| } | } |
| 'use client' | 'use client' | ||||
| import React, { useEffect, useRef, useState } from 'react' | |||||
| import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' | |||||
| import { useTranslation } from 'react-i18next' | import { useTranslation } from 'react-i18next' | ||||
| import { useContext } from 'use-context-selector' | import { useContext } from 'use-context-selector' | ||||
| import cn from 'classnames' | import cn from 'classnames' | ||||
| import useSWR from 'swr' | |||||
| import s from './index.module.css' | import s from './index.module.css' | ||||
| import type { File as FileEntity } from '@/models/datasets' | |||||
| import type { CustomFile as File, FileItem } from '@/models/datasets' | |||||
| import { ToastContext } from '@/app/components/base/toast' | import { ToastContext } from '@/app/components/base/toast' | ||||
| import { upload } from '@/service/base' | import { upload } from '@/service/base' | ||||
| import { fetchFileUploadConfig } from '@/service/common' | |||||
| type IFileUploaderProps = { | type IFileUploaderProps = { | ||||
| fileList: any[] | |||||
| fileList: FileItem[] | |||||
| titleClassName?: string | titleClassName?: string | ||||
| prepareFileList: (files: any[]) => void | |||||
| onFileUpdate: (fileItem: any, progress: number, list: any[]) => void | |||||
| prepareFileList: (files: FileItem[]) => void | |||||
| onFileUpdate: (fileItem: FileItem, progress: number, list: FileItem[]) => void | |||||
| onFileListUpdate?: (files: any) => void | onFileListUpdate?: (files: any) => void | ||||
| onPreview: (file: FileEntity) => void | |||||
| onPreview: (file: File) => void | |||||
| } | } | ||||
| const ACCEPTS = [ | const ACCEPTS = [ | ||||
| '.csv', | '.csv', | ||||
| ] | ] | ||||
| const MAX_SIZE = 15 * 1024 * 1024 | |||||
| const BATCH_COUNT = 5 | |||||
| const FileUploader = ({ | const FileUploader = ({ | ||||
| fileList, | fileList, | ||||
| titleClassName, | titleClassName, | ||||
| const dragRef = useRef<HTMLDivElement>(null) | const dragRef = useRef<HTMLDivElement>(null) | ||||
| const fileUploader = useRef<HTMLInputElement>(null) | const fileUploader = useRef<HTMLInputElement>(null) | ||||
| const fileListRef = useRef<any>([]) | |||||
| const { data: fileUploadConfigResponse } = useSWR({ url: '/files/upload' }, fetchFileUploadConfig) | |||||
| const fileUploadConfig = useMemo(() => fileUploadConfigResponse ?? { | |||||
| file_size_limit: 15, | |||||
| batch_count_limit: 5, | |||||
| }, [fileUploadConfigResponse]) | |||||
| const fileListRef = useRef<FileItem[]>([]) | |||||
| // utils | // utils | ||||
| const getFileType = (currentFile: File) => { | const getFileType = (currentFile: File) => { | ||||
| return `${(size / 1024 / 1024).toFixed(2)}MB` | return `${(size / 1024 / 1024).toFixed(2)}MB` | ||||
| } | } | ||||
| const isValid = (file: File) => { | |||||
| const isValid = useCallback((file: File) => { | |||||
| const { size } = file | const { size } = file | ||||
| const ext = `.${getFileType(file)}` | const ext = `.${getFileType(file)}` | ||||
| const isValidType = ACCEPTS.includes(ext) | const isValidType = ACCEPTS.includes(ext) | ||||
| if (!isValidType) | if (!isValidType) | ||||
| notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.validation.typeError') }) | notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.validation.typeError') }) | ||||
| const isValidSize = size <= MAX_SIZE | |||||
| const isValidSize = size <= fileUploadConfig.file_size_limit * 1024 * 1024 | |||||
| if (!isValidSize) | if (!isValidSize) | ||||
| notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.validation.size') }) | |||||
| notify({ type: 'error', message: t('datasetCreation.stepOne.uploader.validation.size', { size: fileUploadConfig.file_size_limit }) }) | |||||
| return isValidType && isValidSize | return isValidType && isValidSize | ||||
| } | |||||
| }, [fileUploadConfig, notify, t]) | |||||
| const fileUpload = async (fileItem: any) => { | |||||
| const fileUpload = useCallback(async (fileItem: FileItem): Promise<FileItem> => { | |||||
| const formData = new FormData() | const formData = new FormData() | ||||
| formData.append('file', fileItem.file) | formData.append('file', fileItem.file) | ||||
| const onProgress = (e: ProgressEvent) => { | const onProgress = (e: ProgressEvent) => { | ||||
| } | } | ||||
| } | } | ||||
| const fileListCopy = fileListRef.current | |||||
| return upload({ | return upload({ | ||||
| xhr: new XMLHttpRequest(), | xhr: new XMLHttpRequest(), | ||||
| data: formData, | data: formData, | ||||
| onprogress: onProgress, | onprogress: onProgress, | ||||
| }) | }) | ||||
| .then((res: FileEntity) => { | |||||
| const fileListCopy = fileListRef.current | |||||
| .then((res: File) => { | |||||
| const completeFile = { | const completeFile = { | ||||
| fileID: fileItem.fileID, | fileID: fileItem.fileID, | ||||
| file: res, | file: res, | ||||
| progress: -1, | |||||
| } | } | ||||
| const index = fileListCopy.findIndex((item: any) => item.fileID === fileItem.fileID) | |||||
| const index = fileListCopy.findIndex(item => item.fileID === fileItem.fileID) | |||||
| fileListCopy[index] = completeFile | fileListCopy[index] = completeFile | ||||
| onFileUpdate(completeFile, 100, fileListCopy) | onFileUpdate(completeFile, 100, fileListCopy) | ||||
| return Promise.resolve({ ...completeFile }) | return Promise.resolve({ ...completeFile }) | ||||
| return Promise.resolve({ ...fileItem }) | return Promise.resolve({ ...fileItem }) | ||||
| }) | }) | ||||
| .finally() | .finally() | ||||
| } | |||||
| const uploadBatchFiles = (bFiles: any) => { | |||||
| bFiles.forEach((bf: any) => (bf.progress = 0)) | |||||
| return Promise.all(bFiles.map((bFile: any) => fileUpload(bFile))) | |||||
| } | |||||
| const uploadMultipleFiles = async (files: any) => { | |||||
| }, [fileListRef, notify, onFileUpdate, t]) | |||||
| const uploadBatchFiles = useCallback((bFiles: FileItem[]) => { | |||||
| bFiles.forEach(bf => (bf.progress = 0)) | |||||
| return Promise.all(bFiles.map(fileUpload)) | |||||
| }, [fileUpload]) | |||||
| const uploadMultipleFiles = useCallback(async (files: FileItem[]) => { | |||||
| const batchCountLimit = fileUploadConfig.batch_count_limit | |||||
| const length = files.length | const length = files.length | ||||
| let start = 0 | let start = 0 | ||||
| let end = 0 | let end = 0 | ||||
| while (start < length) { | while (start < length) { | ||||
| if (start + BATCH_COUNT > length) | |||||
| if (start + batchCountLimit > length) | |||||
| end = length | end = length | ||||
| else | else | ||||
| end = start + BATCH_COUNT | |||||
| end = start + batchCountLimit | |||||
| const bFiles = files.slice(start, end) | const bFiles = files.slice(start, end) | ||||
| await uploadBatchFiles(bFiles) | await uploadBatchFiles(bFiles) | ||||
| start = end | start = end | ||||
| } | } | ||||
| } | |||||
| const initialUpload = (files: any) => { | |||||
| }, [fileUploadConfig, uploadBatchFiles]) | |||||
| const initialUpload = useCallback((files: File[]) => { | |||||
| if (!files.length) | if (!files.length) | ||||
| return false | return false | ||||
| const preparedFiles = files.map((file: any, index: number) => { | |||||
| const fileItem = { | |||||
| fileID: `file${index}-${Date.now()}`, | |||||
| file, | |||||
| progress: -1, | |||||
| } | |||||
| return fileItem | |||||
| }) | |||||
| const preparedFiles = files.map((file, index) => ({ | |||||
| fileID: `file${index}-${Date.now()}`, | |||||
| file, | |||||
| progress: -1, | |||||
| })) | |||||
| const newFiles = [...fileListRef.current, ...preparedFiles] | const newFiles = [...fileListRef.current, ...preparedFiles] | ||||
| prepareFileList(newFiles) | prepareFileList(newFiles) | ||||
| fileListRef.current = newFiles | fileListRef.current = newFiles | ||||
| uploadMultipleFiles(preparedFiles) | uploadMultipleFiles(preparedFiles) | ||||
| } | |||||
| }, [prepareFileList, uploadMultipleFiles]) | |||||
| const handleDragEnter = (e: DragEvent) => { | const handleDragEnter = (e: DragEvent) => { | ||||
| e.preventDefault() | e.preventDefault() | ||||
| e.stopPropagation() | e.stopPropagation() | ||||
| e.target === dragRef.current && setDragging(false) | e.target === dragRef.current && setDragging(false) | ||||
| } | } | ||||
| const handleDrop = (e: DragEvent) => { | |||||
| const handleDrop = useCallback((e: DragEvent) => { | |||||
| e.preventDefault() | e.preventDefault() | ||||
| e.stopPropagation() | e.stopPropagation() | ||||
| setDragging(false) | setDragging(false) | ||||
| if (!e.dataTransfer) | if (!e.dataTransfer) | ||||
| return | return | ||||
| const files = [...e.dataTransfer.files] | |||||
| const validFiles = files.filter(file => isValid(file)) | |||||
| // fileUpload(files[0]) | |||||
| const files = [...e.dataTransfer.files] as File[] | |||||
| const validFiles = files.filter(isValid) | |||||
| initialUpload(validFiles) | initialUpload(validFiles) | ||||
| } | |||||
| }, [initialUpload, isValid]) | |||||
| const selectHandle = () => { | const selectHandle = () => { | ||||
| if (fileUploader.current) | if (fileUploader.current) | ||||
| if (fileUploader.current) | if (fileUploader.current) | ||||
| fileUploader.current.value = '' | fileUploader.current.value = '' | ||||
| fileListRef.current = fileListRef.current.filter((item: any) => item.fileID !== fileID) | |||||
| fileListRef.current = fileListRef.current.filter(item => item.fileID !== fileID) | |||||
| onFileListUpdate?.([...fileListRef.current]) | onFileListUpdate?.([...fileListRef.current]) | ||||
| } | } | ||||
| const fileChangeHandle = (e: React.ChangeEvent<HTMLInputElement>) => { | |||||
| const files = [...(e.target.files ?? [])].filter(file => isValid(file)) | |||||
| initialUpload(files) | |||||
| } | |||||
| const fileChangeHandle = useCallback((e: React.ChangeEvent<HTMLInputElement>) => { | |||||
| const files = [...(e.target.files ?? [])] as File[] | |||||
| initialUpload(files.filter(isValid)) | |||||
| }, [isValid, initialUpload]) | |||||
| useEffect(() => { | useEffect(() => { | ||||
| dropRef.current?.addEventListener('dragenter', handleDragEnter) | dropRef.current?.addEventListener('dragenter', handleDragEnter) | ||||
| dropRef.current?.removeEventListener('dragleave', handleDragLeave) | dropRef.current?.removeEventListener('dragleave', handleDragLeave) | ||||
| dropRef.current?.removeEventListener('drop', handleDrop) | dropRef.current?.removeEventListener('drop', handleDrop) | ||||
| } | } | ||||
| }, []) | |||||
| }, [handleDrop]) | |||||
| return ( | return ( | ||||
| <div className={s.fileUploader}> | <div className={s.fileUploader}> | ||||
| <span>{t('datasetCreation.stepOne.uploader.button')}</span> | <span>{t('datasetCreation.stepOne.uploader.button')}</span> | ||||
| <label className={s.browse} onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.browse')}</label> | <label className={s.browse} onClick={selectHandle}>{t('datasetCreation.stepOne.uploader.browse')}</label> | ||||
| </div> | </div> | ||||
| <div className={s.tip}>{t('datasetCreation.stepOne.uploader.tip')}</div> | |||||
| <div className={s.tip}>{t('datasetCreation.stepOne.uploader.tip', { size: fileUploadConfig.file_size_limit })}</div> | |||||
| {dragging && <div ref={dragRef} className={s.draggingCover}/>} | {dragging && <div ref={dragRef} className={s.draggingCover}/>} | ||||
| </div> | </div> | ||||
| <div className={s.fileList}> | <div className={s.fileList}> |
| import StepTwo from './step-two' | import StepTwo from './step-two' | ||||
| import StepThree from './step-three' | import StepThree from './step-three' | ||||
| import { DataSourceType } from '@/models/datasets' | import { DataSourceType } from '@/models/datasets' | ||||
| import type { DataSet, createDocumentResponse } from '@/models/datasets' | |||||
| import type { DataSet, FileItem, createDocumentResponse } from '@/models/datasets' | |||||
| import { fetchDataSource, fetchTenantInfo } from '@/service/common' | import { fetchDataSource, fetchTenantInfo } from '@/service/common' | ||||
| import { fetchDataDetail } from '@/service/datasets' | import { fetchDataDetail } from '@/service/datasets' | ||||
| import type { DataSourceNotionPage } from '@/models/common' | import type { DataSourceNotionPage } from '@/models/common' | ||||
| const [dataSourceType, setDataSourceType] = useState<DataSourceType>(DataSourceType.FILE) | const [dataSourceType, setDataSourceType] = useState<DataSourceType>(DataSourceType.FILE) | ||||
| const [step, setStep] = useState(1) | const [step, setStep] = useState(1) | ||||
| const [indexingTypeCache, setIndexTypeCache] = useState('') | const [indexingTypeCache, setIndexTypeCache] = useState('') | ||||
| const [fileList, setFiles] = useState<any[]>([]) | |||||
| const [fileList, setFiles] = useState<FileItem[]>([]) | |||||
| const [result, setResult] = useState<createDocumentResponse | undefined>() | const [result, setResult] = useState<createDocumentResponse | undefined>() | ||||
| const [hasError, setHasError] = useState(false) | const [hasError, setHasError] = useState(false) | ||||
| setNotionPages(value) | setNotionPages(value) | ||||
| } | } | ||||
| const updateFileList = (preparedFiles: any) => { | |||||
| const updateFileList = (preparedFiles: FileItem[]) => { | |||||
| setFiles(preparedFiles) | setFiles(preparedFiles) | ||||
| } | } | ||||
| const updateFile = (fileItem: any, progress: number, list: any[]) => { | |||||
| const targetIndex = list.findIndex((file: any) => file.fileID === fileItem.fileID) | |||||
| const updateFile = (fileItem: FileItem, progress: number, list: FileItem[]) => { | |||||
| const targetIndex = list.findIndex(file => file.fileID === fileItem.fileID) | |||||
| list[targetIndex] = { | list[targetIndex] = { | ||||
| ...list[targetIndex], | ...list[targetIndex], | ||||
| progress, | progress, |
| import NotionPagePreview from '../notion-page-preview' | import NotionPagePreview from '../notion-page-preview' | ||||
| import EmptyDatasetCreationModal from '../empty-dataset-creation-modal' | import EmptyDatasetCreationModal from '../empty-dataset-creation-modal' | ||||
| import s from './index.module.css' | import s from './index.module.css' | ||||
| import type { File } from '@/models/datasets' | |||||
| import type { FileItem } from '@/models/datasets' | |||||
| import type { DataSourceNotionPage } from '@/models/common' | import type { DataSourceNotionPage } from '@/models/common' | ||||
| import { DataSourceType } from '@/models/datasets' | import { DataSourceType } from '@/models/datasets' | ||||
| import Button from '@/app/components/base/button' | import Button from '@/app/components/base/button' | ||||
| dataSourceTypeDisable: Boolean | dataSourceTypeDisable: Boolean | ||||
| hasConnection: boolean | hasConnection: boolean | ||||
| onSetting: () => void | onSetting: () => void | ||||
| files: any[] | |||||
| updateFileList: (files: any[]) => void | |||||
| updateFile: (fileItem: any, progress: number, list: any[]) => void | |||||
| files: FileItem[] | |||||
| updateFileList: (files: FileItem[]) => void | |||||
| updateFile: (fileItem: FileItem, progress: number, list: FileItem[]) => void | |||||
| notionPages?: any[] | notionPages?: any[] | ||||
| updateNotionPages: (value: any[]) => void | updateNotionPages: (value: any[]) => void | ||||
| onStepChange: () => void | onStepChange: () => void |
| import { groupBy } from 'lodash-es' | import { groupBy } from 'lodash-es' | ||||
| import PreviewItem, { PreviewType } from './preview-item' | import PreviewItem, { PreviewType } from './preview-item' | ||||
| import s from './index.module.css' | import s from './index.module.css' | ||||
| import type { CreateDocumentReq, File, FullDocumentDetail, FileIndexingEstimateResponse as IndexingEstimateResponse, NotionInfo, PreProcessingRule, Rules, createDocumentResponse } from '@/models/datasets' | |||||
| import type { CreateDocumentReq, CustomFile, FullDocumentDetail, FileIndexingEstimateResponse as IndexingEstimateResponse, NotionInfo, PreProcessingRule, Rules, createDocumentResponse } from '@/models/datasets' | |||||
| import { | import { | ||||
| createDocument, | createDocument, | ||||
| createFirstDocument, | createFirstDocument, | ||||
| datasetId?: string | datasetId?: string | ||||
| indexingType?: string | indexingType?: string | ||||
| dataSourceType: DataSourceType | dataSourceType: DataSourceType | ||||
| files: File[] | |||||
| files: CustomFile[] | |||||
| notionPages?: Page[] | notionPages?: Page[] | ||||
| onStepChange?: (delta: number) => void | onStepChange?: (delta: number) => void | ||||
| updateIndexingTypeCache?: (type: string) => void | updateIndexingTypeCache?: (type: string) => void |
| title: 'Upload text file', | title: 'Upload text file', | ||||
| button: 'Drag and drop file, or', | button: 'Drag and drop file, or', | ||||
| browse: 'Browse', | browse: 'Browse', | ||||
| tip: 'Supports txt, html, markdown, xlsx, and pdf. Max 15MB each.', | |||||
| tip: 'Supports txt, html, markdown, xlsx, and pdf. Max {{size}}MB each.', | |||||
| validation: { | validation: { | ||||
| typeError: 'File type not supported', | typeError: 'File type not supported', | ||||
| size: 'File too large. Maximum is 15MB', | |||||
| size: 'File too large. Maximum is {{size}}MB', | |||||
| count: 'Multiple files not supported', | count: 'Multiple files not supported', | ||||
| }, | }, | ||||
| cancel: 'Cancel', | cancel: 'Cancel', |
| title: '上传文本文件', | title: '上传文本文件', | ||||
| button: '拖拽文件至此,或者', | button: '拖拽文件至此,或者', | ||||
| browse: '选择文件', | browse: '选择文件', | ||||
| tip: '已支持 TXT、 HTML、 Markdown、 PDF、 XLSX,每个文件不超过 15 MB。', | |||||
| tip: '已支持 TXT、 HTML、 Markdown、 PDF、 XLSX,每个文件不超过 {{size}}MB。', | |||||
| validation: { | validation: { | ||||
| typeError: '文件类型不支持', | typeError: '文件类型不支持', | ||||
| size: '文件太大了,不能超过 15MB', | |||||
| size: '文件太大了,不能超过 {{size}}MB', | |||||
| count: '暂不支持多个文件', | count: '暂不支持多个文件', | ||||
| }, | }, | ||||
| cancel: '取消', | cancel: '取消', |
| api_key: string | api_key: string | ||||
| } | null | } | null | ||||
| } | } | ||||
| export type FileUploadConfigResponse = { | |||||
| file_size_limit: number | |||||
| batch_count_limit: number | |||||
| } |
| word_count: number | word_count: number | ||||
| } | } | ||||
| export type File = { | |||||
| id: string | |||||
| name: string | |||||
| size: number | |||||
| extension: string | |||||
| mime_type: string | |||||
| created_by: string | |||||
| created_at: number | |||||
| export type CustomFile = File & { | |||||
| id?: string | |||||
| extension?: string | |||||
| mime_type?: string | |||||
| created_by?: string | |||||
| created_at?: number | |||||
| } | |||||
| export type FileItem = { | |||||
| fileID: string | |||||
| file: CustomFile | |||||
| progress: number | |||||
| } | } | ||||
| export type DataSetListResponse = { | export type DataSetListResponse = { |
| import { del, get, patch, post, put } from './base' | import { del, get, patch, post, put } from './base' | ||||
| import type { | import type { | ||||
| AccountIntegrate, CommonResponse, DataSourceNotion, | AccountIntegrate, CommonResponse, DataSourceNotion, | ||||
| FileUploadConfigResponse, | |||||
| ICurrentWorkspace, | ICurrentWorkspace, | ||||
| IWorkspace, LangGeniusVersionResponse, Member, | IWorkspace, LangGeniusVersionResponse, Member, | ||||
| OauthResponse, PluginProvider, Provider, ProviderAnthropicToken, ProviderAzureToken, | OauthResponse, PluginProvider, Provider, ProviderAnthropicToken, ProviderAzureToken, | ||||
| export const submitFreeQuota: Fetcher<{ type: string; redirect_url?: string; result?: string }, string> = (url) => { | export const submitFreeQuota: Fetcher<{ type: string; redirect_url?: string; result?: string }, string> = (url) => { | ||||
| return post(url) as Promise<{ type: string; redirect_url?: string; result?: string }> | return post(url) as Promise<{ type: string; redirect_url?: string; result?: string }> | ||||
| } | } | ||||
| export const fetchFileUploadConfig: Fetcher<FileUploadConfigResponse, { url: string }> = ({ url }) => { | |||||
| return get(url) as Promise<FileUploadConfigResponse> | |||||
| } |