mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-03-28 03:29:25 +01:00
feat(rag): make Knowledge Base upload size limit configurable
- Increase FileUploader default maxFileSize from 10MB to 100MB - Add 'rag.maxFileSizeMB' KV store setting for configurable limit - KnowledgeBaseModal reads setting and passes to FileUploader - Falls back to 100MB default if setting is not configured Closes #259
This commit is contained in:
parent
db22b0c5f6
commit
310eae9c1d
|
|
@ -10,6 +10,7 @@ import { IconX } from '@tabler/icons-react'
|
|||
import { useModals } from '~/context/ModalContext'
|
||||
import StyledModal from '../StyledModal'
|
||||
import ActiveEmbedJobs from '~/components/ActiveEmbedJobs'
|
||||
import { useSystemSetting } from '~/hooks/useSystemSetting'
|
||||
|
||||
interface KnowledgeBaseModalProps {
|
||||
aiAssistantName?: string
|
||||
|
|
@ -29,6 +30,13 @@ export default function KnowledgeBaseModal({ aiAssistantName = "AI Assistant", o
|
|||
const { openModal, closeModal } = useModals()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const DEFAULT_MAX_FILE_SIZE_MB = 100
|
||||
const { data: maxFileSizeSetting } = useSystemSetting({ key: 'rag.maxFileSizeMB' })
|
||||
const maxFileSizeMB = maxFileSizeSetting?.value
|
||||
? Number(maxFileSizeSetting.value)
|
||||
: DEFAULT_MAX_FILE_SIZE_MB
|
||||
const maxFileSize = maxFileSizeMB * 1024 * 1024
|
||||
|
||||
const { data: storedFiles = [], isLoading: isLoadingFiles } = useQuery({
|
||||
queryKey: ['storedFiles'],
|
||||
queryFn: () => api.getStoredRAGFiles(),
|
||||
|
|
@ -134,6 +142,7 @@ export default function KnowledgeBaseModal({ aiAssistantName = "AI Assistant", o
|
|||
ref={fileUploaderRef}
|
||||
minFiles={1}
|
||||
maxFiles={1}
|
||||
maxFileSize={maxFileSize}
|
||||
onUpload={(uploadedFiles) => {
|
||||
setFiles(Array.from(uploadedFiles))
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ const FileUploader = forwardRef<FileUploaderRef, FileUploaderProps>((props, ref)
|
|||
const {
|
||||
minFiles = 0,
|
||||
maxFiles = 1,
|
||||
maxFileSize = 10485760, // default to 10MB
|
||||
maxFileSize = 104857600, // default to 100MB
|
||||
fileTypes,
|
||||
disabled = false,
|
||||
onUpload,
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ export const KV_STORE_SCHEMA = {
|
|||
'system.earlyAccess': 'boolean',
|
||||
'ui.hasVisitedEasySetup': 'boolean',
|
||||
'ai.assistantCustomName': 'string',
|
||||
'rag.maxFileSizeMB': 'string',
|
||||
} as const
|
||||
|
||||
type KVTagToType<T extends string> = T extends 'boolean' ? boolean : string
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user