Feat: v0.12 Pipeline Separation, Spacing Fix, and Idempotent Restoration
This commit is contained in:
+26
-4
@@ -102,13 +102,32 @@ async def run_pipeline(args):
|
||||
await translator.translate(manifest_manager.entries, profile)
|
||||
manifest_manager.save()
|
||||
|
||||
await llm_client.close()
|
||||
# Don't close here, wait until after backfill
|
||||
# await llm_client.close()
|
||||
pass
|
||||
else:
|
||||
logger.info("Skipping translation step.")
|
||||
|
||||
# 5. Backfill
|
||||
backfiller = BackfillEngine()
|
||||
updated_structure = backfiller.backfill(structure, manifest_manager.entries, mode=args.mode)
|
||||
# 5. Backfill (now async + LLM repair enabled)
|
||||
# Reuse existing llm_client if available, otherwise create temporary one if needed?
|
||||
# In this flow, llm_client is created inside the 'if not args.skip_translation' block.
|
||||
# If skip_translation is True, llm_client is undefined.
|
||||
|
||||
backfill_llm_client = None
|
||||
should_close_client = False
|
||||
|
||||
if 'llm_client' in locals() and llm_client:
|
||||
backfill_llm_client = llm_client
|
||||
elif api_key and not args.skip_translation:
|
||||
# This case shouldn't happen because if not skip, we key llm_client above.
|
||||
# But if skip_translation is True, we might still want repair?
|
||||
# For now, let's only enable repair if translation occurred or if we explicitly create one.
|
||||
# User said: "LLM features may fail" if no key.
|
||||
pass
|
||||
|
||||
# Initialization
|
||||
backfiller = BackfillEngine(llm_client=backfill_llm_client)
|
||||
updated_structure = await backfiller.backfill(structure, manifest_manager.entries, mode=args.mode)
|
||||
|
||||
# 6. Assembly - Pass original EPUB for TOC preservation
|
||||
builder = BilingualBuilder(work["root"], original_epub_path=input_path)
|
||||
@@ -124,6 +143,9 @@ async def run_pipeline(args):
|
||||
|
||||
logger.info(f"Pipeline completed! Output: {created_epub}")
|
||||
|
||||
if 'llm_client' in locals() and llm_client:
|
||||
await llm_client.close()
|
||||
|
||||
except EpubTranslatorError as e:
|
||||
logger.error(f"An error occurred: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user