@azure/ai-form-recognizer 5.0.0-alpha.20250227.1 → 5.0.0-alpha.20250228.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +292 -330
- package/dist/browser/documentAnalysisClient.d.ts +220 -131
- package/dist/browser/documentAnalysisClient.d.ts.map +1 -1
- package/dist/browser/documentAnalysisClient.js +57 -35
- package/dist/browser/documentAnalysisClient.js.map +1 -1
- package/dist/browser/documentModelAdministrationClient.d.ts +291 -123
- package/dist/browser/documentModelAdministrationClient.d.ts.map +1 -1
- package/dist/browser/documentModelAdministrationClient.js +184 -82
- package/dist/browser/documentModelAdministrationClient.js.map +1 -1
- package/dist/browser/lro/util/delayMs.d.ts +1 -1
- package/dist/browser/lro/util/delayMs.js +1 -1
- package/dist/browser/lro/util/delayMs.js.map +1 -1
- package/dist/commonjs/documentAnalysisClient.d.ts +220 -131
- package/dist/commonjs/documentAnalysisClient.d.ts.map +1 -1
- package/dist/commonjs/documentAnalysisClient.js +57 -35
- package/dist/commonjs/documentAnalysisClient.js.map +1 -1
- package/dist/commonjs/documentModelAdministrationClient.d.ts +291 -123
- package/dist/commonjs/documentModelAdministrationClient.d.ts.map +1 -1
- package/dist/commonjs/documentModelAdministrationClient.js +184 -82
- package/dist/commonjs/documentModelAdministrationClient.js.map +1 -1
- package/dist/commonjs/lro/util/delayMs.d.ts +1 -1
- package/dist/commonjs/lro/util/delayMs.js +1 -1
- package/dist/commonjs/lro/util/delayMs.js.map +1 -1
- package/dist/esm/documentAnalysisClient.d.ts +220 -131
- package/dist/esm/documentAnalysisClient.d.ts.map +1 -1
- package/dist/esm/documentAnalysisClient.js +57 -35
- package/dist/esm/documentAnalysisClient.js.map +1 -1
- package/dist/esm/documentModelAdministrationClient.d.ts +291 -123
- package/dist/esm/documentModelAdministrationClient.d.ts.map +1 -1
- package/dist/esm/documentModelAdministrationClient.js +184 -82
- package/dist/esm/documentModelAdministrationClient.js.map +1 -1
- package/dist/esm/lro/util/delayMs.d.ts +1 -1
- package/dist/esm/lro/util/delayMs.js +1 -1
- package/dist/esm/lro/util/delayMs.js.map +1 -1
- package/dist/react-native/documentAnalysisClient.d.ts +220 -131
- package/dist/react-native/documentAnalysisClient.d.ts.map +1 -1
- package/dist/react-native/documentAnalysisClient.js +57 -35
- package/dist/react-native/documentAnalysisClient.js.map +1 -1
- package/dist/react-native/documentModelAdministrationClient.d.ts +291 -123
- package/dist/react-native/documentModelAdministrationClient.d.ts.map +1 -1
- package/dist/react-native/documentModelAdministrationClient.js +184 -82
- package/dist/react-native/documentModelAdministrationClient.js.map +1 -1
- package/dist/react-native/lro/util/delayMs.d.ts +1 -1
- package/dist/react-native/lro/util/delayMs.js +1 -1
- package/dist/react-native/lro/util/delayMs.js.map +1 -1
- package/package.json +19 -18
|
@@ -15,25 +15,27 @@ import type { DocumentModelSource, DocumentClassifierDocumentTypeSources } from
|
|
|
15
15
|
*
|
|
16
16
|
* #### Azure Active Directory
|
|
17
17
|
*
|
|
18
|
-
* ```
|
|
19
|
-
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
18
|
+
* ```ts snippet:ReadmeSampleAdministrationClient_TokenCredential
|
|
20
19
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
20
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
21
21
|
*
|
|
22
|
-
* const endpoint = "https://<resource name>.cognitiveservices.azure.com";
|
|
23
22
|
* const credential = new DefaultAzureCredential();
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* const client = new DocumentModelAdministrationClient(
|
|
24
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
25
|
+
* credential,
|
|
26
|
+
* );
|
|
26
27
|
* ```
|
|
27
28
|
*
|
|
28
29
|
* #### API Key (Subscription Key)
|
|
29
30
|
*
|
|
30
|
-
* ```
|
|
31
|
-
* import {
|
|
31
|
+
* ```ts snippet:ReadmeSampleAdministrationClient_KeyCredential
|
|
32
|
+
* import { AzureKeyCredential, DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
32
33
|
*
|
|
33
|
-
* const
|
|
34
|
-
* const
|
|
35
|
-
*
|
|
36
|
-
*
|
|
34
|
+
* const credential = new AzureKeyCredential("<API key>");
|
|
35
|
+
* const client = new DocumentModelAdministrationClient(
|
|
36
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
37
|
+
* credential,
|
|
38
|
+
* );
|
|
37
39
|
* ```
|
|
38
40
|
*/
|
|
39
41
|
export declare class DocumentModelAdministrationClient {
|
|
@@ -47,14 +49,15 @@ export declare class DocumentModelAdministrationClient {
|
|
|
47
49
|
*
|
|
48
50
|
* ### Example:
|
|
49
51
|
*
|
|
50
|
-
* ```
|
|
51
|
-
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
52
|
+
* ```ts snippet:ReadmeSampleAdministrationClient_TokenCredential
|
|
52
53
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
54
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
53
55
|
*
|
|
54
|
-
* const endpoint = "https://<resource name>.cognitiveservices.azure.com";
|
|
55
56
|
* const credential = new DefaultAzureCredential();
|
|
56
|
-
*
|
|
57
|
-
*
|
|
57
|
+
* const client = new DocumentModelAdministrationClient(
|
|
58
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
59
|
+
* credential,
|
|
60
|
+
* );
|
|
58
61
|
* ```
|
|
59
62
|
*
|
|
60
63
|
* @param endpoint - the endpoint URL of an Azure Cognitive Services instance
|
|
@@ -68,13 +71,14 @@ export declare class DocumentModelAdministrationClient {
|
|
|
68
71
|
*
|
|
69
72
|
* ### Example:
|
|
70
73
|
*
|
|
71
|
-
* ```
|
|
72
|
-
* import {
|
|
73
|
-
*
|
|
74
|
-
* const endpoint = "https://<resource name>.cognitiveservices.azure.com";
|
|
75
|
-
* const credential = new AzureKeyCredential("<api key>");
|
|
74
|
+
* ```ts snippet:ReadmeSampleAdministrationClient_KeyCredential
|
|
75
|
+
* import { AzureKeyCredential, DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
76
76
|
*
|
|
77
|
-
* const
|
|
77
|
+
* const credential = new AzureKeyCredential("<API key>");
|
|
78
|
+
* const client = new DocumentModelAdministrationClient(
|
|
79
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
80
|
+
* credential,
|
|
81
|
+
* );
|
|
78
82
|
* ```
|
|
79
83
|
*
|
|
80
84
|
* @param endpoint - the endpoint URL of an Azure Cognitive Services instance
|
|
@@ -101,25 +105,54 @@ export declare class DocumentModelAdministrationClient {
|
|
|
101
105
|
*
|
|
102
106
|
* ### Example
|
|
103
107
|
*
|
|
104
|
-
* ```
|
|
105
|
-
*
|
|
106
|
-
*
|
|
108
|
+
* ```ts snippet:ReadmeSampleBuildModel
|
|
109
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
110
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
107
111
|
*
|
|
108
|
-
* const
|
|
109
|
-
*
|
|
110
|
-
*
|
|
112
|
+
* const credential = new DefaultAzureCredential();
|
|
113
|
+
* const client = new DocumentModelAdministrationClient(
|
|
114
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
115
|
+
* credential,
|
|
116
|
+
* );
|
|
117
|
+
*
|
|
118
|
+
* const containerSasUrl = "<SAS url to the blob container storing training documents>";
|
|
119
|
+
*
|
|
120
|
+
* // You must provide the model ID. It can be any text that does not start with "prebuilt-".
|
|
121
|
+
* // For example, you could provide a randomly generated GUID using the "uuid" package.
|
|
122
|
+
* // The second parameter is the SAS-encoded URL to an Azure Storage container with the training documents.
|
|
123
|
+
* // The third parameter is the build mode: one of "template" (the only mode prior to 4.0.0-beta.3) or "neural".
|
|
124
|
+
* // See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes.
|
|
125
|
+
* const poller = await client.beginBuildDocumentModel("<model ID>", containerSasUrl, "template", {
|
|
126
|
+
* // The model description is optional and can be any text.
|
|
127
|
+
* description: "This is my new model!",
|
|
128
|
+
* onProgress: ({ status }) => {
|
|
129
|
+
* console.log(`operation status: ${status}`);
|
|
130
|
+
* },
|
|
111
131
|
* });
|
|
132
|
+
* const model = await poller.pollUntilDone();
|
|
112
133
|
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
134
|
+
* console.log(`Model ID: ${model.modelId}`);
|
|
135
|
+
* console.log(`Description: ${model.description}`);
|
|
136
|
+
* console.log(`Created: ${model.createdOn}`);
|
|
116
137
|
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
* }
|
|
138
|
+
* // A model may contain several document types, which describe the possible object structures of fields extracted using
|
|
139
|
+
* // this model
|
|
140
|
+
*
|
|
141
|
+
* console.log("Document Types:");
|
|
142
|
+
* for (const [docType, { description, fieldSchema: schema }] of Object.entries(
|
|
143
|
+
* model.docTypes ?? {},
|
|
144
|
+
* )) {
|
|
145
|
+
* console.log(`- Name: "${docType}"`);
|
|
146
|
+
* console.log(` Description: "${description}"`);
|
|
147
|
+
*
|
|
148
|
+
* // For simplicity, this example will only show top-level field names
|
|
149
|
+
* console.log(" Fields:");
|
|
150
|
+
*
|
|
151
|
+
* for (const [fieldName, fieldSchema] of Object.entries(schema)) {
|
|
152
|
+
* console.log(` - "${fieldName}" (${fieldSchema.type})`);
|
|
153
|
+
* console.log(` ${fieldSchema.description ?? "<no description>"}`);
|
|
154
|
+
* }
|
|
155
|
+
* }
|
|
123
156
|
* ```
|
|
124
157
|
*
|
|
125
158
|
* @param modelId - the unique ID of the model to create
|
|
@@ -141,24 +174,59 @@ export declare class DocumentModelAdministrationClient {
|
|
|
141
174
|
*
|
|
142
175
|
* ### Example
|
|
143
176
|
*
|
|
144
|
-
* ```
|
|
145
|
-
*
|
|
177
|
+
* ```ts snippet:ReadmeSampleBuildModel_Container
|
|
178
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
179
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
146
180
|
*
|
|
147
|
-
* const
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
181
|
+
* const credential = new DefaultAzureCredential();
|
|
182
|
+
* const client = new DocumentModelAdministrationClient(
|
|
183
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
184
|
+
* credential,
|
|
185
|
+
* );
|
|
151
186
|
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
187
|
+
* const containerSasUrl = "<SAS url to the blob container storing training documents>";
|
|
188
|
+
*
|
|
189
|
+
* // You must provide the model ID. It can be any text that does not start with "prebuilt-".
|
|
190
|
+
* // For example, you could provide a randomly generated GUID using the "uuid" package.
|
|
191
|
+
* // The second parameter is the SAS-encoded URL to an Azure Storage container with the training documents.
|
|
192
|
+
* // The third parameter is the build mode: one of "template" (the only mode prior to 4.0.0-beta.3) or "neural".
|
|
193
|
+
* // See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes.
|
|
194
|
+
* const poller = await client.beginBuildDocumentModel(
|
|
195
|
+
* "<model ID>",
|
|
196
|
+
* { azureBlobSource: { containerUrl: containerSasUrl } },
|
|
197
|
+
* "template",
|
|
198
|
+
* {
|
|
199
|
+
* // The model description is optional and can be any text.
|
|
200
|
+
* description: "This is my new model!",
|
|
201
|
+
* onProgress: ({ status }) => {
|
|
202
|
+
* console.log(`operation status: ${status}`);
|
|
203
|
+
* },
|
|
204
|
+
* },
|
|
205
|
+
* );
|
|
206
|
+
* const model = await poller.pollUntilDone();
|
|
155
207
|
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
208
|
+
* console.log(`Model ID: ${model.modelId}`);
|
|
209
|
+
* console.log(`Description: ${model.description}`);
|
|
210
|
+
* console.log(`Created: ${model.createdOn}`);
|
|
211
|
+
*
|
|
212
|
+
* // A model may contain several document types, which describe the possible object structures of fields extracted using
|
|
213
|
+
* // this model
|
|
214
|
+
*
|
|
215
|
+
* console.log("Document Types:");
|
|
216
|
+
* for (const [docType, { description, fieldSchema: schema }] of Object.entries(
|
|
217
|
+
* model.docTypes ?? {},
|
|
218
|
+
* )) {
|
|
219
|
+
* console.log(`- Name: "${docType}"`);
|
|
220
|
+
* console.log(` Description: "${description}"`);
|
|
221
|
+
*
|
|
222
|
+
* // For simplicity, this example will only show top-level field names
|
|
223
|
+
* console.log(" Fields:");
|
|
224
|
+
*
|
|
225
|
+
* for (const [fieldName, fieldSchema] of Object.entries(schema)) {
|
|
226
|
+
* console.log(` - "${fieldName}" (${fieldSchema.type})`);
|
|
227
|
+
* console.log(` ${fieldSchema.description ?? "<no description>"}`);
|
|
228
|
+
* }
|
|
229
|
+
* }
|
|
162
230
|
* ```
|
|
163
231
|
*
|
|
164
232
|
* @param modelId - the unique ID of the model to create
|
|
@@ -176,20 +244,24 @@ export declare class DocumentModelAdministrationClient {
|
|
|
176
244
|
*
|
|
177
245
|
* ### Example
|
|
178
246
|
*
|
|
179
|
-
* ```
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
247
|
+
* ```ts snippet:ReadmeSampleComposeModel
|
|
248
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
249
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
250
|
+
*
|
|
251
|
+
* const credential = new DefaultAzureCredential();
|
|
252
|
+
* const client = new DocumentModelAdministrationClient(
|
|
253
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
254
|
+
* credential,
|
|
255
|
+
* );
|
|
256
|
+
*
|
|
257
|
+
* const composeModelId = "aNewComposedModel";
|
|
258
|
+
* const subModelIds = ["documentType1Model", "documentType2Model", "documentType3Model"];
|
|
186
259
|
*
|
|
187
260
|
* // The resulting composed model can classify and extract data from documents
|
|
188
261
|
* // conforming to any of the above document types
|
|
189
|
-
* const poller = await client.beginComposeDocumentModel(
|
|
190
|
-
* description: "This is a composed model that can handle several document types."
|
|
262
|
+
* const poller = await client.beginComposeDocumentModel(composeModelId, subModelIds, {
|
|
263
|
+
* description: "This is a composed model that can handle several document types.",
|
|
191
264
|
* });
|
|
192
|
-
*
|
|
193
265
|
* // Model composition, like all other model creation operations, returns a poller that eventually produces a
|
|
194
266
|
* // ModelDetails object
|
|
195
267
|
* const modelDetails = await poller.pollUntilDone();
|
|
@@ -198,7 +270,7 @@ export declare class DocumentModelAdministrationClient {
|
|
|
198
270
|
* modelId, // identical to the modelId given when creating the model
|
|
199
271
|
* description, // identical to the description given when creating the model
|
|
200
272
|
* createdOn, // the Date (timestamp) that the model was created
|
|
201
|
-
* docTypes // information about the document types of the composed submodels
|
|
273
|
+
* docTypes, // information about the document types of the composed submodels
|
|
202
274
|
* } = modelDetails;
|
|
203
275
|
* ```
|
|
204
276
|
*
|
|
@@ -216,7 +288,16 @@ export declare class DocumentModelAdministrationClient {
|
|
|
216
288
|
*
|
|
217
289
|
* ### Example
|
|
218
290
|
*
|
|
219
|
-
* ```
|
|
291
|
+
* ```ts snippet:ReadmeSampleGetCopyAuthorization
|
|
292
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
293
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
294
|
+
*
|
|
295
|
+
* const credential = new DefaultAzureCredential();
|
|
296
|
+
* const client = new DocumentModelAdministrationClient(
|
|
297
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
298
|
+
* credential,
|
|
299
|
+
* );
|
|
300
|
+
*
|
|
220
301
|
* // The copyAuthorization data structure stored below grants any cognitive services resource the right to copy a
|
|
221
302
|
* // model into the client's resource with the given destination model ID.
|
|
222
303
|
* const copyAuthorization = await client.getCopyAuthorization("<destination model ID>");
|
|
@@ -234,18 +315,26 @@ export declare class DocumentModelAdministrationClient {
|
|
|
234
315
|
*
|
|
235
316
|
* ### Example
|
|
236
317
|
*
|
|
237
|
-
* ```
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* const
|
|
318
|
+
* ```ts snippet:ReadmeSampleCopyModel
|
|
319
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
320
|
+
* import { DocumentModelAdministrationClient, AzureKeyCredential } from "@azure/ai-form-recognizer";
|
|
321
|
+
*
|
|
322
|
+
* const credential = new DefaultAzureCredential();
|
|
323
|
+
* const client = new DocumentModelAdministrationClient(
|
|
324
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
325
|
+
* credential,
|
|
326
|
+
* );
|
|
242
327
|
*
|
|
243
328
|
* // We create the copy authorization using a client authenticated with the destination resource. Note that these two
|
|
244
329
|
* // resources can be the same (you can copy a model to a new ID in the same resource).
|
|
245
330
|
* const copyAuthorization = await client.getCopyAuthorization("<destination model ID>");
|
|
246
331
|
*
|
|
247
332
|
* // Finally, use the _source_ client to copy the model and await the copy operation
|
|
248
|
-
*
|
|
333
|
+
* // We need a client for the source model's resource
|
|
334
|
+
* const sourceEndpoint = "https://<source resource name>.cognitiveservices.azure.com";
|
|
335
|
+
* const sourceCredential = new AzureKeyCredential("<source api key>");
|
|
336
|
+
* const sourceClient = new DocumentModelAdministrationClient(sourceEndpoint, sourceCredential);
|
|
337
|
+
* const poller = await sourceClient.beginCopyModelTo("<source model ID>", copyAuthorization);
|
|
249
338
|
*
|
|
250
339
|
* // Model copying, like all other model creation operations, returns a poller that eventually produces a ModelDetails
|
|
251
340
|
* // object
|
|
@@ -255,7 +344,7 @@ export declare class DocumentModelAdministrationClient {
|
|
|
255
344
|
* modelId, // identical to the modelId given when creating the copy authorization
|
|
256
345
|
* description, // identical to the description given when creating the copy authorization
|
|
257
346
|
* createdOn, // the Date (timestamp) that the model was created
|
|
258
|
-
* docTypes // information about the document types of the model (identical to the original, source model)
|
|
347
|
+
* docTypes, // information about the document types of the model (identical to the original, source model)
|
|
259
348
|
* } = modelDetails;
|
|
260
349
|
* ```
|
|
261
350
|
*
|
|
@@ -285,32 +374,41 @@ export declare class DocumentModelAdministrationClient {
|
|
|
285
374
|
*
|
|
286
375
|
* ### Example
|
|
287
376
|
*
|
|
288
|
-
* ```
|
|
289
|
-
*
|
|
377
|
+
* ```ts snippet:ReadmeSampleBuildClassifier
|
|
378
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
379
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
380
|
+
*
|
|
381
|
+
* const credential = new DefaultAzureCredential();
|
|
382
|
+
* const client = new DocumentModelAdministrationClient(
|
|
383
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
384
|
+
* credential,
|
|
385
|
+
* );
|
|
386
|
+
*
|
|
387
|
+
* const newClassifiedId = "aNewClassifier";
|
|
290
388
|
* const containerUrl1 = "<training data container SAS URL 1>";
|
|
291
389
|
* const containerUrl2 = "<training data container SAS URL 2>";
|
|
292
390
|
*
|
|
293
391
|
* const poller = await client.beginBuildDocumentClassifier(
|
|
294
|
-
*
|
|
392
|
+
* newClassifiedId,
|
|
295
393
|
* {
|
|
296
394
|
* // The document types. Each entry in this object should map a document type name to a
|
|
297
395
|
* // `ClassifierDocumentTypeDetails` object
|
|
298
|
-
*
|
|
396
|
+
* formX: {
|
|
299
397
|
* azureBlobSource: {
|
|
300
398
|
* containerUrl: containerUrl1,
|
|
301
|
-
* }
|
|
399
|
+
* },
|
|
302
400
|
* },
|
|
303
|
-
*
|
|
401
|
+
* formY: {
|
|
304
402
|
* azureBlobFileListSource: {
|
|
305
403
|
* containerUrl: containerUrl2,
|
|
306
|
-
* fileList: "path/to/fileList.jsonl"
|
|
307
|
-
* }
|
|
404
|
+
* fileList: "path/to/fileList.jsonl",
|
|
405
|
+
* },
|
|
308
406
|
* },
|
|
309
407
|
* },
|
|
310
408
|
* {
|
|
311
409
|
* // Optionally, a text description may be attached to the classifier
|
|
312
|
-
* description: "This is an example classifier!"
|
|
313
|
-
* }
|
|
410
|
+
* description: "This is an example classifier!",
|
|
411
|
+
* },
|
|
314
412
|
* );
|
|
315
413
|
*
|
|
316
414
|
* // Classifier building, like model creation operations, returns a poller that eventually produces a
|
|
@@ -321,7 +419,7 @@ export declare class DocumentModelAdministrationClient {
|
|
|
321
419
|
* classifierId, // identical to the classifierId given when creating the classifier
|
|
322
420
|
* description, // identical to the description given when creating the classifier (if any)
|
|
323
421
|
* createdOn, // the Date (timestamp) that the classifier was created
|
|
324
|
-
* docTypes // information about the document types in the classifier and their details
|
|
422
|
+
* docTypes, // information about the document types in the classifier and their details
|
|
325
423
|
* } = classifierDetails;
|
|
326
424
|
* ```
|
|
327
425
|
*
|
|
@@ -346,15 +444,24 @@ export declare class DocumentModelAdministrationClient {
|
|
|
346
444
|
*
|
|
347
445
|
* ### Example
|
|
348
446
|
*
|
|
349
|
-
* ```
|
|
447
|
+
* ```ts snippet:ReadmeSampleGetResourceDetails
|
|
448
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
449
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
450
|
+
*
|
|
451
|
+
* const credential = new DefaultAzureCredential();
|
|
452
|
+
* const client = new DocumentModelAdministrationClient(
|
|
453
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
454
|
+
* credential,
|
|
455
|
+
* );
|
|
456
|
+
*
|
|
350
457
|
* const {
|
|
351
458
|
* // Information about the custom models in the current resource
|
|
352
|
-
*
|
|
459
|
+
* customDocumentModels: {
|
|
353
460
|
* // The number of custom models in the current resource
|
|
354
461
|
* count,
|
|
355
462
|
* // The maximum number of models that the current resource can support
|
|
356
|
-
* limit
|
|
357
|
-
* }
|
|
463
|
+
* limit,
|
|
464
|
+
* },
|
|
358
465
|
* } = await client.getResourceDetails();
|
|
359
466
|
* ```
|
|
360
467
|
*
|
|
@@ -376,9 +483,18 @@ export declare class DocumentModelAdministrationClient {
|
|
|
376
483
|
*
|
|
377
484
|
* ### Example
|
|
378
485
|
*
|
|
379
|
-
* ```
|
|
486
|
+
* ```ts snippet:ReadmeSampleGetModel
|
|
487
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
488
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
489
|
+
*
|
|
490
|
+
* const credential = new DefaultAzureCredential();
|
|
491
|
+
* const client = new DocumentModelAdministrationClient(
|
|
492
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
493
|
+
* credential,
|
|
494
|
+
* );
|
|
495
|
+
*
|
|
380
496
|
* // The ID of the prebuilt business card model
|
|
381
|
-
* const
|
|
497
|
+
* const prebuiltModelId = "prebuilt-businessCard";
|
|
382
498
|
*
|
|
383
499
|
* const {
|
|
384
500
|
* modelId, // identical to the modelId given when calling `getDocumentModel`
|
|
@@ -389,15 +505,15 @@ export declare class DocumentModelAdministrationClient {
|
|
|
389
505
|
* // the document type of the prebuilt business card model
|
|
390
506
|
* "prebuilt:businesscard": {
|
|
391
507
|
* // an optional, textual description of this document type
|
|
392
|
-
* description,
|
|
508
|
+
* description: businessCardDescription,
|
|
393
509
|
* // the schema of the fields in this document type, see the FieldSchema type
|
|
394
510
|
* fieldSchema,
|
|
395
511
|
* // the service's confidences in the fields (an object with field names as properties and numeric confidence
|
|
396
512
|
* // values)
|
|
397
|
-
* fieldConfidence
|
|
398
|
-
* }
|
|
399
|
-
* }
|
|
400
|
-
* } = await client.getDocumentModel(
|
|
513
|
+
* fieldConfidence,
|
|
514
|
+
* },
|
|
515
|
+
* },
|
|
516
|
+
* } = await client.getDocumentModel(prebuiltModelId);
|
|
401
517
|
* ```
|
|
402
518
|
*
|
|
403
519
|
* @param modelId - the unique ID of the model to query
|
|
@@ -425,7 +541,17 @@ export declare class DocumentModelAdministrationClient {
|
|
|
425
541
|
*
|
|
426
542
|
* #### Async Iteration
|
|
427
543
|
*
|
|
428
|
-
* ```
|
|
544
|
+
* ```ts snippet:ReadmeSampleListModels
|
|
545
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
546
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
547
|
+
*
|
|
548
|
+
* const credential = new DefaultAzureCredential();
|
|
549
|
+
* const client = new DocumentModelAdministrationClient(
|
|
550
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
551
|
+
* credential,
|
|
552
|
+
* );
|
|
553
|
+
*
|
|
554
|
+
* // Iterate over all models in the current resource
|
|
429
555
|
* for await (const summary of client.listDocumentModels()) {
|
|
430
556
|
* const {
|
|
431
557
|
* modelId, // The model's unique ID
|
|
@@ -435,17 +561,13 @@ export declare class DocumentModelAdministrationClient {
|
|
|
435
561
|
* // You can get the full model info using `getDocumentModel`
|
|
436
562
|
* const model = await client.getDocumentModel(modelId);
|
|
437
563
|
* }
|
|
438
|
-
* ```
|
|
439
564
|
*
|
|
440
|
-
* #### By Page
|
|
441
|
-
*
|
|
442
|
-
* ```javascript
|
|
443
565
|
* // The listDocumentModels method is paged, and you can iterate by page using the `byPage` method.
|
|
444
566
|
* const pages = client.listDocumentModels().byPage();
|
|
445
567
|
*
|
|
446
568
|
* for await (const page of pages) {
|
|
447
569
|
* // Each page is an array of models and can be iterated synchronously
|
|
448
|
-
* for (const
|
|
570
|
+
* for (const summary of page) {
|
|
449
571
|
* const {
|
|
450
572
|
* modelId, // The model's unique ID
|
|
451
573
|
* description, // a textual description of the model, if provided during model creation
|
|
@@ -466,8 +588,17 @@ export declare class DocumentModelAdministrationClient {
|
|
|
466
588
|
*
|
|
467
589
|
* ### Example
|
|
468
590
|
*
|
|
469
|
-
* ```
|
|
470
|
-
*
|
|
591
|
+
* ```ts snippet:ReadmeSampleDeleteModel
|
|
592
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
593
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
594
|
+
*
|
|
595
|
+
* const credential = new DefaultAzureCredential();
|
|
596
|
+
* const client = new DocumentModelAdministrationClient(
|
|
597
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
598
|
+
* credential,
|
|
599
|
+
* );
|
|
600
|
+
*
|
|
601
|
+
* await client.deleteDocumentModel("<model ID to delete>");
|
|
471
602
|
* ```
|
|
472
603
|
*
|
|
473
604
|
* @param modelId - the unique ID of the model to delete from the resource
|
|
@@ -479,21 +610,30 @@ export declare class DocumentModelAdministrationClient {
|
|
|
479
610
|
*
|
|
480
611
|
* ### Example
|
|
481
612
|
*
|
|
482
|
-
* ```
|
|
483
|
-
*
|
|
613
|
+
* ```ts snippet:ReadmeSampleGetClassifier
|
|
614
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
615
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
616
|
+
*
|
|
617
|
+
* const credential = new DefaultAzureCredential();
|
|
618
|
+
* const client = new DocumentModelAdministrationClient(
|
|
619
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
620
|
+
* credential,
|
|
621
|
+
* );
|
|
622
|
+
*
|
|
623
|
+
* const foundClassifier = "<classifier ID>";
|
|
484
624
|
*
|
|
485
625
|
* const {
|
|
486
626
|
* classifierId, // identical to the ID given when calling `getDocumentClassifier`
|
|
487
627
|
* description, // a textual description of the classifier, if provided during classifier creation
|
|
488
628
|
* createdOn, // the Date (timestamp) that the classifier was created
|
|
489
629
|
* // information about the document types in the classifier and their corresponding traning data
|
|
490
|
-
* docTypes
|
|
491
|
-
* } = await client.getDocumentClassifier(
|
|
630
|
+
* docTypes,
|
|
631
|
+
* } = await client.getDocumentClassifier(foundClassifier);
|
|
492
632
|
*
|
|
493
633
|
* // The `docTypes` property is a map of document type names to information about the training data
|
|
494
634
|
* // for that document type.
|
|
495
635
|
* for (const [docTypeName, classifierDocTypeDetails] of Object.entries(docTypes)) {
|
|
496
|
-
*
|
|
636
|
+
* console.log(`- '${docTypeName}': `, classifierDocTypeDetails);
|
|
497
637
|
* }
|
|
498
638
|
* ```
|
|
499
639
|
*
|
|
@@ -509,7 +649,16 @@ export declare class DocumentModelAdministrationClient {
|
|
|
509
649
|
*
|
|
510
650
|
* #### Async Iteration
|
|
511
651
|
*
|
|
512
|
-
* ```
|
|
652
|
+
* ```ts snippet:ReadmeSampleListClassifiers
|
|
653
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
654
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
655
|
+
*
|
|
656
|
+
* const credential = new DefaultAzureCredential();
|
|
657
|
+
* const client = new DocumentModelAdministrationClient(
|
|
658
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
659
|
+
* credential,
|
|
660
|
+
* );
|
|
661
|
+
*
|
|
513
662
|
* for await (const details of client.listDocumentClassifiers()) {
|
|
514
663
|
* const {
|
|
515
664
|
* classifierId, // The classifier's unique ID
|
|
@@ -517,11 +666,7 @@ export declare class DocumentModelAdministrationClient {
|
|
|
517
666
|
* docTypes, // information about the document types in the classifier and their corresponding traning data
|
|
518
667
|
* } = details;
|
|
519
668
|
* }
|
|
520
|
-
* ```
|
|
521
|
-
*
|
|
522
|
-
* #### By Page
|
|
523
669
|
*
|
|
524
|
-
* ```javascript
|
|
525
670
|
* // The listDocumentClassifiers method is paged, and you can iterate by page using the `byPage` method.
|
|
526
671
|
* const pages = client.listDocumentClassifiers().byPage();
|
|
527
672
|
*
|
|
@@ -546,8 +691,17 @@ export declare class DocumentModelAdministrationClient {
|
|
|
546
691
|
*
|
|
547
692
|
* ### Example
|
|
548
693
|
*
|
|
549
|
-
* ```
|
|
550
|
-
*
|
|
694
|
+
* ```ts snippet:ReadmeSampleDeleteClassifier
|
|
695
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
696
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
697
|
+
*
|
|
698
|
+
* const credential = new DefaultAzureCredential();
|
|
699
|
+
* const client = new DocumentModelAdministrationClient(
|
|
700
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
701
|
+
* credential,
|
|
702
|
+
* );
|
|
703
|
+
*
|
|
704
|
+
* await client.deleteDocumentClassifier("<classifier ID to delete>");
|
|
551
705
|
* ```
|
|
552
706
|
*
|
|
553
707
|
* @param classifierId - the unique ID of the classifier to delete from the resource
|
|
@@ -565,9 +719,18 @@ export declare class DocumentModelAdministrationClient {
|
|
|
565
719
|
*
|
|
566
720
|
* ### Example
|
|
567
721
|
*
|
|
568
|
-
* ```
|
|
722
|
+
* ```ts snippet:ReadmeSampleGetOperation
|
|
723
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
724
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
725
|
+
*
|
|
726
|
+
* const credential = new DefaultAzureCredential();
|
|
727
|
+
* const client = new DocumentModelAdministrationClient(
|
|
728
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
729
|
+
* credential,
|
|
730
|
+
* );
|
|
731
|
+
*
|
|
569
732
|
* // The ID of the operation, which should be a GUID
|
|
570
|
-
* const
|
|
733
|
+
* const findOperationId = "<operation GUID>";
|
|
571
734
|
*
|
|
572
735
|
* const {
|
|
573
736
|
* operationId, // identical to the operationId given when calling `getOperation`
|
|
@@ -576,7 +739,7 @@ export declare class DocumentModelAdministrationClient {
|
|
|
576
739
|
* percentCompleted, // a number between 0 and 100 representing the progress of the operation
|
|
577
740
|
* createdOn, // a Date object that reflects the time when the operation was started
|
|
578
741
|
* lastUpdatedOn, // a Date object that reflects the time when the operation state was last modified
|
|
579
|
-
* } = await client.getOperation(
|
|
742
|
+
* } = await client.getOperation(findOperationId);
|
|
580
743
|
* ```
|
|
581
744
|
*/
|
|
582
745
|
getOperation(operationId: string, options?: GetOperationOptions): Promise<OperationDetails>;
|
|
@@ -588,19 +751,24 @@ export declare class DocumentModelAdministrationClient {
|
|
|
588
751
|
*
|
|
589
752
|
* #### Async Iteration
|
|
590
753
|
*
|
|
591
|
-
* ```
|
|
754
|
+
* ```ts snippet:ReadmeSampleListOperations
|
|
755
|
+
* import { DefaultAzureCredential } from "@azure/identity";
|
|
756
|
+
* import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
|
|
757
|
+
*
|
|
758
|
+
* const credential = new DefaultAzureCredential();
|
|
759
|
+
* const client = new DocumentModelAdministrationClient(
|
|
760
|
+
* "https://<resource name>.cognitiveservices.azure.com",
|
|
761
|
+
* credential,
|
|
762
|
+
* );
|
|
763
|
+
*
|
|
592
764
|
* for await (const operation of client.listOperations()) {
|
|
593
765
|
* const {
|
|
594
766
|
* operationId, // the operation's GUID
|
|
595
767
|
* status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
|
|
596
|
-
* percentCompleted // the progress of the operation, from 0 to 100
|
|
768
|
+
* percentCompleted, // the progress of the operation, from 0 to 100
|
|
597
769
|
* } = operation;
|
|
598
770
|
* }
|
|
599
|
-
* ```
|
|
600
|
-
*
|
|
601
|
-
* #### By Page
|
|
602
771
|
*
|
|
603
|
-
* ```javascript
|
|
604
772
|
* // The listOperations method is paged, and you can iterate by page using the `byPage` method.
|
|
605
773
|
* const pages = client.listOperations().byPage();
|
|
606
774
|
*
|
|
@@ -610,7 +778,7 @@ export declare class DocumentModelAdministrationClient {
|
|
|
610
778
|
* const {
|
|
611
779
|
* operationId, // the operation's GUID
|
|
612
780
|
* status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
|
|
613
|
-
* percentCompleted // the progress of the operation, from 0 to 100
|
|
781
|
+
* percentCompleted, // the progress of the operation, from 0 to 100
|
|
614
782
|
* } = operation;
|
|
615
783
|
* }
|
|
616
784
|
* }
|