Skip to content

Add picture description support for document processing - #323

Open
gshikhar2021 wants to merge 1 commit into
redhat-data-and-ai:mainfrom
gshikhar2021:image-description
Open

Add picture description support for document processing#323
gshikhar2021 wants to merge 1 commit into
redhat-data-and-ai:mainfrom
gshikhar2021:image-description

Conversation

@gshikhar2021

Copy link
Copy Markdown
Contributor

Enable Gemini as a vision language model in the document processor to generate descriptions of images found in PDFs. The API key is read from the operator secret and injected at runtime

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 69cfbeca-3e30-47bd-9133-e7837fc5d07d

📥 Commits

Reviewing files that changed from the base of the PR and between 83f3163 and 45b6ec1.

📒 Files selected for processing (1)
  • config/samples/operator_v1alpha1_unstructureddatapipeline_gdrive.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/samples/operator_v1alpha1_unstructureddatapipeline_gdrive.yaml

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added optional picture-description API configuration for document processing, including model, prompt, URL, token limits, headers, timeout, and concurrency.
    • Added secure support for supplying the vision-language model API key.
    • Extended deployment schemas to support picture-description settings across document-processing workflows.
  • Configuration

    • Updated samples to enable Markdown output, image inclusion, placeholders, picture descriptions, and classification.
    • Increased the client request timeout for longer-running API requests.
    • Added a sample secret entry for the vision-language model API key.

Walkthrough

The change adds picture-description API configuration to public types and CRD schemas. The controller reads VLM_API_KEY, converts the configuration, and adds authorization headers. The Docling client supports the configuration and uses a 60-second HTTP timeout.

Changes

Picture description API

Layer / File(s) Summary
API contracts and CRD schemas
api/v1alpha1/documentprocessor_types.go, api/v1alpha1/zz_generated.deepcopy.go, config/crd/bases/*
Public picture-description API types and deep-copy methods were added. The CRD schemas define required URL and model fields plus optional request settings.
Secret loading and controller conversion
config/samples/unstructured-secret.yaml, internal/controller/controllerconfig_controller.go, internal/controller/documentprocessor_controller.go
The controller reads VLM_API_KEY, converts picture-description settings, parses timeouts, and adds a Bearer authorization header.
Docling client and configuration samples
pkg/docling/client.go, config/samples/operator_v1alpha1_unstructureddatapipeline_gdrive.yaml
The Docling client accepts picture-description settings and uses a 60-second HTTP timeout. The sample configuration enables picture description and provides API settings.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant OperatorSecret
  participant ControllerReconciliation
  participant DoclingClient
  participant PictureDescriptionAPI

  OperatorSecret->>ControllerReconciliation: Provide VLM_API_KEY
  ControllerReconciliation->>ControllerReconciliation: Convert picture-description settings
  ControllerReconciliation->>DoclingClient: Pass URL, params, prompt, timeout, concurrency, headers
  DoclingClient->>PictureDescriptionAPI: Use configured API endpoint
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding picture description support for document processing.
Description check ✅ Passed The description accurately explains Gemini vision-language support and runtime API key injection.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/controller/controllerconfig_controller.go`:
- Around line 143-145: Replace the process-global VLM API key assignment in
internal/controller/controllerconfig_controller.go lines 143-145 with a
synchronized, namespace-scoped configuration snapshot keyed by req.Namespace.
Update internal/controller/documentprocessor_controller.go lines 126-130 to
retrieve only the credential associated with the reconciled resource namespace,
preserving synchronization for concurrent reconciliation access.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 08e4b646-763a-4470-82cb-ed464990342c

📥 Commits

Reviewing files that changed from the base of the PR and between 5a86b26 and 83f3163.

📒 Files selected for processing (10)
  • api/v1alpha1/documentprocessor_types.go
  • api/v1alpha1/zz_generated.deepcopy.go
  • config/crd/bases/operator.dataverse.redhat.com_documentprocessors.yaml
  • config/crd/bases/operator.dataverse.redhat.com_unstructureddatapipelines.yaml
  • config/samples/operator_v1alpha1_unstructureddatapipeline_gdrive.yaml
  • config/samples/unstructured-secret.yaml
  • internal/controller/controllerconfig_controller.go
  • internal/controller/documentprocessor_controller.go
  • pkg/docling/client.go
  • pkg/docling/zz_generated.deepcopy.go
💤 Files with no reviewable changes (1)
  • pkg/docling/zz_generated.deepcopy.go

Comment on lines +143 to +145
// VLM API key for picture description
vlmAPIKey = string(secret.Data["VLM_API_KEY"])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | 🏗️ Heavy lift

Keep VLM_API_KEY namespace-scoped and synchronized.

VLM_API_KEY comes from a Secret in req.Namespace, but Line 144 stores it in a process-global variable. A reconciliation in namespace B can overwrite the key before a DocumentProcessor reconciliation in namespace A reads it. The processor can then use namespace B's credential. Concurrent reads and writes also cause a Go data race.

Replace the global with a namespace-scoped, synchronized configuration snapshot, or resolve the applicable Secret during DocumentProcessor reconciliation.

  • internal/controller/controllerconfig_controller.go#L143-L145: store the key with its namespace instead of assigning a process-global value.
  • internal/controller/documentprocessor_controller.go#L126-L130: retrieve only the key for the reconciled resource namespace.

As per path instructions, focus on major issues impacting performance, readability, maintainability and security.

📍 Affects 2 files
  • internal/controller/controllerconfig_controller.go#L143-L145 (this comment)
  • internal/controller/documentprocessor_controller.go#L126-L130
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/controller/controllerconfig_controller.go` around lines 143 - 145,
Replace the process-global VLM API key assignment in
internal/controller/controllerconfig_controller.go lines 143-145 with a
synchronized, namespace-scoped configuration snapshot keyed by req.Namespace.
Update internal/controller/documentprocessor_controller.go lines 126-130 to
retrieve only the credential associated with the reconciled resource namespace,
preserving synchronization for concurrent reconciliation access.

Source: Path instructions

Enable Gemini as a vision language model in the document processor
to generate descriptions of images found in PDFs. The API key is
read from the operator secret and injected at runtime
Comment thread pkg/docling/client.go
logger := log.FromContext(ctx)
client := &http.Client{
Timeout: 15 * time.Second,
Timeout: 60 * time.Second,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason why are we changing this ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also if this is needed then we should take this value from controllerconfig so that same can be fine tuned

Prompt string `json:"prompt,omitempty"`
Timeout string `json:"timeout,omitempty"`
Concurrency int `json:"concurrency,omitempty"`
Headers map[string]string `json:"headers,omitempty"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what kind of headers needs to be passed here?

}

type PictureDescriptionAPI struct {
URL string `json:"url"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this going to be constant for each pipeline? If so, can we move this to controllerconfig?

Comment on lines +42 to +48
Extract all visible content from this image: text
(exact wording, spelling, numbers, dates, percentages),
table data (preserve rows, columns, headers, values),
chart/graph data (axis labels, data points, legends, trends),
diagrams (labels, connections, flow direction),
and any logos or watermarks.
Reproduce numbers and figures exactly as shown.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more detailed prompt needed

@concaf
concaf requested a review from vinamra28 August 19, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants