diff --git a/frontend/src/components/cloud-picker/ingest-settings.tsx b/frontend/src/components/cloud-picker/ingest-settings.tsx index d5843a2a..68cf27db 100644 --- a/frontend/src/components/cloud-picker/ingest-settings.tsx +++ b/frontend/src/components/cloud-picker/ingest-settings.tsx @@ -2,13 +2,22 @@ import { Input } from "@/components/ui/input"; import { Switch } from "@/components/ui/switch"; +import { Label } from "@/components/ui/label"; import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/components/ui/collapsible"; -import { ChevronRight, Info } from "lucide-react"; +import { ChevronRight } from "lucide-react"; import { IngestSettings as IngestSettingsType } from "./types"; +import { LabelWrapper } from "@/components/label-wrapper"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; interface IngestSettingsProps { isOpen: boolean; @@ -30,6 +39,7 @@ export const IngestSettings = ({ ocr: false, pictureDescriptions: false, embeddingModel: "text-embedding-3-small", + tableStructure: false, }; // Use provided settings or defaults @@ -58,79 +68,144 @@ export const IngestSettings = ({ -
-
-
-
Chunk size
- - handleSettingsChange({ - chunkSize: parseInt(e.target.value) || 0, - }) +
+
+ + + +
+ +
+
+ +
+ + handleSettingsChange({ + chunkSize: Math.max(0, parseInt(e.target.value) || 0), + }) + } + className="w-full pr-24" + /> +
+ + characters + +
+
+
+
+ +
+ + handleSettingsChange({ + chunkOverlap: Math.max(0, parseInt(e.target.value) || 0), + }) + } + className="w-full pr-24" + /> +
+ + characters + +
+
+
+
+ +
+
+
+ +
+ Capture table structure during ingest. +
+
+ + handleSettingsChange({ tableStructure: checked }) } />
-
-
Chunk overlap
- - handleSettingsChange({ - chunkOverlap: parseInt(e.target.value) || 0, - }) +
+
+ +
+ Extracts text from images and scanned pages. +
+
+ + handleSettingsChange({ ocr: checked }) } />
-
- -
-
-
OCR
-
- Extracts text from images/PDFs. Ingest is slower when enabled. +
+
+ +
+ Generates short image captions. More expensive when enabled. +
+ + handleSettingsChange({ pictureDescriptions: checked }) + } + />
- - handleSettingsChange({ ocr: checked }) - } - /> -
- -
-
-
- Picture descriptions -
-
- Adds captions for images. Ingest is more expensive when enabled. -
-
- - handleSettingsChange({ pictureDescriptions: checked }) - } - /> -
- -
-
- Embedding model - -
- - handleSettingsChange({ embeddingModel: e.target.value }) - } - placeholder="text-embedding-3-small" - />
diff --git a/frontend/src/components/cloud-picker/types.ts b/frontend/src/components/cloud-picker/types.ts index ca346bf0..aca452fb 100644 --- a/frontend/src/components/cloud-picker/types.ts +++ b/frontend/src/components/cloud-picker/types.ts @@ -103,4 +103,5 @@ export interface IngestSettings { ocr: boolean; pictureDescriptions: boolean; embeddingModel: string; + tableStructure: boolean; } diff --git a/frontend/src/components/cloud-picker/unified-cloud-picker.tsx b/frontend/src/components/cloud-picker/unified-cloud-picker.tsx index fd77698f..2237474d 100644 --- a/frontend/src/components/cloud-picker/unified-cloud-picker.tsx +++ b/frontend/src/components/cloud-picker/unified-cloud-picker.tsx @@ -10,6 +10,9 @@ import { PickerHeader } from "./picker-header"; import { FileList } from "./file-list"; import { IngestSettings } from "./ingest-settings"; import { createProviderHandler } from "./provider-handlers"; +import { useGetSettingsQuery } from "@/app/api/queries/useGetSettingsQuery"; +import { useAuth } from "@/contexts/auth-context"; +import { DEFAULT_KNOWLEDGE_SETTINGS } from "@/lib/constants"; export const UnifiedCloudPicker = ({ provider, @@ -22,21 +25,73 @@ export const UnifiedCloudPicker = ({ baseUrl, onSettingsChange, }: UnifiedCloudPickerProps) => { + const { isNoAuthMode } = useAuth(); const [isPickerLoaded, setIsPickerLoaded] = useState(false); const [isPickerOpen, setIsPickerOpen] = useState(false); - const [isIngestSettingsOpen, setIsIngestSettingsOpen] = useState(false); + const [isIngestSettingsOpen, setIsIngestSettingsOpen] = useState(true); const [isLoadingBaseUrl, setIsLoadingBaseUrl] = useState(false); const [autoBaseUrl, setAutoBaseUrl] = useState(undefined); + // Fetch settings using React Query + const { data: settings = {} } = useGetSettingsQuery({ + enabled: isAuthenticated || isNoAuthMode, + }); + // Settings state with defaults const [ingestSettings, setIngestSettings] = useState({ - chunkSize: 1000, - chunkOverlap: 200, - ocr: false, - pictureDescriptions: false, - embeddingModel: "text-embedding-3-small", + chunkSize: DEFAULT_KNOWLEDGE_SETTINGS.chunk_size, + chunkOverlap: DEFAULT_KNOWLEDGE_SETTINGS.chunk_overlap, + ocr: DEFAULT_KNOWLEDGE_SETTINGS.ocr, + pictureDescriptions: DEFAULT_KNOWLEDGE_SETTINGS.picture_descriptions, + embeddingModel: DEFAULT_KNOWLEDGE_SETTINGS.embedding_model, + tableStructure: DEFAULT_KNOWLEDGE_SETTINGS.table_structure, }); + // Sync chunk size with backend settings + useEffect(() => { + const chunkSize = settings.knowledge?.chunk_size; + if (chunkSize !== undefined) { + setIngestSettings(prev => ({ + ...prev, + chunkSize: chunkSize, + })); + } + }, [settings.knowledge]); + + // Sync chunk overlap with backend settings + useEffect(() => { + const chunkOverlap = settings.knowledge?.chunk_overlap; + if (chunkOverlap !== undefined) { + setIngestSettings(prev => ({ + ...prev, + chunkOverlap: chunkOverlap, + })); + } + }, [settings.knowledge]); + + // Sync processing mode (doclingPresets) with OCR and picture descriptions + useEffect(() => { + const mode = settings.knowledge?.doclingPresets; + if (mode) { + setIngestSettings(prev => ({ + ...prev, + ocr: mode === "ocr" || mode === "picture_description" || mode === "VLM", + pictureDescriptions: mode === "picture_description", + })); + } + }, [settings.knowledge]); + + // Sync embedding model with backend settings + useEffect(() => { + const embeddingModel = settings.knowledge?.embedding_model; + if (embeddingModel) { + setIngestSettings(prev => ({ + ...prev, + embeddingModel: embeddingModel, + })); + } + }, [settings.knowledge]); + // Handle settings changes and notify parent const handleSettingsChange = (newSettings: IngestSettingsType) => { setIngestSettings(newSettings); diff --git a/frontend/src/lib/constants.ts b/frontend/src/lib/constants.ts index 9c6ea7b0..d92e5a13 100644 --- a/frontend/src/lib/constants.ts +++ b/frontend/src/lib/constants.ts @@ -3,7 +3,8 @@ */ export const DEFAULT_AGENT_SETTINGS = { llm_model: "gpt-4o-mini", - system_prompt: "You are a helpful assistant that can use tools to answer questions and perform tasks." + system_prompt: + "You are a helpful assistant that can use tools to answer questions and perform tasks.", } as const; /** @@ -12,7 +13,11 @@ export const DEFAULT_AGENT_SETTINGS = { export const DEFAULT_KNOWLEDGE_SETTINGS = { chunk_size: 1000, chunk_overlap: 200, - processing_mode: "standard" + processing_mode: "standard", + table_structure: false, + ocr: false, + picture_descriptions: false, + embedding_model: "text-embedding-3-small", } as const; /** @@ -20,4 +25,4 @@ export const DEFAULT_KNOWLEDGE_SETTINGS = { */ export const UI_CONSTANTS = { MAX_SYSTEM_PROMPT_CHARS: 2000, -} as const; \ No newline at end of file +} as const;