add docling presets

This commit is contained in:
Mike Fortman 2025-09-19 12:04:23 -05:00
parent 9ad1fb3f4f
commit 88c9d60986
9 changed files with 156 additions and 57 deletions

View file

@ -20,10 +20,8 @@ knowledge:
chunk_size: 1000
# Overlap between chunks
chunk_overlap: 200
# Enable OCR for image processing
ocr: true
# Enable picture descriptions using vision models
picture_descriptions: false
# Docling preset setting
doclingPresets: standard
# AI agent configuration
agent:

View file

@ -0,0 +1,44 @@
"use client"
import * as React from "react"
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group"
import { Circle } from "lucide-react"
import { cn } from "@/lib/utils"
const RadioGroup = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
>(({ className, ...props }, ref) => {
return (
<RadioGroupPrimitive.Root
className={cn("grid gap-2", className)}
{...props}
ref={ref}
/>
)
})
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName
const RadioGroupItem = React.forwardRef<
React.ElementRef<typeof RadioGroupPrimitive.Item>,
React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>
>(({ className, ...props }, ref) => {
return (
<RadioGroupPrimitive.Item
ref={ref}
className={cn(
"aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
className
)}
{...props}
>
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
<Circle className="h-2.5 w-2.5 fill-current text-current" />
</RadioGroupPrimitive.Indicator>
</RadioGroupPrimitive.Item>
)
})
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName
export { RadioGroup, RadioGroupItem }

View file

@ -19,6 +19,7 @@
"@radix-ui/react-label": "^2.1.7",
"@radix-ui/react-navigation-menu": "^1.2.13",
"@radix-ui/react-popover": "^1.1.15",
"@radix-ui/react-radio-group": "^1.3.8",
"@radix-ui/react-select": "^2.2.5",
"@radix-ui/react-separator": "^1.1.7",
"@radix-ui/react-slider": "^1.3.6",
@ -1819,6 +1820,38 @@
}
}
},
"node_modules/@radix-ui/react-radio-group": {
"version": "1.3.8",
"resolved": "https://registry.npmjs.org/@radix-ui/react-radio-group/-/react-radio-group-1.3.8.tgz",
"integrity": "sha512-VBKYIYImA5zsxACdisNQ3BjCBfmbGH3kQlnFVqlWU4tXwjy7cGX8ta80BcrO+WJXIn5iBylEH3K6ZTlee//lgQ==",
"license": "MIT",
"dependencies": {
"@radix-ui/primitive": "1.1.3",
"@radix-ui/react-compose-refs": "1.1.2",
"@radix-ui/react-context": "1.1.2",
"@radix-ui/react-direction": "1.1.1",
"@radix-ui/react-presence": "1.1.5",
"@radix-ui/react-primitive": "2.1.3",
"@radix-ui/react-roving-focus": "1.1.11",
"@radix-ui/react-use-controllable-state": "1.2.2",
"@radix-ui/react-use-previous": "1.1.1",
"@radix-ui/react-use-size": "1.1.1"
},
"peerDependencies": {
"@types/react": "*",
"@types/react-dom": "*",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
},
"@types/react-dom": {
"optional": true
}
}
},
"node_modules/@radix-ui/react-roving-focus": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/@radix-ui/react-roving-focus/-/react-roving-focus-1.1.11.tgz",

View file

@ -20,6 +20,7 @@
"@radix-ui/react-label": "^2.1.7",
"@radix-ui/react-navigation-menu": "^1.2.13",
"@radix-ui/react-popover": "^1.1.15",
"@radix-ui/react-radio-group": "^1.3.8",
"@radix-ui/react-select": "^2.2.5",
"@radix-ui/react-separator": "^1.1.7",
"@radix-ui/react-slider": "^1.3.6",

View file

@ -8,8 +8,7 @@ interface UpdateFlowSettingVariables {
llm_model?: string;
system_prompt?: string;
embedding_model?: string;
ocr?: boolean;
picture_descriptions?: boolean;
doclingPresets?: string;
chunk_size?: number;
chunk_overlap?: number;
}

View file

@ -13,8 +13,7 @@ export interface KnowledgeSettings {
embedding_model?: string;
chunk_size?: number;
chunk_overlap?: number;
ocr?: boolean;
picture_descriptions?: boolean;
doclingPresets?: string;
}
export interface Settings {

View file

@ -22,6 +22,7 @@ import {
import { Checkbox } from "@/components/ui/checkbox";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
import {
Select,
SelectContent,
@ -100,6 +101,7 @@ function KnowledgeSourcesPage() {
const [systemPrompt, setSystemPrompt] = useState<string>("");
const [chunkSize, setChunkSize] = useState<number>(1024);
const [chunkOverlap, setChunkOverlap] = useState<number>(50);
const [processingMode, setProcessingMode] = useState<string>("standard");
// Fetch settings using React Query
const { data: settings = {} } = useGetSettingsQuery({
@ -175,6 +177,13 @@ function KnowledgeSourcesPage() {
}
}, [settings.knowledge?.chunk_overlap]);
// Sync processing mode with settings data
useEffect(() => {
if (settings.knowledge?.doclingPresets) {
setProcessingMode(settings.knowledge.doclingPresets);
}
}, [settings.knowledge?.doclingPresets]);
// Update model selection immediately
const handleModelChange = (newModel: string) => {
updateFlowSettingMutation.mutate({ llm_model: newModel });
@ -204,6 +213,12 @@ function KnowledgeSourcesPage() {
debouncedUpdate({ chunk_overlap: numValue });
};
// Update processing mode
const handleProcessingModeChange = (mode: string) => {
setProcessingMode(mode);
debouncedUpdate({ doclingPresets: mode });
};
// Helper function to get connector icon
const getConnectorIcon = useCallback((iconName: string) => {
@ -777,40 +792,59 @@ function KnowledgeSourcesPage() {
</div>
</div>
</div>
{/* <div className="flex items-center justify-between">
<div className="space-y-0.5">
<Label htmlFor="ocrEnabled" className="text-base font-medium">
OCR
</Label>
<div className="text-sm text-muted-foreground">
Extracts text from images/PDFs. Ingest is slower when enabled.
<div className="space-y-3">
<Label className="text-base font-medium">Ingest Presets</Label>
<RadioGroup
value={processingMode}
onValueChange={handleProcessingModeChange}
className="space-y-3"
>
<div className="flex items-center space-x-3">
<RadioGroupItem value="standard" id="standard" />
<div className="flex-1">
<Label htmlFor="standard" className="text-base font-medium cursor-pointer">
Standard
</Label>
<div className="text-sm text-muted-foreground">
Fast ingest for text-based documents without images
</div>
</div>
</div>
</div>
<Switch
id="ocrEnabled"
checked={ocrEnabled}
onCheckedChange={handleOcrChange}
/>
<div className="flex items-center space-x-3">
<RadioGroupItem value="ocr" id="ocr" />
<div className="flex-1">
<Label htmlFor="ocr" className="text-base font-medium cursor-pointer">
Extract text from images
</Label>
<div className="text-sm text-muted-foreground">
Uses OCR to extract text from images/PDFs. Ingest is slower when enabled
</div>
</div>
</div>
<div className="flex items-center space-x-3">
<RadioGroupItem value="picture_description" id="picture_description" />
<div className="flex-1">
<Label htmlFor="picture_description" className="text-base font-medium cursor-pointer">
Generate Description
</Label>
<div className="text-sm text-muted-foreground">
Text extraction plust AI generated image descriptions
</div>
</div>
</div>
<div className="flex items-center space-x-3">
<RadioGroupItem value="VLM" id="VLM" />
<div className="flex-1">
<Label htmlFor="VLM" className="text-base font-medium cursor-pointer">
AI Vision
</Label>
<div className="text-sm text-muted-foreground">
Advanced processing with vision language models. Highest quality but most expensive
</div>
</div>
</div>
</RadioGroup>
</div>
<div className="flex items-center justify-between">
<div className="space-y-0.5">
<Label
htmlFor="pictureDescriptions"
className="text-base font-medium"
>
Picture descriptions
</Label>
<div className="text-sm text-muted-foreground">
Adds captions for images. Ingest is more expensive when
enabled.
</div>
</div>
<Switch
id="pictureDescriptions"
checked={pictureDescriptionsEnabled}
onCheckedChange={handlePictureDescriptionsChange}
/>
</div> */}
</div>
</CardContent>
</Card>

View file

@ -104,7 +104,7 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
<Navigation />
</div>
<main
className={`md:pl-72 transition-all duration-300 ${
className={`md:pl-72 transition-all duration-300 overflow-y-auto h-[calc(100vh-53px)] ${
isMenuOpen && isPanelOpen
? "md:pr-[728px]"
: // Both open: 384px (menu) + 320px (KF panel) + 24px (original padding)

View file

@ -38,8 +38,7 @@ async def get_settings(request, session_manager):
"embedding_model": knowledge_config.embedding_model,
"chunk_size": knowledge_config.chunk_size,
"chunk_overlap": knowledge_config.chunk_overlap,
"ocr": knowledge_config.ocr,
"picture_descriptions": knowledge_config.picture_descriptions,
"doclingPresets": knowledge_config.doclingPresets,
},
"agent": {
"llm_model": agent_config.llm_model,
@ -149,7 +148,7 @@ async def update_settings(request, session_manager):
# Validate allowed fields
allowed_fields = {
"llm_model", "system_prompt", "ocr", "picture_descriptions",
"llm_model", "system_prompt", "doclingPresets",
"chunk_size", "chunk_overlap"
}
@ -174,22 +173,14 @@ async def update_settings(request, session_manager):
config_updated = True
# Update knowledge settings
if "ocr" in body:
if not isinstance(body["ocr"], bool):
if "doclingPresets" in body:
valid_presets = ["standard", "ocr", "picture_description", "VLM"]
if body["doclingPresets"] not in valid_presets:
return JSONResponse(
{"error": "ocr must be a boolean value"},
{"error": f"doclingPresets must be one of: {', '.join(valid_presets)}"},
status_code=400
)
current_config.knowledge.ocr = body["ocr"]
config_updated = True
if "picture_descriptions" in body:
if not isinstance(body["picture_descriptions"], bool):
return JSONResponse(
{"error": "picture_descriptions must be a boolean value"},
status_code=400
)
current_config.knowledge.picture_descriptions = body["picture_descriptions"]
current_config.knowledge.doclingPresets = body["doclingPresets"]
config_updated = True
if "chunk_size" in body: