RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
refactor(parser): drop write-only setup fields from picture/audio parsers (#19971)
jay77721f4cf4ba9f167
diff --git a/internal/ingestion/component/parser.go b/internal/ingestion/component/parser.goindex 78ae0e24d6..353ba66b6d 100644--- a/internal/ingestion/component/parser.go+++ b/internal/ingestion/component/parser.go@@ -67,10 +67,10 @@// - The Python _param.check() business validation// (parse_method whitelist, conditional lang checks) is mirrored// by (*ParserComponent).Check() below, which NewParserComponent-// runs at construction time. The Python flow check() also-// validates audio/video vlm.llm_id, but Go media_dispatch uses-// tenant default models (resolveTenantModelByType) rather than-// setup["vlm"]["llm_id"], so that check is intentionally omitted.+// runs at construction time. Neither backend validates+// audio/video vlm.llm_id: Python's check() has no such branch,+// and the audio model is resolved at dispatch time with a+// tenant-default fallback.//// - NO PERSISTENCE: structured parser items live only in the per-run// output map.@@ -210,11 +210,10 @@ func cloneParserSetupValue(value any) any {// (Python raises ValueError on the first failure).//// NOT covered here (intentional):-// - audio/video vlm.llm_id: Go media_dispatch uses tenant default-// models (resolveTenantModelByType), not setup["vlm"]["llm_id"].-// The Python flow check() for vlm.llm_id does not apply — Go-// never reads that field, and validating it would block every-// valid audio/video pipeline (see ingestion_pipeline_audio.json).+// - audio/video vlm.llm_id: Python's check() does not validate it+// either, and audio dispatch resolves a missing/empty model to+// the tenant default, so validating it here would only block+// otherwise valid pipelines (see ingestion_pipeline_audio.json).func (c *ParserComponent) Check() error {// PDF family (parser.py:252-261).if pdf, ok := c.setups["pdf"]; ok {diff --git a/internal/ingestion/component/parser_check_test.go b/internal/ingestion/component/parser_check_test.goindex 7213e50f90..63d526848f 100644--- a/internal/ingestion/component/parser_check_test.go+++ b/internal/ingestion/component/parser_check_test.go@@ -26,9 +26,9 @@ import (// TestParserComponent_Check covers the construction-time business// validation for parser methods that require language configuration.//-// Go does NOT validate audio/video vlm.llm_id because media_dispatch-// resolves tenant default models via resolveTenantModelByType, not-// setup["vlm"]["llm_id"]. See plan: quantum-forging-curie-sZ_7zRZb.+// audio/video vlm.llm_id is not validated: Python's check() has no+// such branch, and audio resolves its model at dispatch time with a+// tenant-default fallback.func TestParserComponent_Check(t *testing.T) {cases := []struct {name string@@ -99,17 +99,17 @@ func TestParserComponent_Check(t *testing.T) {setups: map[string]schema.ParserSetup{"image": {"lang": "English"}},},- // --- audio/video: vlm.llm_id NOT validated in Go ---+ // --- audio/video: vlm.llm_id not validated (matches Python check()) ---{- name: "audio: no vlm field → pass (Go uses tenant default ASR)",+ name: "audio: no vlm field → pass (model falls back to tenant default)",setups: map[string]schema.ParserSetup{"audio": {"output_format": "text"}},},{- name: "video: no vlm field → pass (Go uses tenant default VISION)",+ name: "video: no vlm field → pass",setups: map[string]schema.ParserSetup{"video": {"output_format": "text"}},},{- name: "audio: vlm.llm_id empty → pass (Go ignores vlm.llm_id)",+ name: "audio: vlm.llm_id empty → pass (empty falls back to tenant default)",setups: map[string]schema.ParserSetup{"audio": {"vlm": map[string]any{"llm_id": ""}}},},diff --git a/internal/parser/parser/audio_parser.go b/internal/parser/parser/audio_parser.goindex fab1c63cf3..8bdf5e0188 100644--- a/internal/parser/parser/audio_parser.go+++ b/internal/parser/parser/audio_parser.go@@ -38,11 +38,8 @@ var audioExtensions = map[string]bool{"vqf": true, "oggvorbis": true, "ape": true,}-// AudioParser handles audio files for transcription. The struct mirrors-// the configuration from setups["audio"]:output_format and-// setups["audio"].vlm.llm_id.+// AudioParser handles audio files for transcription.type AudioParser struct {- VLMModelID string // vlm.llm_id — identifies the speech-to-text modelOutputFormat string}@@ -52,16 +49,11 @@ func NewAudioParser() *AudioParser {}// ConfigureFromSetup reads audio-specific configuration from the-// parser setup map. It extracts vlm.llm_id and output_format.+// parser setup map.func (p *AudioParser) ConfigureFromSetup(setup map[string]any) {if p == nil || setup == nil {return}- if vlm, ok := setup["vlm"].(map[string]any); ok {- if llmID, ok := vlm["llm_id"].(string); ok && llmID != "" {- p.VLMModelID = llmID- }- }if v, ok := setup["output_format"].(string); ok && v != "" {p.OutputFormat = v}@@ -82,7 +74,6 @@ func (p *AudioParser) ParseWithResult(ctx context.Context, filename string, data}}- // OutputFormat and VLMModelID are consumed by maybeDispatchAudio.outFmt := p.OutputFormatif outFmt == "" {outFmt = "text"diff --git a/internal/parser/parser/audio_parser_test.go b/internal/parser/parser/audio_parser_test.goindex 19f9dbdba4..12e03393fe 100644--- a/internal/parser/parser/audio_parser_test.go+++ b/internal/parser/parser/audio_parser_test.go@@ -26,9 +26,6 @@ func TestAudioParser_ValidExtension(t *testing.T) {p := NewAudioParser()p.ConfigureFromSetup(map[string]any{"output_format": "text",- "vlm": map[string]any{- "llm_id": "whisper-1",- },})result := p.ParseWithResult(ctx, "test.mp3", []byte{1, 2, 3, 4})@@ -66,18 +63,6 @@ func TestAudioParser_InvalidExtension(t *testing.T) {}}-func TestAudioParser_ConfigureVLM(t *testing.T) {- p := NewAudioParser()- p.ConfigureFromSetup(map[string]any{- "vlm": map[string]any{- "llm_id": "openai-whisper",- },- })- if p.VLMModelID != "openai-whisper" {- t.Errorf("VLMModelID = %q, want openai-whisper", p.VLMModelID)- }-}-func TestAudioParser_ConfigureNilSafe(t *testing.T) {ctx := t.Context()p := NewAudioParser()diff --git a/internal/parser/parser/picture_parser.go b/internal/parser/parser/picture_parser.goindex 558ea70e6c..9148080038 100644--- a/internal/parser/parser/picture_parser.go+++ b/internal/parser/parser/picture_parser.go@@ -51,17 +51,8 @@ var imageExtensions = map[string]bool{}// PictureParser handles image files for OCR and VLM description.-// Mirrors the configuration from setups["picture"]:-// - VLMModelID ← setup parse_method (non-"ocr"), vlm.llm_id, or top-level llm_id (in order)-// - output_format-// - image_context_size-// - layout_recognize → ("@PaddleOCR:model_name" or empty)type PictureParser struct {- VLMModelID string // per-call IMAGE2TEXT model reference (parse_method / vlm.llm_id / llm_id)- OutputFormat string- ImageContextSize int // default 0- LayoutRecognize string // layout_recognize (e.g. "@PaddleOCR")- VideoPrompt string // for video-in-image detection (Python fallback)+ OutputFormat string}// NewPictureParser constructs a PictureParser.@@ -70,37 +61,14 @@ func NewPictureParser() *PictureParser {}// ConfigureFromSetup reads picture-specific configuration from the-// parser setup map. Extracts the per-call IMAGE2TEXT model reference-// (parse_method non-"ocr" > vlm.llm_id > llm_id), output_format,-// image_context_size, layout_recognize, and video_prompt.+// parser setup map.func (p *PictureParser) ConfigureFromSetup(setup map[string]any) {if p == nil || setup == nil {return}- if pm, ok := setup["parse_method"].(string); ok && pm != "" && !strings.EqualFold(pm, "ocr") {- p.VLMModelID = pm- } else if vlm, ok := setup["vlm"].(map[string]any); ok {- if llmID, ok := vlm["llm_id"].(string); ok && llmID != "" {- p.VLMModelID = llmID- }- }- if p.VLMModelID == "" {- if llmID, ok := setup["llm_id"].(string); ok && llmID != "" {- p.VLMModelID = llmID- }- }if v, ok := setup["output_format"].(string); ok && v != "" {p.OutputFormat = v}- if v, ok := setup["image_context_size"].(float64); ok {- p.ImageContextSize = int(v)- }- if v, ok := setup["layout_recognize"].(string); ok && v != "" {- p.LayoutRecognize = v- }- if v, ok := setup["video_prompt"].(string); ok && v != "" {- p.VideoPrompt = v- }}// ParseWithResult implements ParseResultProducer. It validates the@@ -127,8 +95,6 @@ func (p *PictureParser) ParseWithResult(ctx context.Context, filename string, da}}- // OutputFormat, VLMModelID, ImageContextSize, and LayoutRecognize- // are consumed by maybeDispatchImage at the component layer.// Parser output is normalized to JSON at the component boundary, so an// absent backend format defaults to JSON here as well.outFmt := p.OutputFormatdiff --git a/internal/parser/parser/picture_parser_test.go b/internal/parser/parser/picture_parser_test.goindex b3e3ccdc39..c53360984d 100644--- a/internal/parser/parser/picture_parser_test.go+++ b/internal/parser/parser/picture_parser_test.go@@ -29,40 +29,16 @@ func TestNewPictureParser(t *testing.T) {if p.OutputFormat != "" {t.Errorf("OutputFormat = %q, want empty", p.OutputFormat)}- if p.VLMModelID != "" {- t.Errorf("VLMModelID = %q, want empty", p.VLMModelID)- }- if p.ImageContextSize != 0 {- t.Errorf("ImageContextSize = %d, want 0", p.ImageContextSize)- }}func TestPictureParser_ConfigureFromSetup(t *testing.T) {p := NewPictureParser()p.ConfigureFromSetup(map[string]any{- "vlm": map[string]any{- "llm_id": "gpt-4-vision",- },- "output_format": "text",- "image_context_size": float64(3),- "layout_recognize": "@PaddleOCR",- "video_prompt": "summarize",+ "output_format": "text",})- if p.VLMModelID != "gpt-4-vision" {- t.Errorf("VLMModelID = %q, want gpt-4-vision", p.VLMModelID)- }if p.OutputFormat != "text" {t.Errorf("OutputFormat = %q, want text", p.OutputFormat)}- if p.ImageContextSize != 3 {- t.Errorf("ImageContextSize = %d, want 3", p.ImageContextSize)- }- if p.LayoutRecognize != "@PaddleOCR" {- t.Errorf("LayoutRecognize = %q, want @PaddleOCR", p.LayoutRecognize)- }- if p.VideoPrompt != "summarize" {- t.Errorf("VideoPrompt = %q, want summarize", p.VideoPrompt)- }}func TestPictureParser_ParseWithResult_NilSetup(t *testing.T) {