Skip to content

fix(analyzer): honour config_path for LangExtract recognizers in YAML registry#2157

Merged
RonShakutai merged 6 commits into
mainfrom
ronshakutai-fix-llm-recognizer-custom-yaml-config
Jul 13, 2026
Merged

fix(analyzer): honour config_path for LangExtract recognizers in YAML registry#2157
RonShakutai merged 6 commits into
mainfrom
ronshakutai-fix-llm-recognizer-custom-yaml-config

Conversation

@RonShakutai

Copy link
Copy Markdown
Contributor

♻️ Re-opened equivalent of #2153. That PR was merged into ronshaktuai/fix-langextract-params and then the merge was reverted (the branch was reset to drop the squashed commit), so this PR restores the same config_path change for review/merge. Same head branch, same diff.

Change Description

LM recognizers (BasicLangExtractRecognizer, AzureOpenAILangExtractRecognizer) configured via a recognizer-registry YAML now honour config_path.

Bug: these class names were missing from CONFIG_MODEL_MAP, so their YAML entry was validated by the strict PredefinedRecognizerConfig (no config_path field, no extra="allow"). Pydantic silently dropped config_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" + explicit config_path) mirroring the existing HuggingFace/GLiNER configs, and register both class names in CONFIG_MODEL_MAP. Now config_path survives 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).

Stacked on ronshaktuai/fix-langextract-params (#2150) — this PR targets that branch so it shows only the config_path commit.

Issue reference

N/A

Checklist

  • I have reviewed the contribution guidelines
  • I agree to follow this project's Code of Conduct
  • I confirm that I have the right to submit this contribution and that it does not knowingly contain proprietary or confidential code.
  • My code includes unit tests
  • All unit tests and lint checks pass locally
  • My PR contains documentation updates / additions if required

RonShakutai and others added 2 commits July 9, 2026 16:03
…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>
@RonShakutai RonShakutai requested a review from omri374 July 12, 2026 20:05
@RonShakutai

Copy link
Copy Markdown
Contributor Author

@SharonHart dont merge this PR please

Base automatically changed from ronshaktuai/fix-langextract-params to main July 13, 2026 06:59
…ecognizer-custom-yaml-config

# Conflicts:
#	CHANGELOG.md
Copilot AI review requested due to automatic review settings July 13, 2026 07:15
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (presidio-anonymizer)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  presidio-anonymizer/presidio_anonymizer
  anonymizer_engine.py
  presidio-anonymizer/presidio_anonymizer/operators
  custom.py
Project Total  

This report was generated by python-coverage-comment-action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (presidio-structured)

This PR does not seem to contain any modification to coverable code.

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (presidio-cli)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  presidio-cli/presidio_cli
  cli.py
Project Total  

This report was generated by python-coverage-comment-action

@github-actions

Copy link
Copy Markdown
Contributor

Coverage report (presidio-image-redactor)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  presidio-image-redactor/presidio_image_redactor
  dicom_image_pii_verify_engine.py
  document_intelligence_ocr.py
  image_analyzer_engine.py
Project Total  

This report was generated by python-coverage-comment-action

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LangExtractRecognizerConfig and mapped BasicLangExtractRecognizer / AzureOpenAILangExtractRecognizer in CONFIG_MODEL_MAP so config_path survives validation.
  • Added regression tests covering config-model selection and config_path preservation 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.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Coverage report (presidio-analyzer)

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  presidio-analyzer/presidio_analyzer
  analyzer_engine.py
  entity_recognizer.py
  presidio-analyzer/presidio_analyzer/input_validation
  schemas.py
  yaml_recognizer_models.py
  presidio-analyzer/presidio_analyzer/nlp_engine
  __init__.py
  nlp_engine_provider.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers
  __init__.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific
  __init__.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/australia
  au_abn_recognizer.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/finland
  fi_personal_identity_code_recognizer.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/germany
  de_bsnr_recognizer.py
  de_id_card_recognizer.py
  de_lanr_recognizer.py
  de_passport_recognizer.py
  de_social_security_recognizer.py
  de_tax_id_recognizer.py
  de_vat_id_recognizer.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/india
  in_vehicle_registration_recognizer.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/poland
  pl_pesel_recognizer.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/singapore
  sg_uen_recognizer.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/country_specific/us
  us_ssn_recognizer.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/generic
  phone_recognizer.py
  presidio-analyzer/presidio_analyzer/predefined_recognizers/third_party
  basic_langextract_recognizer.py
  presidio-analyzer/presidio_analyzer/recognizer_registry
  recognizer_registry.py
  recognizers_loader_utils.py
Project Total  

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

Copilot AI review requested due to automatic review settings July 13, 2026 07:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 13, 2026 09:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Copilot AI review requested due to automatic review settings July 13, 2026 09:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@RonShakutai RonShakutai merged commit b2680be into main Jul 13, 2026
39 checks passed
@RonShakutai RonShakutai deleted the ronshakutai-fix-llm-recognizer-custom-yaml-config branch July 13, 2026 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants