Skip to content

fix: generate structured IDML translations in one request - #1163

Open
TimRl wants to merge 1 commit into
mainfrom
slow-LLM-requests-IDML
Open

fix: generate structured IDML translations in one request#1163
TimRl wants to merge 1 commit into
mainfrom
slow-LLM-requests-IDML

Conversation

@TimRl

@TimRl TimRl commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

fix: generate structured IDML translations in one request

Summary

Addresses an identified cause of slow Sparkle generation in multi-segment IDML cells: plain-text translations could not preserve the imported structure, triggering an additional LLM request to repair the HTML.

Eligible cells now request indexed JSON translations and reconstruct the original HTML locally, avoiding the repair request on successful structured responses.

Related to #1160. Broader project-wide performance verification remains pending.

Changes

  • Extract source text segments and their data-segment-index values.
  • Request schema-constrained JSON translations through response_format.
  • Validate segment counts, indexes, duplicates, and translation types before reconstruction.
  • Reinsert escaped translations while preserving original tags, attributes, styles, and separators.
  • Retain the legacy fallback for unsupported providers or invalid responses; cancellation does not trigger a retry.
  • Limit the new path to supported multi-segment IDML cells with HTML structure enforcement enabled. Other formats, single-segment cells, and merged/range cells retain existing behavior.
  • Add regression coverage for reconstruction, validation, fallback, cancellation, and compatibility.

Test Checklist

Automated verification

  • Extension build passes.
  • ESLint passes.
  • Full extension test suite passes: 1,530 passing, 10 pending.
  • Valid structured output completes with one LLM request.
  • Reconstruction preserves markup and correctly maps out-of-order segment responses.
  • Invalid responses are rejected and the legacy fallback remains functional.
  • Cancellation does not start a fallback request.
  • Single-segment cells and disabled structure enforcement retain the legacy path.

Performance and acceptance verification

  • Reviewed the supplied IDML recording: translation appears after approximately 13–14 seconds, without the additional HTML-repair stage.
  • Verify generation speed in NEW ACT–REV.
  • Verify representative front/back matter and Bible Dictionary cells.
  • Confirm whether recent migration edits contributed to the reported slowdown.
  • Confirm normal generation speed with the partner and Patrice.

@TimRl TimRl self-assigned this Sep 3, 2026
@TimRl

TimRl commented Sep 8, 2026

Copy link
Copy Markdown
Contributor Author

/build

@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

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