Azure AI Document Intelligence client library for Python - a cloud service that uses machine learning to analyze text and structured data from documents
76
Build a helper that submits a single document to a document analysis service using a specified model and returns a concise summary of the extracted content and fields.
CustomerName and TotalAmount when the model provides them. @test"1-1") and a locale code, analysis is limited to those pages and the locale hint is forwarded so language-aware extraction is used. @testquery_fields is provided, only the requested field keys are returned, with missing values represented as None. @testoutput_format is "markdown", the returned summary includes markdown content; when "text", it includes plain text; other values raise a ValueError. @test@generates
from typing import Iterable, Optional, Dict, Any
def analyze_document(
file_path: str,
*,
model_id: str,
pages: Optional[str] = None,
locale: Optional[str] = None,
query_fields: Optional[Iterable[str]] = None,
output_format: str = "text"
) -> Dict[str, Any]:
"""
Analyze a single document and return extracted content and fields.
Returns a dictionary with:
- "content": the document text in the requested format
- "fields": a mapping from requested field names to extracted strings or None
"""Provides the document analysis client used to submit single-document requests.
Install with Tessl CLI
npx tessl i tessl/pypi-azure-ai-documentintelligencedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10