feat: Claude enhancements - prompt caching, batch API, and translation improvements#540
Open
seidnerj wants to merge 4 commits intobookfere:masterfrom
Open
feat: Claude enhancements - prompt caching, batch API, and translation improvements#540seidnerj wants to merge 4 commits intobookfere:masterfrom
seidnerj wants to merge 4 commits intobookfere:masterfrom
Conversation
d790ed7 to
7512d58
Compare
070f7ea to
62ad7c5
Compare
…vements - Add prompt caching support with configurable cache control headers - Add batch API support for cost-efficient bulk translations - Add UI controls for extended output and context beta features - Improve streaming text insertion and stop button functionality - Prevent partial translations with dynamic max_tokens and opt-in timeout scaling - Bump version to 2.4.2
When prompt caching is enabled and the full book context is in the system prompt, Claude sometimes refuses to translate content it identifies as copyrighted. This adds: - Anti-refusal language to the base and cached system prompts - Two-stage refusal detection: heuristic pre-filter (pattern matching) followed by LLM classification to avoid false positives - Automatic retry loop (up to 3 attempts) in translate_paragraph - install.sh script for quick local Calibre plugin installation
62ad7c5 to
2b65a60
Compare
Add partial-translation refusal patterns (scope limiting, offering alternatives) and bump refusal_max_retries from 3 to 5.
- Raise TranslationFailed when all refusal retries are exhausted instead of silently saving the refusal text as the translation - Fix cache_enabled defaulting to disabled when config value is None (use `is not False` so None defaults to enabled)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Advanced translation features specifically for the Claude (Anthropic) engine, including cost-saving optimizations and reliability improvements.
Translation Refusal Detection & Retry
translate_paragraphPrompt Caching (90% Cost Reduction)
Batch Translation API (50% Cost Reduction)
Dynamic Token Management
Extended Output/Context (Beta Features)
Dynamic Timeout (Opt-in)
Streaming Improvements
Testing
Version
Bumped to v2.4.2 with comprehensive CHANGELOG