fix(review): _enum_fields validation, gate classify_from_text flags, OCR warnings
Address PR #858 review round 3: - document_tier1_engine / document_ocr_provider now validate + normalize via Settings.__post_init__ _enum_fields (the repo's canonical opt-in-enum pattern; case-insensitive) instead of dynaconf Validators. A typo now raises ValueError at load and "Gateway" normalizes to "gateway". - classify_from_text gates no_text_layer/bad_text_layer on ocr_frac >= OCR_PAGE_FRACTION, matching classify_pdf -- a "fast"-routed doc with a few junk pages no longer emits a misleading flag (keeps the shadow vs hot-path classification metrics consistent). - build_ocr_backend warns when an EXPLICIT provider is misconfigured (gateway without EMBEDDING_GATEWAY_URL, mistral without MISTRAL_API_KEY) instead of silently returning None. - Pypdfium2FastProcessor.health_check probes the import; documented why OcrProcessor.health_check is unconditionally True (lazy per-tenant backends). - Removed the leftover per-boundary / per-chunk debug logging loops. Tests: enum normalization + rejection for the two new settings. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
f1272dfe84
commit
bc957b5bc7
@@ -29,9 +29,13 @@ class TestDecompositionDefaults:
|
||||
s = Settings(
|
||||
collection_metadata_source=" QDRANT ",
|
||||
mcp_role=" API ",
|
||||
document_tier1_engine=" PyPDFium2 ",
|
||||
document_ocr_provider=" Gateway ",
|
||||
)
|
||||
assert s.collection_metadata_source == "qdrant"
|
||||
assert s.mcp_role == "api"
|
||||
assert s.document_tier1_engine == "pypdfium2"
|
||||
assert s.document_ocr_provider == "gateway"
|
||||
|
||||
|
||||
class TestEnumValidation:
|
||||
@@ -41,6 +45,8 @@ class TestEnumValidation:
|
||||
("embedding_provider", "openai"),
|
||||
("mcp_role", "leader"),
|
||||
("collection_metadata_source", "redis"),
|
||||
("document_tier1_engine", "mupdf"),
|
||||
("document_ocr_provider", "gatway"),
|
||||
],
|
||||
)
|
||||
def test_invalid_enum_rejected(self, field, value):
|
||||
|
||||
Reference in New Issue
Block a user