import { useMutation, useQuery } from '@tanstack/react-query' import { useRef, useState } from 'react' import FileUploader from '~/components/file-uploader' import StyledButton from '~/components/StyledButton' import StyledSectionHeader from '~/components/StyledSectionHeader' import StyledTable from '~/components/StyledTable' import { useNotifications } from '~/context/NotificationContext' import api from '~/lib/api' import { IconX } from '@tabler/icons-react' interface KnowledgeBaseModalProps { onClose: () => void } export default function KnowledgeBaseModal({ onClose }: KnowledgeBaseModalProps) { const { addNotification } = useNotifications() const [files, setFiles] = useState([]) const fileUploaderRef = useRef>(null) const { data: storedFiles = [], isLoading: isLoadingFiles } = useQuery({ queryKey: ['storedFiles'], queryFn: () => api.getStoredRAGFiles(), select: (data) => data || [], }) const uploadMutation = useMutation({ mutationFn: (file: File) => api.uploadDocument(file), onSuccess: (data) => { addNotification({ type: 'success', message: data?.message || 'Document uploaded and queued for processing', }) setFiles([]) if (fileUploaderRef.current) { fileUploaderRef.current.clear() } }, onError: (error: any) => { addNotification({ type: 'error', message: error?.message || 'Failed to upload document', }) }, }) const handleUpload = () => { if (files.length > 0) { uploadMutation.mutate(files[0]) } } return (

Knowledge Base

{ setFiles(Array.from(uploadedFiles)) }} />
Upload

Why upload documents to your Knowledge Base?

1

AI Assistant Knowledge Base Integration

When you upload documents to your Knowledge Base, NOMAD processes and embeds the content, making it directly accessible to the AI Assistant. This allows the AI Assistant to reference your specific documents during conversations, providing more accurate and personalized responses based on your uploaded data.

2

Enhanced Document Processing with OCR

NOMAD includes built-in Optical Character Recognition (OCR) capabilities, allowing it to extract text from image-based documents such as scanned PDFs or photos. This means that even if your documents are not in a standard text format, NOMAD can still process and embed their content for AI access.

3

Information Library Integration

NOMAD will automatically discover and extract any content you save to your Information Library (if installed), making it instantly available to the AI Assistant without any extra steps.

className="font-semibold" rowLines={true} columns={[ { accessor: 'source', title: 'File Name', render(record) { return {record.source} }, }, ]} data={storedFiles.map((source) => ({ source }))} loading={isLoadingFiles} />
) }