Skip to content

feat(enricher): fall back to translation when enrichment fails#84

Merged
Thysrael merged 1 commit into
Thysrael:mainfrom
cjtree04:feat/translation-fallback
Jun 2, 2026
Merged

feat(enricher): fall back to translation when enrichment fails#84
Thysrael merged 1 commit into
Thysrael:mainfrom
cjtree04:feat/translation-fallback

Conversation

@cjtree04
Copy link
Copy Markdown
Contributor

@cjtree04 cjtree04 commented Jun 1, 2026

What

When content enrichment fails — either the AI call raises, or the JSON response can't be parsed — the item was previously dropped or left untranslated. This adds a lightweight translation fallback: _translate_item() translates the title and summary to Simplified Chinese so the item still appears in the digest with a usable headline.

Why

On a flaky API response or occasional malformed JSON, losing the item entirely (or showing untranslated English in a Chinese digest) is worse than a best-effort translation.

Changes

  • src/ai/enricher.py: add _translate_item(), and call it from the two existing failure paths (the except in enrich_batch, and the None parse result in _enrich_item).

Notes

  • No new dependencies.
  • The fallback is best-effort and swallows its own errors, so it can never make an enrichment failure worse.

When AI enrichment raises or the JSON response can't be parsed, items were
either dropped or left untranslated. Add a lightweight _translate_item
fallback that translates the title and summary to Chinese so the item still
appears in the digest. No new dependencies.
@Thysrael Thysrael merged commit 430a445 into Thysrael:main Jun 2, 2026
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.

2 participants