$ show yihong0618/bilingual_book_maker
This repository is a CLI tool for translating books (EPUB, TXT, PDF, SRT, Markdown) into bilingual versions (original + translation side-by-side) using large language models (OpenAI, Anthropic, Gemini, etc.) and free machine translation engines. It supports multiple translation backends, a provider configuration system, and a PDF-to-EPUB pipeline using docling for PDF extraction and Pandoc for EPUB export. The architecture is modular: loaders parse input formats, translators handle API calls with session context and capability probing, and a pipeline orchestrates PDF-to-EPUB conversion with figure rendering and classification. Key entry points are `make_book.py` and the installed command `bbook_maker`. The tool includes features like plan mode for selective translation, glossary support, resume, progress bars, and Docker support. It has extensive tests covering CLI contract, loaders, translators, pipeline stages, and documentation. External dependencies include LLM APIs, docling, pypdfium2, Pandoc, and various SDKs. The codebase demonstrates careful engineering decisions around capability degradation, session compaction, glossary learning, and structured output ladder. It is a well-maintained application with active development and low technical drift.
The LLM identified 4 files worth highlighting for reuse:
CapabilityLedger caches per-model probes for JSON Schema support, vision, temperature rejection, and compact cap field negotiation. It normalizes verdicts, demotes after a streak, dedupes concurrent probes, and carries extra_body. This pattern is reusable for any LLM-based tool that needs to degrade gracefully across endpoints.
SessionHistory manages append-only message lists for context, with compact budget, handoff reports, and seed truncation. It includes token estimation (CJK vs Latin characters per token) and budget decisions. This is reusable for any conversational AI application with context windows.
RungRejected, extract_json_object, unwrap_schema_echo implement a ladder from strict schema to prompt-only with RungRejected semantics. This is reusable for any LLM-based tool that needs to degrade gracefully across endpoints.
Redaction module scrubs credentials from errors, output, and identity hashes. This is reusable for any application that prints errors with credentials.