add docling presets
This commit is contained in:
parent
9ad1fb3f4f
commit
88c9d60986
9 changed files with 156 additions and 57 deletions
|
|
@ -20,10 +20,8 @@ knowledge:
|
||||||
chunk_size: 1000
|
chunk_size: 1000
|
||||||
# Overlap between chunks
|
# Overlap between chunks
|
||||||
chunk_overlap: 200
|
chunk_overlap: 200
|
||||||
# Enable OCR for image processing
|
# Docling preset setting
|
||||||
ocr: true
|
doclingPresets: standard
|
||||||
# Enable picture descriptions using vision models
|
|
||||||
picture_descriptions: false
|
|
||||||
|
|
||||||
# AI agent configuration
|
# AI agent configuration
|
||||||
agent:
|
agent:
|
||||||
|
|
|
||||||
44
frontend/components/ui/radio-group.tsx
Normal file
44
frontend/components/ui/radio-group.tsx
Normal 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 }
|
||||||
33
frontend/package-lock.json
generated
33
frontend/package-lock.json
generated
|
|
@ -19,6 +19,7 @@
|
||||||
"@radix-ui/react-label": "^2.1.7",
|
"@radix-ui/react-label": "^2.1.7",
|
||||||
"@radix-ui/react-navigation-menu": "^1.2.13",
|
"@radix-ui/react-navigation-menu": "^1.2.13",
|
||||||
"@radix-ui/react-popover": "^1.1.15",
|
"@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-select": "^2.2.5",
|
||||||
"@radix-ui/react-separator": "^1.1.7",
|
"@radix-ui/react-separator": "^1.1.7",
|
||||||
"@radix-ui/react-slider": "^1.3.6",
|
"@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": {
|
"node_modules/@radix-ui/react-roving-focus": {
|
||||||
"version": "1.1.11",
|
"version": "1.1.11",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-roving-focus/-/react-roving-focus-1.1.11.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-roving-focus/-/react-roving-focus-1.1.11.tgz",
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
"@radix-ui/react-label": "^2.1.7",
|
"@radix-ui/react-label": "^2.1.7",
|
||||||
"@radix-ui/react-navigation-menu": "^1.2.13",
|
"@radix-ui/react-navigation-menu": "^1.2.13",
|
||||||
"@radix-ui/react-popover": "^1.1.15",
|
"@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-select": "^2.2.5",
|
||||||
"@radix-ui/react-separator": "^1.1.7",
|
"@radix-ui/react-separator": "^1.1.7",
|
||||||
"@radix-ui/react-slider": "^1.3.6",
|
"@radix-ui/react-slider": "^1.3.6",
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,7 @@ interface UpdateFlowSettingVariables {
|
||||||
llm_model?: string;
|
llm_model?: string;
|
||||||
system_prompt?: string;
|
system_prompt?: string;
|
||||||
embedding_model?: string;
|
embedding_model?: string;
|
||||||
ocr?: boolean;
|
doclingPresets?: string;
|
||||||
picture_descriptions?: boolean;
|
|
||||||
chunk_size?: number;
|
chunk_size?: number;
|
||||||
chunk_overlap?: number;
|
chunk_overlap?: number;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,8 +13,7 @@ export interface KnowledgeSettings {
|
||||||
embedding_model?: string;
|
embedding_model?: string;
|
||||||
chunk_size?: number;
|
chunk_size?: number;
|
||||||
chunk_overlap?: number;
|
chunk_overlap?: number;
|
||||||
ocr?: boolean;
|
doclingPresets?: string;
|
||||||
picture_descriptions?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Settings {
|
export interface Settings {
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ import {
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
|
import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
|
|
@ -100,6 +101,7 @@ function KnowledgeSourcesPage() {
|
||||||
const [systemPrompt, setSystemPrompt] = useState<string>("");
|
const [systemPrompt, setSystemPrompt] = useState<string>("");
|
||||||
const [chunkSize, setChunkSize] = useState<number>(1024);
|
const [chunkSize, setChunkSize] = useState<number>(1024);
|
||||||
const [chunkOverlap, setChunkOverlap] = useState<number>(50);
|
const [chunkOverlap, setChunkOverlap] = useState<number>(50);
|
||||||
|
const [processingMode, setProcessingMode] = useState<string>("standard");
|
||||||
|
|
||||||
// Fetch settings using React Query
|
// Fetch settings using React Query
|
||||||
const { data: settings = {} } = useGetSettingsQuery({
|
const { data: settings = {} } = useGetSettingsQuery({
|
||||||
|
|
@ -175,6 +177,13 @@ function KnowledgeSourcesPage() {
|
||||||
}
|
}
|
||||||
}, [settings.knowledge?.chunk_overlap]);
|
}, [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
|
// Update model selection immediately
|
||||||
const handleModelChange = (newModel: string) => {
|
const handleModelChange = (newModel: string) => {
|
||||||
updateFlowSettingMutation.mutate({ llm_model: newModel });
|
updateFlowSettingMutation.mutate({ llm_model: newModel });
|
||||||
|
|
@ -204,6 +213,12 @@ function KnowledgeSourcesPage() {
|
||||||
debouncedUpdate({ chunk_overlap: numValue });
|
debouncedUpdate({ chunk_overlap: numValue });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Update processing mode
|
||||||
|
const handleProcessingModeChange = (mode: string) => {
|
||||||
|
setProcessingMode(mode);
|
||||||
|
debouncedUpdate({ doclingPresets: mode });
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Helper function to get connector icon
|
// Helper function to get connector icon
|
||||||
const getConnectorIcon = useCallback((iconName: string) => {
|
const getConnectorIcon = useCallback((iconName: string) => {
|
||||||
|
|
@ -777,40 +792,59 @@ function KnowledgeSourcesPage() {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* <div className="flex items-center justify-between">
|
<div className="space-y-3">
|
||||||
<div className="space-y-0.5">
|
<Label className="text-base font-medium">Ingest Presets</Label>
|
||||||
<Label htmlFor="ocrEnabled" className="text-base font-medium">
|
<RadioGroup
|
||||||
OCR
|
value={processingMode}
|
||||||
</Label>
|
onValueChange={handleProcessingModeChange}
|
||||||
<div className="text-sm text-muted-foreground">
|
className="space-y-3"
|
||||||
Extracts text from images/PDFs. Ingest is slower when enabled.
|
>
|
||||||
|
<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>
|
||||||
</div>
|
<div className="flex items-center space-x-3">
|
||||||
<Switch
|
<RadioGroupItem value="ocr" id="ocr" />
|
||||||
id="ocrEnabled"
|
<div className="flex-1">
|
||||||
checked={ocrEnabled}
|
<Label htmlFor="ocr" className="text-base font-medium cursor-pointer">
|
||||||
onCheckedChange={handleOcrChange}
|
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>
|
||||||
<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>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
|
||||||
|
|
@ -104,7 +104,7 @@ export function LayoutWrapper({ children }: { children: React.ReactNode }) {
|
||||||
<Navigation />
|
<Navigation />
|
||||||
</div>
|
</div>
|
||||||
<main
|
<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
|
isMenuOpen && isPanelOpen
|
||||||
? "md:pr-[728px]"
|
? "md:pr-[728px]"
|
||||||
: // Both open: 384px (menu) + 320px (KF panel) + 24px (original padding)
|
: // Both open: 384px (menu) + 320px (KF panel) + 24px (original padding)
|
||||||
|
|
|
||||||
|
|
@ -38,8 +38,7 @@ async def get_settings(request, session_manager):
|
||||||
"embedding_model": knowledge_config.embedding_model,
|
"embedding_model": knowledge_config.embedding_model,
|
||||||
"chunk_size": knowledge_config.chunk_size,
|
"chunk_size": knowledge_config.chunk_size,
|
||||||
"chunk_overlap": knowledge_config.chunk_overlap,
|
"chunk_overlap": knowledge_config.chunk_overlap,
|
||||||
"ocr": knowledge_config.ocr,
|
"doclingPresets": knowledge_config.doclingPresets,
|
||||||
"picture_descriptions": knowledge_config.picture_descriptions,
|
|
||||||
},
|
},
|
||||||
"agent": {
|
"agent": {
|
||||||
"llm_model": agent_config.llm_model,
|
"llm_model": agent_config.llm_model,
|
||||||
|
|
@ -149,7 +148,7 @@ async def update_settings(request, session_manager):
|
||||||
|
|
||||||
# Validate allowed fields
|
# Validate allowed fields
|
||||||
allowed_fields = {
|
allowed_fields = {
|
||||||
"llm_model", "system_prompt", "ocr", "picture_descriptions",
|
"llm_model", "system_prompt", "doclingPresets",
|
||||||
"chunk_size", "chunk_overlap"
|
"chunk_size", "chunk_overlap"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,22 +173,14 @@ async def update_settings(request, session_manager):
|
||||||
config_updated = True
|
config_updated = True
|
||||||
|
|
||||||
# Update knowledge settings
|
# Update knowledge settings
|
||||||
if "ocr" in body:
|
if "doclingPresets" in body:
|
||||||
if not isinstance(body["ocr"], bool):
|
valid_presets = ["standard", "ocr", "picture_description", "VLM"]
|
||||||
|
if body["doclingPresets"] not in valid_presets:
|
||||||
return JSONResponse(
|
return JSONResponse(
|
||||||
{"error": "ocr must be a boolean value"},
|
{"error": f"doclingPresets must be one of: {', '.join(valid_presets)}"},
|
||||||
status_code=400
|
status_code=400
|
||||||
)
|
)
|
||||||
current_config.knowledge.ocr = body["ocr"]
|
current_config.knowledge.doclingPresets = body["doclingPresets"]
|
||||||
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"]
|
|
||||||
config_updated = True
|
config_updated = True
|
||||||
|
|
||||||
if "chunk_size" in body:
|
if "chunk_size" in body:
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue