Skip to content

Commit dab0fee

Browse files
committed
Merge branch 'main' into release-aio-april-updates
2 parents 7ec1401 + 6ba0e42 commit dab0fee

File tree

59 files changed

+1166
-675
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1166
-675
lines changed

articles/ai-services/document-intelligence/quickstarts/includes/csharp-sdk.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,12 @@ DocumentIntelligenceClient client = new DocumentIntelligenceClient(new Uri(endpo
209209
//sample document
210210
Uri fileUri = new Uri ("https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-layout.pdf");
211211

212-
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-layout", fileUri);
212+
AnalyzeDocumentContent content = new AnalyzeDocumentContent()
213+
{
214+
UrlSource= fileUri
215+
};
216+
217+
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-layout", content);
213218

214219
AnalyzeResult result = operation.Value;
215220

@@ -641,7 +646,12 @@ DocumentIntelligenceClient client = new DocumentIntelligenceClient(new Uri(endpo
641646
642647
Uri invoiceUri = new Uri ("https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-invoice.pdf");
643648

644-
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-invoice", invoiceUri);
649+
AnalyzeDocumentContent content = new AnalyzeDocumentContent()
650+
{
651+
UrlSource = invoiceUri
652+
};
653+
654+
Operation<AnalyzeResult> operation = await client.AnalyzeDocumentAsync(WaitUntil.Completed, "prebuilt-invoice", content);
645655

646656
AnalyzeResult result = operation.Value;
647657

articles/ai-services/document-intelligence/quickstarts/includes/java-sdk.md

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: laujan
66
manager: nitinme
77
ms.service: azure-ai-document-intelligence
88
ms.topic: include
9-
ms.date: 03/25/2024
9+
ms.date: 05/01/2024
1010
ms.author: lajanuar
1111
---
1212
<!-- markdownlint-disable MD025 -->
@@ -284,18 +284,25 @@ public class DocIntelligence {
284284

285285
public static void main(String[] args) {
286286

287-
// create your `DocumentAnalysisClient` instance and `AzureKeyCredential` variable
287+
// create your `DocumentIntelligenceClient` instance and `AzureKeyCredential` variable
288288
DocumentIntelligenceClient client = new DocumentIntelligenceClientBuilder()
289289
.credential(new AzureKeyCredential(key))
290290
.endpoint(endpoint)
291291
.buildClient();
292292

293293
// sample document
294-
String documentUrl = "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-layout.pdf";
295294
String modelId = "prebuilt-layout";
295+
String documentUrl = "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-layout.pdf";
296296

297-
SyncPoller <AnalyzeResultOperation, AnalyzeResultOperation> analyzeLayoutResultPoller =
298-
client.beginAnalyzeDocument(modelId, documentUrl);
297+
SyncPoller <AnalyzeResultOperation, AnalyzeResultOperation> analyzeLayoutPoller =
298+
client.beginAnalyzeDocument(modelId,
299+
null,
300+
null,
301+
null,
302+
null,
303+
null,
304+
null,
305+
new AnalyzeDocumentRequest().setUrlSource(documentUrl));
299306

300307
AnalyzeResult analyzeLayoutResult = analyzeLayoutPoller.getFinalResult().getAnalyzeResult();
301308

@@ -658,25 +665,27 @@ public class DocIntelligence {
658665

659666
public static void main(String[] args) {
660667

661-
// create your `DocumentAnalysisClient` instance and `AzureKeyCredential` variable
662-
DocumentIntelligenceClient client = new DocumentIntelligenceClientBuilder()
663-
.credential(new AzureKeyCredential(key))
664-
.endpoint(endpoint)
665-
.buildClient();
666-
667668
// sample document
668669
String modelId = "prebuilt-invoice";
669670
String invoiceUrl = "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-invoice.pdf";
670671

671672
public static void main(final String[] args) throws IOException {
673+
672674
// Instantiate a client that will be used to call the service.
673675
DocumentIntelligenceClient client = new DocumentIntelligenceClientBuilder()
674-
.credential(new AzureKeyCredential("{key}"))
675-
.endpoint("https://{endpoint}.cognitiveservices.azure.com/")
676+
.credential(new AzureKeyCredential(key))
677+
.endpoint(endpoint)
676678
.buildClient();
677679

678-
SyncPoller < OperationResult, AnalyzeResult > analyzeLayoutResultPoller =
679-
client.beginAnalyzeDocument(modelId, invoiceUrl);
680+
SyncPoller<AnalyzeResultOperation, AnalyzeResultOperation > analyzeInvoicesPoller =
681+
client.beginAnalyzeDocument(modelId,
682+
null,
683+
null,
684+
null,
685+
null,
686+
null,
687+
null,
688+
new AnalyzeDocumentRequest().setUrlSource(invoiceUrl));
680689

681690
AnalyzeResult analyzeInvoiceResult = analyzeInvoicesPoller.getFinalResult().getAnalyzeResult();
682691

articles/ai-services/document-intelligence/quickstarts/includes/javascript-sdk.md

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: laujan
66
manager: nitinme
77
ms.service: azure-ai-document-intelligence
88
ms.topic: include
9-
ms.date: 03/25/2024
9+
ms.date: 05/02/2024
1010
ms.author: lajanuar
1111
---
1212
<!-- markdownlint-disable MD025 -->
@@ -146,47 +146,44 @@ Extract text, selection marks, text styles, table structures, and bounding regio
146146
:::moniker range="doc-intel-4.0.0"
147147

148148
```javascript
149-
const { DocumentIntelligenceClient } = require("@azure-rest/ai-document-intelligence");
150-
const { AzureKeyCredential } = require("@azure/core-auth");
149+
const DocumentIntelligenceClient = require("@azure-rest/ai-document-intelligence");
151150

152151
// set `<your-key>` and `<your-endpoint>` variables with the values from the Azure portal.
153152
const key = "<your-key";
154153
const endpoint = "<your-endpoint>";
155154

156155
// sample document
157-
const formUrl = "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-layout.pdf"
156+
const formUrl = "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-layout.pdf"
158157

159-
async function main() {
160-
const client = DocumentIntelligenceClient(endpoint, new AzureKeyCredential(key));
158+
async function main() {
159+
const client = DocumentIntelligenceClient(endpoint, {key:key},);
161160

162-
const poller = await client.beginAnalyzeDocument("prebuilt-layout", formUrl);
163161

164-
const {
165-
pages,
166-
tables
167-
} = await poller.pollUntilDone();
162+
const initialResponse = await client
163+
.path("/documentModels/{modelId}:analyze", "prebuilt-layout")
164+
.post({
165+
contentType: "application/json",
166+
body: {
167+
urlSource: formUrl
168+
},
169+
});
168170

169-
if (pages.length <= 0) {
170-
console.log("No pages were extracted from the document.");
171-
} else {
172-
console.log("Pages:");
173-
for (const page of pages) {
174-
console.log("- Page", page.pageNumber, `(unit: ${page.unit})`);
175-
console.log(` ${page.width}x${page.height}, angle: ${page.angle}`);
176-
console.log(` ${page.lines.length} lines, ${page.words.length} words`);
177-
}
178-
}
171+
const poller = await getLongRunningPoller(client, initialResponse);
172+
const analyzeResult = (await poller.pollUntilDone()).body.analyzeResult;
179173

180-
if (tables.length <= 0) {
181-
console.log("No tables were extracted from the document.");
182-
} else {
183-
console.log("Tables:");
184-
for (const table of tables) {
185-
console.log(
186-
`- Extracted table: ${table.columnCount} columns, ${table.rowCount} rows (${table.cells.length} cells)`
187-
);
188-
}
174+
const documents = analyzeResult?.documents;
175+
176+
const document = documents && documents[0];
177+
if (!document) {
178+
throw new Error("Expected at least one document in the result.");
189179
}
180+
181+
console.log(
182+
"Extracted document:",
183+
document.docType,
184+
`(confidence: ${document.confidence || "<undefined>"})`,
185+
);
186+
console.log("Fields:", document.fields);
190187
}
191188

192189
main().catch((error) => {
@@ -312,8 +309,7 @@ In this example, we analyze an invoice using the **prebuilt-invoice** model.
312309

313310
```javascript
314311

315-
const { DocumentIntelligenceClient } = require("@azure-rest/ai-document-intelligence");
316-
const { AzureKeyCredential } = require("@azure/core-auth");
312+
const DocumentIntelligenceClient = require("@azure-rest/ai-document-intelligence");
317313

318314
// set `<your-key>` and `<your-endpoint>` variables with the values from the Azure portal.
319315
const key = "<your-key>";
@@ -323,32 +319,44 @@ const { AzureKeyCredential } = require("@azure/core-auth");
323319
invoiceUrl = "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-REST-api-samples/master/curl/form-recognizer/sample-invoice.pdf"
324320

325321
async function main() {
326-
const client = DocumentIntelligenceClient(endpoint, new AzureKeyCredential(key));
327322

328-
const poller = await client.beginAnalyzeDocument("prebuilt-invoice", invoiceUrl);
329-
if (pages.length <= 0) {
330-
console.log("No pages were extracted from the document.");
331-
} else {
332-
console.log("Pages:");
333-
for (const page of pages) {
334-
console.log("- Page", page.pageNumber, `(unit: ${page.unit})`);
335-
console.log(` ${page.width}x${page.height}, angle: ${page.angle}`);
336-
console.log(` ${page.lines.length} lines, ${page.words.length} words`);
337-
}
338-
}
323+
const client = DocumentIntelligenceClient(endpoint, {key: key},
324+
);
339325

340-
if (tables.length <= 0) {
341-
console.log("No tables were extracted from the document.");
326+
const initialResponse = await client
327+
.path("/documentModels/{modelId}:analyze", "prebuilt-invoice")
328+
.post({
329+
contentType: "application/json",
330+
body: {
331+
// The Document Intelligence service will access the URL to the invoice image and extract data from it
332+
urlSource: invoiceUrl,
333+
},
334+
});
335+
336+
337+
const poller = await getLongRunningPoller(client, initialResponse);
338+
339+
poller.onProgress((state) => console.log("Operation:", state.result, state.status));
340+
const analyzeResult = (await poller.pollUntilDone()).body.analyzeResult;
341+
342+
const documents = analyzeResult?.documents;
343+
344+
const result = documents && documents[0];
345+
if (result) {
346+
console.log(result.fields);
342347
} else {
343-
console.log("Tables:");
344-
for (const table of tables) {
345-
console.log(
346-
`- Extracted table: ${table.columnCount} columns, ${table.rowCount} rows (${table.cells.length} cells)`
347-
);
348-
}
348+
throw new Error("Expected at least one invoice in the result.");
349349
}
350+
351+
console.log(
352+
"Extracted invoice:",
353+
document.docType,
354+
`(confidence: ${document.confidence || "<undefined>"})`,
355+
);
356+
console.log("Fields:", document.fields);
350357
}
351358

359+
352360
main().catch((error) => {
353361
console.error("An error occurred:", error);
354362
process.exit(1);

articles/ai-services/document-intelligence/quickstarts/includes/python-sdk.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ author: laujan
66
manager: nitinme
77
ms.service: azure-ai-document-intelligence
88
ms.topic: include
9-
ms.date: 03/25/2024
9+
ms.date: 05/01/2024
1010
ms.author: lajanuar
1111
---
1212
<!-- markdownlint-disable MD025 -->
@@ -135,6 +135,7 @@ import os
135135
from azure.core.credentials import AzureKeyCredential
136136
from azure.ai.documentintelligence import DocumentIntelligenceClient
137137
from azure.ai.documentintelligence.models import AnalyzeResult
138+
from azure.ai.documentintelligence.models import AnalyzeDocumentRequest
138139

139140
# set `<your-endpoint>` and `<your-key>` variables with the values from the Azure portal
140141
endpoint = "<your-endpoint>"
@@ -168,12 +169,8 @@ def analyze_layout():
168169
)
169170

170171
poller = document_intelligence_client.begin_analyze_document(
171-
"prebuilt-layout", formUrl
172-
)
173-
174-
analyze_request = AnalyzeDocumentRequest(
175-
url_source=formUrl
176-
)
172+
"prebuilt-layout", AnalyzeDocumentRequest(url_source=formUrl
173+
))
177174

178175
result: AnalyzeResult = poller.result()
179176

@@ -548,6 +545,9 @@ Analyze and extract common fields from specific document types using a prebuilt
548545
import os
549546
from azure.core.credentials import AzureKeyCredential
550547
from azure.ai.documentintelligence import DocumentIntelligenceClient
548+
from azure.ai.documentintelligence.models import AnalyzeResult
549+
from azure.ai.documentintelligence.models import AnalyzeDocumentRequest
550+
551551

552552

553553
# set `<your-endpoint>` and `<your-key>` variables with the values from the Azure portal
@@ -564,7 +564,7 @@ def analyze_invoice():
564564
)
565565

566566
poller = document_intelligence_client.begin_analyze_document(
567-
"prebuilt-invoice", invoiceUrl
567+
"prebuilt-invoice", AnalyzeDocumentRequest(url_source=invoiceUrl
568568
)
569569
invoices = poller.result()
570570

articles/ai-services/openai/concepts/provisioned-throughput.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Azure OpenAI Service provisioned throughput
33
description: Learn about provisioned throughput and Azure OpenAI.
44
ms.service: azure-ai-openai
55
ms.topic: conceptual
6-
ms.date: 04/29/2024
6+
ms.date: 05/02/2024
77
manager: nitinme
88
author: mrbullwinkle #ChrisHMSFT
99
ms.author: mbullwin #chrhoder
@@ -80,22 +80,30 @@ PTUs represent an amount of model processing capacity. Similar to your computer
8080

8181
A few high-level considerations:
8282
- Generations require more capacity than prompts
83-
- Larger calls are progressively more expensive to compute. For example, 100 calls of with a 1000 token prompt size will require less capacity than 1 call with 100,000 tokens in the prompt. This also means that the distribution of these call shapes is important in overall throughput. Traffic patterns with a wide distribution that includes some very large calls may experience lower throughput per PTU than a narrower distribution with the same average prompt & completion token sizes.
83+
- Larger calls are progressively more expensive to compute. For example, 100 calls of with a 1000 token prompt size will require less capacity than 1 call with 100,000 tokens in the prompt. This also means that the distribution of these call shapes is important in overall throughput. Traffic patterns with a wide distribution that includes some very large calls may experience lower throughput per PTU than a narrower distribution with the same average prompt & completion token sizes.
8484

85+
### How utilization performance works
8586

86-
### How utilization enforcement works
87-
Provisioned deployments provide you with an allocated amount of model processing capacity to run a given model. The `Provisioned-Managed Utilization` metric in Azure Monitor measures a given deployments utilization on 1-minute increments. Provisioned-Managed deployments are optimized to ensure that accepted calls are processed with a consistent model processing time (actual end-to-end latency is dependent on a call's characteristics). When the workload exceeds the allocated PTU capacity, the service returns a 429 HTTP status code until the utilization drops down below 100%.
87+
Provisioned deployments provide you with an allocated amount of model processing capacity to run a given model.
8888

89+
In Provisioned-Managed deployments, when capacity is exceeded, the API will immediately return a 429 HTTP Status Error. This enables the user to make decisions on how to manage their traffic. Users can redirect requests to a separate deployment, to a standard pay-as-you-go instance, or leverage a retry strategy to manage a given request. The service will continue to return the 429 HTTP status code until the utilization drops below 100%.
90+
91+
### How can I monitor capacity?
92+
93+
The [Provisioned-Managed Utilization V2 metric](../how-to/monitoring.md#azure-openai-metrics) in Azure Monitor measures a given deployments utilization on 1-minute increments. Provisioned-Managed deployments are optimized to ensure that accepted calls are processed with a consistent model processing time (actual end-to-end latency is dependent on a call's characteristics).
8994

9095
#### What should I do when I receive a 429 response?
9196
The 429 response isn't an error, but instead part of the design for telling users that a given deployment is fully utilized at a point in time. By providing a fast-fail response, you have control over how to handle these situations in a way that best fits your application requirements.
9297

9398
The `retry-after-ms` and `retry-after` headers in the response tell you the time to wait before the next call will be accepted. How you choose to handle this response depends on your application requirements. Here are some considerations:
94-
- You can consider redirecting the traffic to other models, deployments or experiences. This option is the lowest-latency solution because the action can be taken as soon as you receive the 429 signal.
99+
- You can consider redirecting the traffic to other models, deployments or experiences. This option is the lowest-latency solution because the action can be taken as soon as you receive the 429 signal. For ideas on how to effectively implement this pattern see this [community post](https://github.com/Azure/aoai-apim).
95100
- If you're okay with longer per-call latencies, implement client-side retry logic. This option gives you the highest amount of throughput per PTU. The Azure OpenAI client libraries include built-in capabilities for handling retries.
96101

97102
#### How does the service decide when to send a 429?
98-
We use a variation of the leaky bucket algorithm to maintain utilization below 100% while allowing some burstiness in the traffic. The high-level logic is as follows:
103+
104+
In the Provisioned-Managed offering, each request is evaluated individually according to its prompt size, expected generation size, and model to determine its expected utilization. This is in contrast to pay-as-you-go deployments which have a [custom rate limiting behavior](../how-to/quota.md) based on the estimated traffic load. For pay-as-you-go deployments this can lead to HTTP 429s being generated prior to defined quota values being exceeded if traffic is not evenly distributed.
105+
106+
For Provisioned-Managed, we use a variation of the leaky bucket algorithm to maintain utilization below 100% while allowing some burstiness in the traffic. The high-level logic is as follows:
99107
1. Each customer has a set amount of capacity they can utilize on a deployment
100108
2. When a request is made:
101109

@@ -118,7 +126,7 @@ We use a variation of the leaky bucket algorithm to maintain utilization below 1
118126

119127
#### How many concurrent calls can I have on my deployment?
120128

121-
The number of concurrent calls you can achieve depends on each call's shape (prompt size, max_token parameter, etc). The service will continue to accept calls until the utilization reach 100%. To determine the approximate number of concurrent calls you can model out the maximum requests per minute for a particular call shape in the [capacity calculator](https://oai.azure.com/portal/calculator). If the system generates less than the number of samplings tokens like max_token, it will accept more requests.
129+
The number of concurrent calls you can achieve depends on each call's shape (prompt size, max_token parameter, etc.). The service will continue to accept calls until the utilization reach 100%. To determine the approximate number of concurrent calls you can model out the maximum requests per minute for a particular call shape in the [capacity calculator](https://oai.azure.com/portal/calculator). If the system generates less than the number of samplings tokens like max_token, it will accept more requests.
122130

123131
## Next steps
124132

0 commit comments

Comments
 (0)