Files
agent/app/modules/rag/intent_router_v2/test_signals.py

41 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from __future__ import annotations
import re
_NEGATIVE_TEST_RE = re.compile(r"\b(?:не|без|кроме)\b[^.?!]{0,28}\ест", re.IGNORECASE)
_NEGATIVE_TEST_MARKERS = ("не про тест", "без тест", "кроме тест", "про прод код", "только прод", "production code")
_POSITIVE_TEST_MARKERS = (
"тест",
"tests",
"pytest",
"unit test",
"unit tests",
"тестиру",
)
_TEST_TERMS = {"тест", "тесты", "test", "tests", "pytest", "unit", "unit test", "юнит-тест", "юниттест"}
def is_negative_test_request(text: str) -> bool:
lowered = (text or "").lower()
if _NEGATIVE_TEST_RE.search(lowered):
return True
return any(marker in lowered for marker in _NEGATIVE_TEST_MARKERS)
def has_test_focus(text: str) -> bool:
lowered = (text or "").lower()
if is_negative_test_request(lowered):
return False
return any(marker in lowered for marker in _POSITIVE_TEST_MARKERS)
def is_test_related_token(value: str) -> bool:
lowered = (value or "").lower().strip()
if not lowered:
return False
if lowered in _TEST_TERMS:
return True
if lowered.startswith("test"):
return True
return lowered.startswith("тест")