Skip to content

Validate and recover structured captions - #76

Merged
bghira merged 1 commit into
mainfrom
feat/openai-structured-output
Sep 8, 2026
Merged

bghira merged 1 commit into
mainfrom
feat/openai-structured-output

Conversation

@bghira

@bghira bghira commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Add structured JSON validation and semantic recovery to the OpenAI-compatible worker, based on the behavior exercised by the Ideogram-style captioning run.

  • optionally reject malformed JSON, including non-standard NaN and Infinity
  • conservatively repair invalid JSON escape sequences
  • canonicalize JSON, correct inverted [ymin, xmin, ymax, xmax] boxes, and remove exact duplicate elements
  • treat invalid structured output as retryable caption failure
  • support retry-specific standard sampling through shared stage configuration
  • support worker-local retry_extra_body for provider-specific recovery schemas
  • validate structured-output and retry configuration eagerly
  • document the complete primary and recovery setup without deployment-specific paths

The JSON validator checks syntax, while provider response_format remains responsible for schema-constrained decoding. Bounding-box normalization only corrects coordinate ordering; it does not infer or score boxes.

Validation:

  • 499 tests passed
  • 100% changed-line coverage (131/131 lines)
  • Black formatting check passed
  • targeted Ruff correctness checks passed
  • all documented YAML examples parse successfully

@bghira
bghira force-pushed the feat/openai-structured-output branch from 17fb974 to 117b196 Compare September 8, 2026 20:24
@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/caption_flow/models.py 96.15% <100.00%> (+0.02%) ⬆️
src/caption_flow/utils/vllm_config.py 93.33% <ø> (ø)
src/caption_flow/workers/caption.py 63.85% <100.00%> (+0.32%) ⬆️
src/caption_flow/workers/openai_compatible.py 92.37% <100.00%> (+1.50%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bghira
bghira merged commit 562ac0c into main Sep 8, 2026
4 checks passed
@bghira
bghira deleted the feat/openai-structured-output branch September 8, 2026 21:08
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.

1 participant