Skip to content

feat: Add API Route as a translation service - #1190

Open
DennyHo0917 wants to merge 1 commit into
PDFMathTranslate:mainfrom
DennyHo0917:feat/add-api-route-translator
Open

DennyHo0917 wants to merge 1 commit into
PDFMathTranslate:mainfrom
DennyHo0917:feat/add-api-route-translator

Conversation

@DennyHo0917

Copy link
Copy Markdown

Summary

This PR adds API Route as a supported translation service for PDFMathTranslate. API Route is a unified AI model gateway providing high-availability access to top LLMs (Claude 3.7 Sonnet, GPT-4o, DeepSeek, etc.) through an OpenAI-compatible API.

Key Changes

  • Translator Implementation: Added ApiRouteTranslator in pdf2zh/translator.py extending OpenAITranslator with default endpoint https://global.api-route.com/v1 and default model claude-3-7-sonnet-20250219.
  • Converter & CLI Registration: Registered ApiRouteTranslator with service name apiroute across pdf2zh/converter.py and pdf2zh/pdf2zh.py.
  • GUI Integration: Added "API Route": ApiRouteTranslator to service_map in pdf2zh/gui.py for visual service selection and dynamic environment configuration.
  • Documentation: Updated the translation services table in docs/ADVANCED.md with required environment variables (APIROUTE_API_KEY, APIROUTE_MODEL) and documentation links.
  • Unit Tests: Added TestApiRouteTranslator in test/test_translator.py covering default configuration, custom model parameters, and environment overrides.

Verification

  • Ran python -m unittest test.test_translator (all 12 tests passed including new TestApiRouteTranslator).
  • Ran black --check on all modified files (passed without format warnings).

This branch has not been deployed

No deployments
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.

1 participant