qfa.services.language#
Source-language detection for prompt assembly.
Wraps langdetect directly so the services layer can pin an LLM’s output
language to the language a feedback record was written in. Deliberately
separate from qfa.adapters.presidio_anonymizer.detect_language(), which
answers a different question (which of Presidio’s six spaCy models to load)
and would be an adapters import from the services layer besides.
Functions
|
Detect the language |
- qfa.services.language.detect_source_language(text: str) str | None[source]#
Detect the language
textis written in.Returns a raw ISO 639-1 code (
"en","fr"), orNonewhen the text is too short, too noisy, or too ambiguous to detect reliably — callers are expected to skip pinning a language in that case rather than trust a guess. Never raises. Only the first 2000 characters are inspected.