Commit graph

3 commits

Author SHA1 Message Date
andikarachman
69c25b43d7 refactor: address code review feedback
- Made is_available() abstract in base.py with proper implementation in providers
- Added original_error parameter to UnsupportedLanguageError and TranslationConfigError
- Added Field validation for confidence_threshold bounds (0.0-1.0)
- Changed @lru_cache to @lru_cache() for explicit style
- Added get_translation_provider to __all__ in providers/__init__.py
- Replaced deprecated asyncio.get_event_loop() with get_running_loop()
- Added debug logging to is_available() in GoogleTranslationProvider
- Added TODO comment for confidence score improvement in OpenAIProvider
- Added None check for read_query_prompt() with fallback default prompt
- Moved ClientSession outside batch loop in AzureTranslationProvider
- Fixed Optional[float] type annotation in detect_language()
- Added Note section documenting in-place mutation in translate_content()
- Added test_confidence_threshold_validation() for bounds testing
- Added descriptive assertion messages to config tests
- Converted all async tests to use @pytest.mark.asyncio decorators
- Replaced manual skip checks with @pytest.mark.skipif
- Removed manual main() blocks, tests now pytest-only
- Changed Chinese language assertion to use startswith('zh') for flexibility
2026-01-04 12:06:50 +07:00
andikarachman
05d34c9915 test: add comprehensive translation module tests
- Add unit tests for translation configuration, language detection, providers, and translate_content task
- Add integration tests for full cognify pipeline with translation
- All 40 tests passing (32 unit + 8 integration)
- Tests use asyncio.run() pattern matching project style
- Tests named with *_test.py suffix per project convention
- Update README with test documentation

Formatting changes:
- Apply ruff format to cognify.py (bracket placement style)

Signed-off-by: andikarachman <andika.rachman.y@gmail.com>
2026-01-04 12:06:50 +07:00
andikarachman
8a794ea85d feat(translation): implement multilingual content translation task
- Add translation module with OpenAI, Google, Azure provider support
- Implement language detection using langdetect
- Add TranslatedContent and LanguageMetadata models
- Integrate translation task into cognify pipeline
- Add auto_translate parameter to cognify() function
- Preserve original text alongside translations
- Support custom translation providers and target languages
2026-01-04 12:06:50 +07:00