feat(translate): language detection, async HTTP LLM, history model, agent improvements
- Add async HTTP-based LLM transport (_llm_async_http.py) - Add orthogonal LLM call tests - Improve language detection (_lang_detect.py) and batch insert - Update translate schemas, service utils, preview constants/prompts - Add TranslateHistoryModel with pagination and filtering - Update agent confirmation, persistence, langgraph setup, run, tools - Improve LLM health checking in shared module - Update translate runs API, history route
This commit is contained in:
@@ -17,6 +17,7 @@ from src.plugins.translate._lang_detect import (
|
||||
get_detector,
|
||||
detect_language,
|
||||
_character_block_fallback,
|
||||
_mark_suspicious_detections_und,
|
||||
batch_detect,
|
||||
)
|
||||
|
||||
@@ -184,6 +185,39 @@ class TestCharacterBlockFallback:
|
||||
assert results[0] == "und"
|
||||
|
||||
|
||||
class TestSuspiciousDetections:
|
||||
"""Suspicious short Cyrillic detections are routed to LLM as und."""
|
||||
|
||||
def test_short_cyrillic_uk_for_ru_target_becomes_und(self):
|
||||
results = _mark_suspicious_detections_und(
|
||||
["Оплачено 22.06"],
|
||||
["uk"],
|
||||
["ru"],
|
||||
)
|
||||
assert results == ["und"]
|
||||
|
||||
def test_short_cyrillic_it_for_ru_target_becomes_und(self):
|
||||
results = _mark_suspicious_detections_und(
|
||||
["Нет"],
|
||||
["it"],
|
||||
["ru"],
|
||||
)
|
||||
assert results == ["und"]
|
||||
|
||||
def test_long_mixed_text_keeps_detection(self):
|
||||
text = "Contract with KZ Trading for Financing in China Необходимо подтверждение депозита"
|
||||
results = _mark_suspicious_detections_und([text], ["en"], ["ru"])
|
||||
assert results == ["en"]
|
||||
|
||||
def test_non_ru_target_keeps_detection(self):
|
||||
results = _mark_suspicious_detections_und(
|
||||
["Оплачено 22.06"],
|
||||
["uk"],
|
||||
["en"],
|
||||
)
|
||||
assert results == ["uk"]
|
||||
|
||||
|
||||
class TestBatchDetect:
|
||||
"""batch_detect."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user