mirror of
https://github.com/Crosstalk-Solutions/project-nomad.git
synced 2026-04-05 08:16:16 +02: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 { useModals } from '~/context/ModalContext'
|
||||||
import StyledModal from '../StyledModal'
|
import StyledModal from '../StyledModal'
|
||||||
import ActiveEmbedJobs from '~/components/ActiveEmbedJobs'
|
import ActiveEmbedJobs from '~/components/ActiveEmbedJobs'
|
||||||
|
import { useSystemSetting } from '~/hooks/useSystemSetting'
|
||||||
|
|
||||||
interface KnowledgeBaseModalProps {
|
interface KnowledgeBaseModalProps {
|
||||||
aiAssistantName?: string
|
aiAssistantName?: string
|
||||||
|
|
@ -29,6 +30,13 @@ export default function KnowledgeBaseModal({ aiAssistantName = "AI Assistant", o
|
||||||
const { openModal, closeModal } = useModals()
|
const { openModal, closeModal } = useModals()
|
||||||
const queryClient = useQueryClient()
|
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({
|
const { data: storedFiles = [], isLoading: isLoadingFiles } = useQuery({
|
||||||
queryKey: ['storedFiles'],
|
queryKey: ['storedFiles'],
|
||||||
queryFn: () => api.getStoredRAGFiles(),
|
queryFn: () => api.getStoredRAGFiles(),
|
||||||
|
|
@ -134,6 +142,7 @@ export default function KnowledgeBaseModal({ aiAssistantName = "AI Assistant", o
|
||||||
ref={fileUploaderRef}
|
ref={fileUploaderRef}
|
||||||
minFiles={1}
|
minFiles={1}
|
||||||
maxFiles={1}
|
maxFiles={1}
|
||||||
|
maxFileSize={maxFileSize}
|
||||||
onUpload={(uploadedFiles) => {
|
onUpload={(uploadedFiles) => {
|
||||||
setFiles(Array.from(uploadedFiles))
|
setFiles(Array.from(uploadedFiles))
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ const FileUploader = forwardRef<FileUploaderRef, FileUploaderProps>((props, ref)
|
||||||
const {
|
const {
|
||||||
minFiles = 0,
|
minFiles = 0,
|
||||||
maxFiles = 1,
|
maxFiles = 1,
|
||||||
maxFileSize = 10485760, // default to 10MB
|
maxFileSize = 104857600, // default to 100MB
|
||||||
fileTypes,
|
fileTypes,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
onUpload,
|
onUpload,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ export const KV_STORE_SCHEMA = {
|
||||||
'system.earlyAccess': 'boolean',
|
'system.earlyAccess': 'boolean',
|
||||||
'ui.hasVisitedEasySetup': 'boolean',
|
'ui.hasVisitedEasySetup': 'boolean',
|
||||||
'ai.assistantCustomName': 'string',
|
'ai.assistantCustomName': 'string',
|
||||||
|
'rag.maxFileSizeMB': 'string',
|
||||||
} as const
|
} as const
|
||||||
|
|
||||||
type KVTagToType<T extends string> = T extends 'boolean' ? boolean : string
|
type KVTagToType<T extends string> = T extends 'boolean' ? boolean : string
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user