@@ -233,9 +233,7 @@ key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]
233233
234234document_intelligence_client = DocumentIntelligenceClient(endpoint = endpoint, credential = AzureKeyCredential(key))
235235with open (path_to_sample_documents, " rb" ) as f:
236- poller = document_intelligence_client.begin_analyze_document(
237- " prebuilt-layout" , body = f
238- )
236+ poller = document_intelligence_client.begin_analyze_document(" prebuilt-layout" , body = f)
239237result: AnalyzeResult = poller.result()
240238
241239if result.styles and any ([style.is_handwritten for style in result.styles]):
@@ -503,16 +501,16 @@ from azure.ai.documentintelligence import DocumentIntelligenceClient
503501from azure.ai.documentintelligence.models import AnalyzeResult
504502
505503def _format_price (price_dict ):
504+ if price_dict is None :
505+ return " N/A"
506506 return " " .join([f " { p} " for p in price_dict.values()])
507507
508508endpoint = os.environ[" DOCUMENTINTELLIGENCE_ENDPOINT" ]
509509key = os.environ[" DOCUMENTINTELLIGENCE_API_KEY" ]
510510
511511document_intelligence_client = DocumentIntelligenceClient(endpoint = endpoint, credential = AzureKeyCredential(key))
512512with open (path_to_sample_documents, " rb" ) as f:
513- poller = document_intelligence_client.begin_analyze_document(
514- " prebuilt-receipt" , body = f, locale = " en-US"
515- )
513+ poller = document_intelligence_client.begin_analyze_document(" prebuilt-receipt" , body = f, locale = " en-US" )
516514receipts: AnalyzeResult = poller.result()
517515
518516if receipts.documents:
@@ -665,9 +663,7 @@ document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, cre
665663
666664# Make sure your document's type is included in the list of document types the custom model can analyze
667665with open (path_to_sample_documents, " rb" ) as f:
668- poller = document_intelligence_client.begin_analyze_document(
669- model_id = model_id, body = f
670- )
666+ poller = document_intelligence_client.begin_analyze_document(model_id = model_id, body = f)
671667result: AnalyzeResult = poller.result()
672668
673669if result.documents:
@@ -921,7 +917,7 @@ def callback(response):
921917
922918client.get_resource_details(raw_response_hook = callback)
923919
924- print (f " Response status code is: { responses[" status_code" ]} " )
920+ print (f " Response status code is: { responses[' status_code' ]} " )
925921response_body = responses[" response_body" ]
926922print (
927923 f " Our resource has { response_body[' customDocumentModels' ][' count' ]} custom models, "
0 commit comments