Performance optimization: batch translation for 5-10x speed improvement
- GoogleTranslationProvider: Added batch translation with separator method - DeepLTranslationProvider: Added translator caching and batch support - LibreTranslationProvider: Added translator caching and batch support - WordTranslator: Collect all texts -> batch translate -> apply pattern - ExcelTranslator: Collect all texts -> batch translate -> apply pattern - PowerPointTranslator: Collect all texts -> batch translate -> apply pattern - Enhanced Ollama/OpenAI prompts with stricter translation-only rules - Added rule: return original text if uncertain about translation
This commit is contained in:
3
main.py
3
main.py
@@ -319,6 +319,9 @@ async def translate_document(
|
||||
if validation_result.warnings:
|
||||
logger.warning(f"[{request_id}] File validation warnings: {validation_result.warnings}")
|
||||
|
||||
# Reset file position after validation read
|
||||
await file.seek(0)
|
||||
|
||||
# Check rate limit for translations
|
||||
client_ip = request.client.host if request.client else "unknown"
|
||||
if not await rate_limit_manager.check_translation_limit(client_ip):
|
||||
|
||||
Reference in New Issue
Block a user