Skip to content

[codex] Add Gemini batch artifacts and deferred translation#1131

Open
nozuru wants to merge 9 commits into
PDFMathTranslate:mainfrom
nozuru:codex/gemini-batch-artifact-output
Open

[codex] Add Gemini batch artifacts and deferred translation#1131
nozuru wants to merge 9 commits into
PDFMathTranslate:mainfrom
nozuru:codex/gemini-batch-artifact-output

Conversation

@nozuru

@nozuru nozuru commented May 1, 2026

Copy link
Copy Markdown

Summary

  • add Gemini Batch API support and structured JSON artifact output
  • make dual PDF output side-by-side by default and improve output path handling
  • collect page-level source data, manifest paths, and translation-file support
  • set Gemini thinking level through the top-level reasoning_effort parameter
  • fix batch converter default font state and apply Black formatting

Impact

This lets PDF translation produce reusable intermediate artifacts and use deferred page processing across translators, including Gemini batch workflows. It also makes output handling safer and keeps generated manifests portable with relative paths.

Validation

  • uv run pytest .
  • uv run black --check .

- Add GeminiBatchTranslator for 50% cost reduction via async batch processing
- Add batch mode to TranslateConverter: defer translation/typesetting, flush all at once
- Output intermediate data (source text, translation, layout) as JSON
- Add google-genai dependency
- Default batch model: gemini-3-flash-preview
…file support

- Split extracted_data_path into source_data_path + translated_data_path for separate source.json / translated.json output
- Add --translation-file (-tf) option to reuse translations from external JSON
- Extract _collect_source_page_data() to run immediately after Phase A
- Merge redundant translation_map/translations into single translations dict
- Remove dead extracted_data_path parameter
- Reorganize output into artifacts/{doc_id}/json/{run_id}/ and artifacts/{doc_id}/pdf/
- Generate per-page JSON artifacts (pages/0001.json) and manifest.json per run
- Support pages/ directory input for -tf (translation file) option
- Use atomic writes for all file output to prevent partial files
- Adapt GUI and MCP server to new output file paths and naming
- Write source-only page JSON to artifacts/{doc_id}/source/pages/ (write-once)
- Source pages contain paragraphs and formulas without translations
- Fix manifest relative paths from ../pdf/ to ../../pdf/ (correct from json/{run_name}/)
- Add source_pages_dir reference in manifest artifacts
…nslators

- Add thinking_level: low to GeminiTranslator (OpenAI-compatible), GeminiBatchTranslator single and batch requests for better cost/latency balance
- Enable batch_mode (deferred Phase B+C) for all translators, not just those with translate_batch
- Fall back to ThreadPoolExecutor parallel translation for translators without batch API support
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