From 81985ae6e5af3b3c67d3928e4ee026727073bd48 Mon Sep 17 00:00:00 2001 From: Joe Nudell Date: Tue, 12 May 2026 13:55:41 -0400 Subject: [PATCH] Fix AzureDIExtract.load_analyze_result for azure-ai-documentintelligence>=1.0 The 1.0 release of azure-ai-documentintelligence dropped `AnalyzeResult.from_dict`; `AnalyzeResult` now inherits from the new `_model_base.Model` and is constructed directly from the REST payload dict (matching `as_dict()` round-trips). The sibling driver in `bc2/core/ontology/openai.py` already uses `AnalyzeResult(content)`; this extraction driver was missed, so any pipeline that re-reads a cached `application/x-analyze-result` file blew up with: AttributeError: type object 'AnalyzeResult' has no attribute 'from_dict' Co-authored-by: Cursor --- bc2/core/extract/azuredi.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bc2/core/extract/azuredi.py b/bc2/core/extract/azuredi.py index 3e976ef..09a4eb3 100644 --- a/bc2/core/extract/azuredi.py +++ b/bc2/core/extract/azuredi.py @@ -33,8 +33,10 @@ def __init__(self, config: AzureDIExtractConfig): def load_analyze_result(self, file: MemoryFile) -> AnalyzeResult: file.buffer.seek(0) # Parse JSON and inflate the AnalyzeResult object. + # azure-ai-documentintelligence >= 1.0.0 dropped `from_dict` in favour + # of Model-style direct construction from the raw REST payload. content = date_aware_json_load(file.buffer) - return AnalyzeResult.from_dict(content) + return AnalyzeResult(content) def extract(self, analysis: AnalyzeResult) -> Tuple[str, bool]: result = self._extract_text_from_analysis(analysis) or ""