Skip to content

Commit

Permalink
[DI] Add SDK versions and API versions relationship in README.md (#33351
Browse files Browse the repository at this point in the history
)
  • Loading branch information
YalinLi0312 authored Dec 5, 2023
1 parent 59ca764 commit 2bcc83c
Show file tree
Hide file tree
Showing 45 changed files with 291 additions and 247 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ This is the first preview of the `azure-ai-documentintelligence` package, target
- Changed some currency-related fields in `prebuilt-receipt` model.
- Retired model `prebuilt-businessCard` and `prebuilt-document`. `prebuilt-document` model is essentially `prebuilt-layout` with `features="keyValuePairs"` specified. _(This is only supported as an optional feature for "prebuilt-layout" and "prebuilt-invoice".)_

If you were using the old `azure-ai-formrecognizer` package, please refer [MIGRATION.MD](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/MIGRATION_GUIDE.md) for more details.
If you were using the old `azure-ai-formrecognizer` package, please refer [MIGRATION_GUIDE.MD](https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/documentintelligence/azure-ai-documentintelligence/MIGRATION_GUIDE.md) for more details.
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Each page is treated as a separate document. Each empty page is kept as its own

### Clients names updates

|SDK version|Supported API version of service|
|SDK version|Supported API service version|
|-|-|
|1.0.0b1|2023-10-31-preview|
|3.3.X(azure-ai-formrecognizer latest GA release)|2.0, 2.1, 2022-08-31, 2023-07-31 (default)|
Expand Down
234 changes: 139 additions & 95 deletions sdk/documentintelligence/azure-ai-documentintelligence/README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ async def analyze_barcodes():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))

async with document_analysis_client:
async with document_intelligence_client:
# Specify which add-on capabilities to enable.
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
analyze_request=f,
features=[DocumentAnalysisFeature.BARCODES],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ async def analyze_fonts():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_analysis_client:
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_intelligence_client:
# Specify which add-on capabilities to enable.
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
analyze_request=f,
features=[DocumentAnalysisFeature.STYLE_FONT],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ async def analyze_formulas():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))

async with document_analysis_client:
async with document_intelligence_client:
# Specify which add-on capabilities to enable
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
analyze_request=f,
features=[DocumentAnalysisFeature.FORMULAS],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ async def analyze_with_highres():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))

async with document_analysis_client:
async with document_intelligence_client:
# Specify which add-on capabilities to enable.
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
analyze_request=f,
features=[DocumentAnalysisFeature.OCR_HIGH_RESOLUTION],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ async def analyze_languages():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))

async with document_analysis_client:
async with document_intelligence_client:
# Specify which add-on capabilities to enable.
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
analyze_request=f,
features=[DocumentAnalysisFeature.LANGUAGES],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ async def analyze_query_fields():
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]
url = "https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/documentintelligence/azure-ai-documentintelligence/samples/sample_forms/forms/Invoice_1.pdf"

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))

async with document_analysis_client:
async with document_intelligence_client:
# Specify which add-on capabilities to enable.
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
AnalyzeDocumentRequest(url_source=url),
features=[DocumentAnalysisFeature.QUERY_FIELDS],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ async def analyze_custom_documents(custom_model_id):
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]
model_id = os.getenv("CUSTOM_BUILT_MODEL_ID", custom_model_id)

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))

# Make sure your document's type is included in the list of document types the custom model can analyze
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
model_id=model_id, analyze_request=f, content_type="application/octet-stream"
)
result = await poller.result()
Expand Down Expand Up @@ -112,11 +112,11 @@ async def main():
build_mode=DocumentBuildMode.TEMPLATE,
azure_blob_source=AzureBlobContentSource(container_url=blob_container_sas_url),
)
document_model_admin_client = DocumentIntelligenceAdministrationClient(
document_intelligence_admin_client = DocumentIntelligenceAdministrationClient(
endpoint=endpoint, credential=AzureKeyCredential(key)
)
async with document_model_admin_client:
poll = await document_model_admin_client.begin_build_document_model(request)
async with document_intelligence_admin_client:
poll = await document_intelligence_admin_client.begin_build_document_model(request)
model = await poll.result()
model_id = model.model_id
await analyze_custom_documents(model_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ async def analyze_documents_output_in_markdown():
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]
url = "https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/documentintelligence/azure-ai-documentintelligence/samples/sample_forms/forms/Invoice_1.pdf"

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_analysis_client:
poller = await document_analysis_client.begin_analyze_document(
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_intelligence_client:
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
AnalyzeDocumentRequest(url_source=url),
output_content_format=ContentFormat.MARKDOWN,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ async def analyze_general_documents():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(
document_intelligence_client = DocumentIntelligenceClient(
endpoint=endpoint, credential=AzureKeyCredential(key)
)
async with document_analysis_client:
async with document_intelligence_client:
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-layout",
analyze_request=f,
features=[DocumentAnalysisFeature.KEY_VALUE_PAIRS],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ async def analyze_identity_documents():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_analysis_client:
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_intelligence_client:
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-idDocument", analyze_request=f, content_type="application/octet-stream"
)
id_documents = await poller.result()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ async def analyze_invoice():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_analysis_client:
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_intelligence_client:
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-invoice", analyze_request=f, locale="en-US", content_type="application/octet-stream"
)
invoices = await poller.result()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ async def analyze_layout():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_analysis_client:
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_intelligence_client:
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-layout", analyze_request=f, content_type="application/octet-stream"
)
result = await poller.result()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ async def analyze_read():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_analysis_client:
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_intelligence_client:
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-read",
analyze_request=f,
features=[DocumentAnalysisFeature.STYLE_FONT],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ async def analyze_receipts():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_analysis_client:
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_intelligence_client:
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-receipt", analyze_request=f, locale="en-US", content_type="application/octet-stream"
)
receipts = await poller.result()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,14 @@ async def analyze_receipts_from_url():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
url = "https://raw.githubusercontent.com/Azure/azure-sdk-for-python/main/sdk/documentintelligence/azure-ai-documentintelligence/samples/sample_forms/receipt/contoso-receipt.png"
async with document_analysis_client:
poller = await document_analysis_client.begin_analyze_document(
async with document_intelligence_client:
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-receipt", AnalyzeDocumentRequest(url_source=url)
)
receipts = await poller.result()
# [END analyze_receipts_from_url]

for idx, receipt in enumerate(receipts.documents):
print(f"--------Analysis of receipt #{idx + 1}--------")
Expand Down Expand Up @@ -96,7 +97,6 @@ async def analyze_receipts_from_url():
if total:
print(f"Total: {format_price(total.get('valueCurrency'))} has confidence: {total.confidence}")
print("--------------------------------------")
# [END analyze_receipts_from_url]


async def main():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ async def analyze_tax_us_w2():
endpoint = os.environ["DOCUMENTINTELLIGENCE_ENDPOINT"]
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]

document_analysis_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_analysis_client:
document_intelligence_client = DocumentIntelligenceClient(endpoint=endpoint, credential=AzureKeyCredential(key))
async with document_intelligence_client:
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_analyze_document(
poller = await document_intelligence_client.begin_analyze_document(
"prebuilt-tax.us.w2", analyze_request=f, locale="en-US", content_type="application/octet-stream"
)
w2s = await poller.result()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ async def classify_document(classifier_id):
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]
classifier_id = os.getenv("CLASSIFIER_ID", classifier_id)

document_analysis_client = DocumentIntelligenceClient(
document_intelligence_client = DocumentIntelligenceClient(
endpoint=endpoint, credential=AzureKeyCredential(key)
)
async with document_analysis_client:
async with document_intelligence_client:
with open(path_to_sample_documents, "rb") as f:
poller = await document_analysis_client.begin_classify_document(
poller = await document_intelligence_client.begin_classify_document(
classifier_id, classify_request=f, content_type="application/octet-stream"
)
result = await poller.result()
Expand Down Expand Up @@ -85,11 +85,11 @@ async def main():
key = os.environ["DOCUMENTINTELLIGENCE_API_KEY"]
blob_container_sas_url = os.environ["DOCUMENTINTELLIGENCE_TRAINING_DATA_CLASSIFIER_SAS_URL"]

document_model_admin_client = DocumentIntelligenceAdministrationClient(
document_intelligence_admin_client = DocumentIntelligenceAdministrationClient(
endpoint=endpoint, credential=AzureKeyCredential(key)
)
async with document_model_admin_client:
poller = await document_model_admin_client.begin_build_classifier(
async with document_intelligence_admin_client:
poller = await document_intelligence_admin_client.begin_build_classifier(
BuildDocumentClassifierRequest(
classifier_id=str(uuid.uuid4()),
doc_types={
Expand Down
Loading

0 comments on commit 2bcc83c

Please sign in to comment.