fix(analyzer): honour config_path for LangExtract recognizers in YAML registry#2157
Conversation
…izer Fixes #1942. Merge language_model_params into provider_kwargs so timeout, num_ctx and other LLM provider params configured in YAML actually reach the provider (e.g. Ollama) instead of being silently dropped. Also fixes TypeError when kwargs: or language_model_params: is null in YAML. - Merge language_model_params into provider_kwargs via setdefault (so explicit kwargs: entries still win for backwards compatibility) - Guard against null YAML values with 'or {}' - Strengthen regression tests to assert params reach ModelConfig.provider_kwargs - Add test for kwargs: null edge case - Document fix in CHANGELOG Related: #1943 (lsternlicht/fix-basic-langextract-language-model-params-dropped)
… registry LM recognizers (BasicLangExtractRecognizer, AzureOpenAILangExtractRecognizer) configured via a recognizer registry YAML silently ignored config_path: the strict PredefinedRecognizerConfig schema has no config_path field and forbids extras, so Pydantic dropped it and the recognizer fell back to its bundled default model configuration. Add a LangExtractRecognizerConfig model (extra=allow, explicit config_path field) mirroring the existing HuggingFace/GLiNER configs, and register both LM recognizer class names in CONFIG_MODEL_MAP so config_path (and other recognizer-specific kwargs) survive validation and reach the constructor. Adds regression tests covering config_path preservation via both the model and the full ConfigurationValidator registry path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
@SharonHart dont merge this PR please |
…ecognizer-custom-yaml-config # Conflicts: # CHANGELOG.md
Coverage report (presidio-anonymizer)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
Coverage report (presidio-cli)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
Coverage report (presidio-image-redactor)Click to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Pull request overview
This PR fixes YAML-based recognizer registry validation so LangExtract-based language model recognizers preserve config_path (and other relevant constructor kwargs) instead of silently dropping them during Pydantic validation, ensuring the configured LangExtract model YAML is actually used at runtime.
Changes:
- Added
LangExtractRecognizerConfigand mappedBasicLangExtractRecognizer/AzureOpenAILangExtractRecognizerinCONFIG_MODEL_MAPsoconfig_pathsurvives validation. - Added regression tests covering config-model selection and
config_pathpreservation through full registry validation. - Documented the fix in the Analyzer “Fixed” section of the changelog.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| presidio-analyzer/presidio_analyzer/input_validation/yaml_recognizer_models.py | Introduces LangExtractRecognizerConfig and registers LangExtract recognizer class names in CONFIG_MODEL_MAP. |
| presidio-analyzer/tests/test_yaml_recognizer_models.py | Adds regression tests ensuring config_path is preserved and the correct config model is selected. |
| CHANGELOG.md | Records the behavior fix for LangExtract recognizers configured via YAML registry. |
Coverage report (presidio-analyzer)Click to see where and how coverage changed
The report is truncated to 25 files out of 70. To see the full report, please visit the workflow summary page. This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Change Description
LM recognizers (
BasicLangExtractRecognizer,AzureOpenAILangExtractRecognizer) configured via a recognizer-registry YAML now honourconfig_path.Bug: these class names were missing from
CONFIG_MODEL_MAP, so their YAML entry was validated by the strictPredefinedRecognizerConfig(noconfig_pathfield, noextra="allow"). Pydantic silently droppedconfig_path, and the recognizer fell back to its bundled default model (qwen2.5:1.5b) instead of the configured one.Fix: add a
LangExtractRecognizerConfig(extra="allow"+ explicitconfig_path) mirroring the existing HuggingFace/GLiNER configs, and register both class names inCONFIG_MODEL_MAP. Nowconfig_pathsurvives validation and reaches the constructor.Adds 3 regression tests. Verified end-to-end: an Ollama recognizer now builds with the configured model (e.g.
llama3.2:3b).Issue reference
N/A
Checklist