DocumentModelAdministrationClient class
Klient do interakcji z funkcjami zarządzania modelami usługi Rozpoznawanie formularzy, takimi jak tworzenie, odczytywanie, wyświetlanie listy, usuwanie i kopiowanie modeli.
Przykłady:
Azure Active Directory
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
Klucz interfejsu API (klucz subskrypcji)
import { AzureKeyCredential, DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new AzureKeyCredential("<API key>");
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
Konstruktory
| Document |
Utwórz wystąpienie DocumentModelAdministrationClient z punktu końcowego zasobu i statycznego klucza interfejsu API ( Przykład:
|
| Document |
Utwórz wystąpienie DocumentModelAdministrationClient z punktu końcowego zasobu i usługi Azure Identity Aby uzyskać więcej informacji na temat uwierzytelniania za pomocą usługi Azure Active Directory, zobacz pakiet Przykład:
|
Metody
| begin |
Utwórz nowy klasyfikator dokumentów przy użyciu danego identyfikatora klasyfikatora i typów dokumentów. Identyfikator klasyfikatora musi być unikatowy wśród klasyfikatorów w ramach zasobu. Typy dokumentów są podawane jako obiekt, który mapuje nazwę typu dokumentu na zestaw danych treningowych dla tego typu dokumentu. Obsługiwane są dwie metody wprowadzania danych szkoleniowych:
Usługa Rozpoznawanie formularzy odczytuje zestaw danych szkoleniowych z kontenera usługi Azure Storage, podanego jako adres URL kontenera z tokenem SAS, który umożliwia zapleczu usługi komunikowanie się z kontenerem. Wymagane są co najmniej uprawnienia "odczyt" i "lista". Ponadto dane w danym kontenerze muszą być zorganizowane zgodnie z konkretną konwencją, która jest udokumentowana w dokumentacji usługi do tworzenia niestandardowych klasyfikatorów dokumentów. Przykład
|
| begin |
Utwórz nowy model z danym identyfikatorem ze źródła zawartości modelu. Identyfikator modelu może składać się z dowolnego tekstu, tak długo, jak nie zaczyna się od "wstępnie utworzonej" (ponieważ te modele odnoszą się do wstępnie utworzonych modeli rozpoznawania formularzy, które są wspólne dla wszystkich zasobów), i tak długo, jak jeszcze nie istnieją w ramach zasobu. Źródło zawartości opisuje mechanizm używany przez usługę do odczytywania danych szkoleniowych wejściowych. Aby uzyskać więcej informacji, zobacz typ <xref:DocumentModelContentSource>. Przykład
|
| begin |
Utwórz nowy model z danym identyfikatorem z zestawu dokumentów wejściowych i pól oznaczonych etykietami. Identyfikator modelu może składać się z dowolnego tekstu, tak długo, jak nie zaczyna się od "wstępnie utworzonej" (ponieważ te modele odnoszą się do wstępnie utworzonych modeli rozpoznawania formularzy, które są wspólne dla wszystkich zasobów), i tak długo, jak jeszcze nie istnieją w ramach zasobu. Usługa Rozpoznawanie formularzy odczytuje zestaw danych szkoleniowych z kontenera usługi Azure Storage, podanego jako adres URL kontenera z tokenem SAS, który umożliwia zapleczu usługi komunikowanie się z kontenerem. Wymagane są co najmniej uprawnienia "odczyt" i "lista". Ponadto dane w danym kontenerze muszą być zorganizowane zgodnie z określoną konwencją, która jest udokumentowana w dokumentacji usługi do tworzenia modeli niestandardowych. Przykład
|
| begin |
Tworzy pojedynczy złożony model na podstawie kilku wstępnie istniejących modeli podrzędnych. Wynikowy model złożony łączy typy dokumentów modeli składników i wstawia krok klasyfikacji do potoku wyodrębniania, aby określić, które z jego podmodelek składników jest najbardziej odpowiednie dla danego danych wejściowych. Przykład
|
| begin |
Kopiuje model z danym identyfikatorem do identyfikatora zasobu i modelu zakodowanego przez daną autoryzację kopiowania. Zobacz CopyAuthorization i getCopyAuthorization. Przykład
|
| delete |
Usuwa klasyfikator z danym identyfikatorem z zasobu klienta, jeśli istnieje. Nie można przywrócić tej operacji. Przykład
|
| delete |
Usuwa model z danym identyfikatorem z zasobu klienta, jeśli istnieje. Nie można przywrócić tej operacji. Przykład
|
| get |
Tworzy autoryzację do kopiowania modelu do zasobu używanego z metodą
Przykład
|
| get |
Pobiera informacje o klasyfikatorze (DocumentClassifierDetails) według identyfikatora. Przykład
|
| get |
Pobiera informacje o modelu (DocumentModelDetails) według identyfikatora. Ta metoda może pobierać informacje o niestandardowych, a także wstępnie utworzonych modelach. zmiana powodująca niezgodnośćW poprzednich wersjach interfejsu API REST i zestawu SDK rozpoznawania formularzy metoda Przykład
|
| get |
Pobiera informacje o operacji ( Operacje reprezentują zadania niezwiązane z analizą, takie jak kompilowanie, kompilowanie lub kopiowanie modelu. |
| get |
Pobierz podstawowe informacje o zasobie tego klienta. Przykład
|
| list |
Wyświetl szczegółowe informacje o klasyfikatorach w zasobie. Ta operacja obsługuje stronicowanie. PrzykładyAsynchronizuj iterację
|
| list |
Lista podsumowań modeli w zasobie. Zostaną uwzględnione niestandardowe, a także wstępnie utworzone modele. Ta operacja obsługuje stronicowanie. Podsumowanie modelu (DocumentModelSummary) zawiera tylko podstawowe informacje o modelu i nie zawiera informacji o typach dokumentów w modelu (takich jak schematy pól i wartości ufności). Aby uzyskać dostęp do pełnych informacji o modelu, użyj getDocumentModel. zmiana powodująca niezgodnośćW poprzednich wersjach interfejsu API REST i zestawu SDK rozpoznawania formularzy metoda PrzykładyAsynchronizuj iterację
|
| list |
Wyświetlanie listy operacji tworzenia modelu w zasobie. Spowoduje to wygenerowanie wszystkich operacji, w tym operacji, które nie udało się pomyślnie utworzyć modeli. Ta operacja obsługuje stronicowanie. PrzykładyAsynchronizuj iterację
|
Szczegóły konstruktora
DocumentModelAdministrationClient(string, KeyCredential, DocumentModelAdministrationClientOptions)
Utwórz wystąpienie DocumentModelAdministrationClient z punktu końcowego zasobu i statycznego klucza interfejsu API (KeyCredential),
Przykład:
import { AzureKeyCredential, DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new AzureKeyCredential("<API key>");
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
new DocumentModelAdministrationClient(endpoint: string, credential: KeyCredential, options?: DocumentModelAdministrationClientOptions)
Parametry
- endpoint
-
string
adres URL punktu końcowego wystąpienia usług Azure Cognitive Services
- credential
- KeyCredential
KeyCredential zawierający klucz subskrypcji wystąpienia usług Cognitive Services
opcjonalne ustawienia konfigurowania wszystkich metod w kliencie
DocumentModelAdministrationClient(string, TokenCredential, DocumentModelAdministrationClientOptions)
Utwórz wystąpienie DocumentModelAdministrationClient z punktu końcowego zasobu i usługi Azure Identity TokenCredential.
Aby uzyskać więcej informacji na temat uwierzytelniania za pomocą usługi Azure Active Directory, zobacz pakiet @azure/identity.
Przykład:
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
new DocumentModelAdministrationClient(endpoint: string, credential: TokenCredential, options?: DocumentModelAdministrationClientOptions)
Parametry
- endpoint
-
string
adres URL punktu końcowego wystąpienia usług Azure Cognitive Services
- credential
- TokenCredential
wystąpienie TokenCredential z pakietu @azure/identity
opcjonalne ustawienia konfigurowania wszystkich metod w kliencie
Szczegóły metody
beginBuildDocumentClassifier(string, DocumentClassifierDocumentTypeSources, BeginBuildDocumentClassifierOptions)
Utwórz nowy klasyfikator dokumentów przy użyciu danego identyfikatora klasyfikatora i typów dokumentów.
Identyfikator klasyfikatora musi być unikatowy wśród klasyfikatorów w ramach zasobu.
Typy dokumentów są podawane jako obiekt, który mapuje nazwę typu dokumentu na zestaw danych treningowych dla tego typu dokumentu. Obsługiwane są dwie metody wprowadzania danych szkoleniowych:
-
azureBlobSource, który trenuje klasyfikator przy użyciu danych w danym kontenerze usługi Azure Blob Storage. -
azureBlobFileListSource, która jest podobna doazureBlobSource, ale umożliwia bardziej szczegółową kontrolę nad plikami zawartymi w zestawie danych treningowych przy użyciu listy plików sformatowanych w formacie JSONL.
Usługa Rozpoznawanie formularzy odczytuje zestaw danych szkoleniowych z kontenera usługi Azure Storage, podanego jako adres URL kontenera z tokenem SAS, który umożliwia zapleczu usługi komunikowanie się z kontenerem. Wymagane są co najmniej uprawnienia "odczyt" i "lista". Ponadto dane w danym kontenerze muszą być zorganizowane zgodnie z konkretną konwencją, która jest udokumentowana w dokumentacji usługi do tworzenia niestandardowych klasyfikatorów dokumentów.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const newClassifiedId = "aNewClassifier";
const containerUrl1 = "<training data container SAS URL 1>";
const containerUrl2 = "<training data container SAS URL 2>";
const poller = await client.beginBuildDocumentClassifier(
newClassifiedId,
{
// The document types. Each entry in this object should map a document type name to a
// `ClassifierDocumentTypeDetails` object
formX: {
azureBlobSource: {
containerUrl: containerUrl1,
},
},
formY: {
azureBlobFileListSource: {
containerUrl: containerUrl2,
fileList: "path/to/fileList.jsonl",
},
},
},
{
// Optionally, a text description may be attached to the classifier
description: "This is an example classifier!",
},
);
// Classifier building, like model creation operations, returns a poller that eventually produces a
// DocumentClassifierDetails object
const classifierDetails = await poller.pollUntilDone();
const {
classifierId, // identical to the classifierId given when creating the classifier
description, // identical to the description given when creating the classifier (if any)
createdOn, // the Date (timestamp) that the classifier was created
docTypes, // information about the document types in the classifier and their details
} = classifierDetails;
function beginBuildDocumentClassifier(classifierId: string, docTypeSources: DocumentClassifierDocumentTypeSources, options?: BeginBuildDocumentClassifierOptions): Promise<DocumentClassifierPoller>
Parametry
- classifierId
-
string
unikatowy identyfikator klasyfikatora do utworzenia
- docTypeSources
- DocumentClassifierDocumentTypeSources
typy dokumentów do uwzględnienia w klasyfikatorze i ich źródłach (mapa nazw typów dokumentów do ClassifierDocumentTypeDetails)
opcjonalne ustawienia operacji kompilacji klasyfikatora
Zwraca
Promise<DocumentClassifierPoller>
długotrwała operacja (poller), która ostatecznie utworzy szczegóły utworzonego klasyfikatora lub błąd
beginBuildDocumentModel(string, DocumentModelSource, DocumentModelBuildMode, BeginBuildDocumentModelOptions)
Utwórz nowy model z danym identyfikatorem ze źródła zawartości modelu.
Identyfikator modelu może składać się z dowolnego tekstu, tak długo, jak nie zaczyna się od "wstępnie utworzonej" (ponieważ te modele odnoszą się do wstępnie utworzonych modeli rozpoznawania formularzy, które są wspólne dla wszystkich zasobów), i tak długo, jak jeszcze nie istnieją w ramach zasobu.
Źródło zawartości opisuje mechanizm używany przez usługę do odczytywania danych szkoleniowych wejściowych. Aby uzyskać więcej informacji, zobacz typ <xref:DocumentModelContentSource>.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const containerSasUrl = "<SAS url to the blob container storing training documents>";
// You must provide the model ID. It can be any text that does not start with "prebuilt-".
// For example, you could provide a randomly generated GUID using the "uuid" package.
// The second parameter is the SAS-encoded URL to an Azure Storage container with the training documents.
// The third parameter is the build mode: one of "template" (the only mode prior to 4.0.0-beta.3) or "neural".
// See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes.
const poller = await client.beginBuildDocumentModel(
"<model ID>",
{ azureBlobSource: { containerUrl: containerSasUrl } },
"template",
{
// The model description is optional and can be any text.
description: "This is my new model!",
onProgress: ({ status }) => {
console.log(`operation status: ${status}`);
},
},
);
const model = await poller.pollUntilDone();
console.log(`Model ID: ${model.modelId}`);
console.log(`Description: ${model.description}`);
console.log(`Created: ${model.createdOn}`);
// A model may contain several document types, which describe the possible object structures of fields extracted using
// this model
console.log("Document Types:");
for (const [docType, { description, fieldSchema: schema }] of Object.entries(
model.docTypes ?? {},
)) {
console.log(`- Name: "${docType}"`);
console.log(` Description: "${description}"`);
// For simplicity, this example will only show top-level field names
console.log(" Fields:");
for (const [fieldName, fieldSchema] of Object.entries(schema)) {
console.log(` - "${fieldName}" (${fieldSchema.type})`);
console.log(` ${fieldSchema.description ?? "<no description>"}`);
}
}
function beginBuildDocumentModel(modelId: string, contentSource: DocumentModelSource, buildMode: DocumentModelBuildMode, options?: BeginBuildDocumentModelOptions): Promise<DocumentModelPoller>
Parametry
- modelId
-
string
unikatowy identyfikator modelu do utworzenia
- contentSource
- DocumentModelSource
źródło zawartości, które udostępnia dane szkoleniowe dla tego modelu
- buildMode
-
DocumentModelBuildMode
tryb używany podczas kompilowania modelu (zobacz DocumentModelBuildMode)
- options
- BeginBuildDocumentModelOptions
opcjonalne ustawienia operacji kompilacji modelu
Zwraca
Promise<DocumentModelPoller>
długotrwała operacja (poller), która ostatecznie spowoduje wygenerowanie informacji o utworzonym modelu lub błędzie
beginBuildDocumentModel(string, string, DocumentModelBuildMode, BeginBuildDocumentModelOptions)
Utwórz nowy model z danym identyfikatorem z zestawu dokumentów wejściowych i pól oznaczonych etykietami.
Identyfikator modelu może składać się z dowolnego tekstu, tak długo, jak nie zaczyna się od "wstępnie utworzonej" (ponieważ te modele odnoszą się do wstępnie utworzonych modeli rozpoznawania formularzy, które są wspólne dla wszystkich zasobów), i tak długo, jak jeszcze nie istnieją w ramach zasobu.
Usługa Rozpoznawanie formularzy odczytuje zestaw danych szkoleniowych z kontenera usługi Azure Storage, podanego jako adres URL kontenera z tokenem SAS, który umożliwia zapleczu usługi komunikowanie się z kontenerem. Wymagane są co najmniej uprawnienia "odczyt" i "lista". Ponadto dane w danym kontenerze muszą być zorganizowane zgodnie z określoną konwencją, która jest udokumentowana w dokumentacji usługi do tworzenia modeli niestandardowych.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const containerSasUrl = "<SAS url to the blob container storing training documents>";
// You must provide the model ID. It can be any text that does not start with "prebuilt-".
// For example, you could provide a randomly generated GUID using the "uuid" package.
// The second parameter is the SAS-encoded URL to an Azure Storage container with the training documents.
// The third parameter is the build mode: one of "template" (the only mode prior to 4.0.0-beta.3) or "neural".
// See https://aka.ms/azsdk/formrecognizer/buildmode for more information about build modes.
const poller = await client.beginBuildDocumentModel("<model ID>", containerSasUrl, "template", {
// The model description is optional and can be any text.
description: "This is my new model!",
onProgress: ({ status }) => {
console.log(`operation status: ${status}`);
},
});
const model = await poller.pollUntilDone();
console.log(`Model ID: ${model.modelId}`);
console.log(`Description: ${model.description}`);
console.log(`Created: ${model.createdOn}`);
// A model may contain several document types, which describe the possible object structures of fields extracted using
// this model
console.log("Document Types:");
for (const [docType, { description, fieldSchema: schema }] of Object.entries(
model.docTypes ?? {},
)) {
console.log(`- Name: "${docType}"`);
console.log(` Description: "${description}"`);
// For simplicity, this example will only show top-level field names
console.log(" Fields:");
for (const [fieldName, fieldSchema] of Object.entries(schema)) {
console.log(` - "${fieldName}" (${fieldSchema.type})`);
console.log(` ${fieldSchema.description ?? "<no description>"}`);
}
}
function beginBuildDocumentModel(modelId: string, containerUrl: string, buildMode: DocumentModelBuildMode, options?: BeginBuildDocumentModelOptions): Promise<DocumentModelPoller>
Parametry
- modelId
-
string
unikatowy identyfikator modelu do utworzenia
- containerUrl
-
string
Adres URL zakodowany przy użyciu sygnatury dostępu współdzielonego do kontenera usługi Azure Storage zawierającego zestaw danych treningowych
- buildMode
-
DocumentModelBuildMode
tryb używany podczas kompilowania modelu (zobacz DocumentModelBuildMode)
- options
- BeginBuildDocumentModelOptions
opcjonalne ustawienia operacji kompilacji modelu
Zwraca
Promise<DocumentModelPoller>
długotrwała operacja (poller), która ostatecznie spowoduje wygenerowanie informacji o utworzonym modelu lub błędzie
beginComposeDocumentModel(string, Iterable<string>, BeginComposeDocumentModelOptions)
Tworzy pojedynczy złożony model na podstawie kilku wstępnie istniejących modeli podrzędnych.
Wynikowy model złożony łączy typy dokumentów modeli składników i wstawia krok klasyfikacji do potoku wyodrębniania, aby określić, które z jego podmodelek składników jest najbardziej odpowiednie dla danego danych wejściowych.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const composeModelId = "aNewComposedModel";
const subModelIds = ["documentType1Model", "documentType2Model", "documentType3Model"];
// The resulting composed model can classify and extract data from documents
// conforming to any of the above document types
const poller = await client.beginComposeDocumentModel(composeModelId, subModelIds, {
description: "This is a composed model that can handle several document types.",
});
// Model composition, like all other model creation operations, returns a poller that eventually produces a
// ModelDetails object
const modelDetails = await poller.pollUntilDone();
const {
modelId, // identical to the modelId given when creating the model
description, // identical to the description given when creating the model
createdOn, // the Date (timestamp) that the model was created
docTypes, // information about the document types of the composed submodels
} = modelDetails;
function beginComposeDocumentModel(modelId: string, componentModelIds: Iterable<string>, options?: BeginComposeDocumentModelOptions): Promise<DocumentModelPoller>
Parametry
- modelId
-
string
unikatowy identyfikator modelu do utworzenia
- componentModelIds
-
Iterable<string>
Iterable ciągów reprezentujących unikatowe identyfikatory modeli do tworzenia
- options
- BeginComposeDocumentModelOptions
opcjonalne ustawienia tworzenia modelu
Zwraca
Promise<DocumentModelPoller>
długotrwała operacja (poller), która ostatecznie spowoduje wygenerowanie informacji o utworzonym modelu lub błędzie
beginCopyModelTo(string, CopyAuthorization, BeginCopyModelOptions)
Kopiuje model z danym identyfikatorem do identyfikatora zasobu i modelu zakodowanego przez daną autoryzację kopiowania.
Zobacz CopyAuthorization i getCopyAuthorization.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient, AzureKeyCredential } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// We create the copy authorization using a client authenticated with the destination resource. Note that these two
// resources can be the same (you can copy a model to a new ID in the same resource).
const copyAuthorization = await client.getCopyAuthorization("<destination model ID>");
// Finally, use the _source_ client to copy the model and await the copy operation
// We need a client for the source model's resource
const sourceEndpoint = "https://<source resource name>.cognitiveservices.azure.com";
const sourceCredential = new AzureKeyCredential("<source api key>");
const sourceClient = new DocumentModelAdministrationClient(sourceEndpoint, sourceCredential);
const poller = await sourceClient.beginCopyModelTo("<source model ID>", copyAuthorization);
// Model copying, like all other model creation operations, returns a poller that eventually produces a ModelDetails
// object
const modelDetails = await poller.pollUntilDone();
const {
modelId, // identical to the modelId given when creating the copy authorization
description, // identical to the description given when creating the copy authorization
createdOn, // the Date (timestamp) that the model was created
docTypes, // information about the document types of the model (identical to the original, source model)
} = modelDetails;
function beginCopyModelTo(sourceModelId: string, authorization: CopyAuthorization, options?: BeginCopyModelOptions): Promise<DocumentModelPoller>
Parametry
- sourceModelId
-
string
unikatowy identyfikator modelu źródłowego, który zostanie skopiowany
- authorization
- CopyAuthorization
autoryzacja do kopiowania modelu utworzonego przy użyciu getCopyAuthorization
- options
- BeginCopyModelOptions
opcjonalne ustawienia dla
Zwraca
Promise<DocumentModelPoller>
długotrwała operacja (poller), która ostatecznie spowoduje wygenerowanie skopiowanych informacji o modelu lub błędzie
deleteDocumentClassifier(string, OperationOptions)
Usuwa klasyfikator z danym identyfikatorem z zasobu klienta, jeśli istnieje. Nie można przywrócić tej operacji.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
await client.deleteDocumentClassifier("<classifier ID to delete>");
function deleteDocumentClassifier(classifierId: string, options?: OperationOptions): Promise<void>
Parametry
- classifierId
-
string
unikatowy identyfikator klasyfikatora do usunięcia z zasobu
- options
- OperationOptions
opcjonalne ustawienia żądania
Zwraca
Promise<void>
deleteDocumentModel(string, DeleteDocumentModelOptions)
Usuwa model z danym identyfikatorem z zasobu klienta, jeśli istnieje. Nie można przywrócić tej operacji.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
await client.deleteDocumentModel("<model ID to delete>");
function deleteDocumentModel(modelId: string, options?: DeleteDocumentModelOptions): Promise<void>
Parametry
- modelId
-
string
unikatowy identyfikator modelu do usunięcia z zasobu
- options
- DeleteDocumentModelOptions
opcjonalne ustawienia żądania
Zwraca
Promise<void>
getCopyAuthorization(string, GetCopyAuthorizationOptions)
Tworzy autoryzację do kopiowania modelu do zasobu używanego z metodą beginCopyModelTo.
CopyAuthorization przyznaje innemu zasobowi usługi Cognitive Service prawo do utworzenia modelu w zasobie tego klienta z identyfikatorem modelu i opcjonalnym opisem zakodowanym w autoryzacji.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// The copyAuthorization data structure stored below grants any cognitive services resource the right to copy a
// model into the client's resource with the given destination model ID.
const copyAuthorization = await client.getCopyAuthorization("<destination model ID>");
function getCopyAuthorization(destinationModelId: string, options?: GetCopyAuthorizationOptions): Promise<CopyAuthorization>
Parametry
- destinationModelId
-
string
unikatowy identyfikator modelu docelowego (identyfikator do skopiowania modelu do)
- options
- GetCopyAuthorizationOptions
opcjonalne ustawienia tworzenia autoryzacji kopiowania
Zwraca
Promise<CopyAuthorization>
autoryzacja kopiowania, która koduje dany identyfikator modelu i opcjonalny opis
getDocumentClassifier(string, OperationOptions)
Pobiera informacje o klasyfikatorze (DocumentClassifierDetails) według identyfikatora.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const foundClassifier = "<classifier ID>";
const {
classifierId, // identical to the ID given when calling `getDocumentClassifier`
description, // a textual description of the classifier, if provided during classifier creation
createdOn, // the Date (timestamp) that the classifier was created
// information about the document types in the classifier and their corresponding traning data
docTypes,
} = await client.getDocumentClassifier(foundClassifier);
// The `docTypes` property is a map of document type names to information about the training data
// for that document type.
for (const [docTypeName, classifierDocTypeDetails] of Object.entries(docTypes)) {
console.log(`- '${docTypeName}': `, classifierDocTypeDetails);
}
function getDocumentClassifier(classifierId: string, options?: OperationOptions): Promise<DocumentClassifierDetails>
Parametry
- classifierId
-
string
unikatowy identyfikator klasyfikatora do wykonywania zapytań
- options
- OperationOptions
opcjonalne ustawienia żądania
Zwraca
Promise<DocumentClassifierDetails>
informacje o klasyfikatorze o danym identyfikatorze
getDocumentModel(string, GetModelOptions)
Pobiera informacje o modelu (DocumentModelDetails) według identyfikatora.
Ta metoda może pobierać informacje o niestandardowych, a także wstępnie utworzonych modelach.
zmiana powodująca niezgodność
W poprzednich wersjach interfejsu API REST i zestawu SDK rozpoznawania formularzy metoda getModel może zwrócić dowolny model, nawet taki, który nie mógł utworzyć z powodu błędów. W nowych wersjach usługi getDocumentModel i listDocumentModelstworzyć tylko pomyślnie utworzone modele (tj. modele, które są "gotowe" do użycia). Modele, które zakończyły się niepowodzeniem, są teraz pobierane za pośrednictwem interfejsów API "operations", zobacz getOperation i listOperations.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// The ID of the prebuilt business card model
const prebuiltModelId = "prebuilt-businessCard";
const {
modelId, // identical to the modelId given when calling `getDocumentModel`
description, // a textual description of the model, if provided during model creation
createdOn, // the Date (timestamp) that the model was created
// information about the document types in the model and their field schemas
docTypes: {
// the document type of the prebuilt business card model
"prebuilt:businesscard": {
// an optional, textual description of this document type
description: businessCardDescription,
// the schema of the fields in this document type, see the FieldSchema type
fieldSchema,
// the service's confidences in the fields (an object with field names as properties and numeric confidence
// values)
fieldConfidence,
},
},
} = await client.getDocumentModel(prebuiltModelId);
function getDocumentModel(modelId: string, options?: GetModelOptions): Promise<DocumentModelDetails>
Parametry
- modelId
-
string
unikatowy identyfikator modelu do wykonywania zapytań
- options
- GetModelOptions
opcjonalne ustawienia żądania
Zwraca
Promise<DocumentModelDetails>
informacje o modelu o danym identyfikatorze
getOperation(string, GetOperationOptions)
Pobiera informacje o operacji (OperationDetails) według jego identyfikatora.
Operacje reprezentują zadania niezwiązane z analizą, takie jak kompilowanie, kompilowanie lub kopiowanie modelu.
function getOperation(operationId: string, options?: GetOperationOptions): Promise<OperationDetails>
Parametry
- operationId
-
string
identyfikator operacji do wykonania zapytania
- options
- GetOperationOptions
opcjonalne ustawienia żądania
Zwraca
Promise<OperationDetails>
informacje o operacji z danym identyfikatorem
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// The ID of the operation, which should be a GUID
const findOperationId = "<operation GUID>";
const {
operationId, // identical to the operationId given when calling `getOperation`
kind, // the operation kind, one of "documentModelBuild", "documentModelCompose", or "documentModelCopyTo"
status, // the status of the operation, one of "notStarted", "running", "failed", "succeeded", or "canceled"
percentCompleted, // a number between 0 and 100 representing the progress of the operation
createdOn, // a Date object that reflects the time when the operation was started
lastUpdatedOn, // a Date object that reflects the time when the operation state was last modified
} = await client.getOperation(findOperationId);
getResourceDetails(GetResourceDetailsOptions)
Pobierz podstawowe informacje o zasobie tego klienta.
Przykład
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
const {
// Information about the custom models in the current resource
customDocumentModels: {
// The number of custom models in the current resource
count,
// The maximum number of models that the current resource can support
limit,
},
} = await client.getResourceDetails();
function getResourceDetails(options?: GetResourceDetailsOptions): Promise<ResourceDetails>
Parametry
- options
- GetResourceDetailsOptions
opcjonalne ustawienia żądania
Zwraca
Promise<ResourceDetails>
podstawowe informacje o zasobie tego klienta
listDocumentClassifiers(ListModelsOptions)
Wyświetl szczegółowe informacje o klasyfikatorach w zasobie. Ta operacja obsługuje stronicowanie.
Przykłady
Asynchronizuj iterację
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
for await (const details of client.listDocumentClassifiers()) {
const {
classifierId, // The classifier's unique ID
description, // a textual description of the classifier, if provided during creation
docTypes, // information about the document types in the classifier and their corresponding traning data
} = details;
}
// The listDocumentClassifiers method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listDocumentClassifiers().byPage();
for await (const page of pages) {
// Each page is an array of classifiers and can be iterated synchronously
for (const details of page) {
const {
classifierId, // The classifier's unique ID
description, // a textual description of the classifier, if provided during creation
docTypes, // information about the document types in the classifier and their corresponding traning data
} = details;
}
}
function listDocumentClassifiers(options?: ListModelsOptions): PagedAsyncIterableIterator<DocumentClassifierDetails, DocumentClassifierDetails[], PageSettings>
Parametry
- options
- ListModelsOptions
opcjonalne ustawienia żądań klasyfikatora
Zwraca
async iterable szczegółów klasyfikatora, który obsługuje stronicowanie
listDocumentModels(ListModelsOptions)
Lista podsumowań modeli w zasobie. Zostaną uwzględnione niestandardowe, a także wstępnie utworzone modele. Ta operacja obsługuje stronicowanie.
Podsumowanie modelu (DocumentModelSummary) zawiera tylko podstawowe informacje o modelu i nie zawiera informacji o typach dokumentów w modelu (takich jak schematy pól i wartości ufności).
Aby uzyskać dostęp do pełnych informacji o modelu, użyj getDocumentModel.
zmiana powodująca niezgodność
W poprzednich wersjach interfejsu API REST i zestawu SDK rozpoznawania formularzy metoda listModels zwróciła wszystkie modele, nawet te, które nie zostały utworzone z powodu błędów. W nowych wersjach usługi listDocumentModels i getDocumentModeltworzyć tylko pomyślnie utworzone modele (tj. modele, które są "gotowe" do użycia). Modele, które zakończyły się niepowodzeniem, są teraz pobierane za pośrednictwem interfejsów API "operations", zobacz getOperation i listOperations.
Przykłady
Asynchronizuj iterację
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
// Iterate over all models in the current resource
for await (const summary of client.listDocumentModels()) {
const {
modelId, // The model's unique ID
description, // a textual description of the model, if provided during model creation
} = summary;
// You can get the full model info using `getDocumentModel`
const model = await client.getDocumentModel(modelId);
}
// The listDocumentModels method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listDocumentModels().byPage();
for await (const page of pages) {
// Each page is an array of models and can be iterated synchronously
for (const summary of page) {
const {
modelId, // The model's unique ID
description, // a textual description of the model, if provided during model creation
} = summary;
// You can get the full model info using `getDocumentModel`
const model = await client.getDocumentModel(modelId);
}
}
function listDocumentModels(options?: ListModelsOptions): PagedAsyncIterableIterator<DocumentModelSummary, DocumentModelSummary[], PageSettings>
Parametry
- options
- ListModelsOptions
opcjonalne ustawienia żądań modelu
Zwraca
async iterable podsumowań modelu, które obsługują stronicowanie
listOperations(ListOperationsOptions)
Wyświetlanie listy operacji tworzenia modelu w zasobie. Spowoduje to wygenerowanie wszystkich operacji, w tym operacji, które nie udało się pomyślnie utworzyć modeli. Ta operacja obsługuje stronicowanie.
Przykłady
Asynchronizuj iterację
import { DefaultAzureCredential } from "@azure/identity";
import { DocumentModelAdministrationClient } from "@azure/ai-form-recognizer";
const credential = new DefaultAzureCredential();
const client = new DocumentModelAdministrationClient(
"https://<resource name>.cognitiveservices.azure.com",
credential,
);
for await (const operation of client.listOperations()) {
const {
operationId, // the operation's GUID
status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
percentCompleted, // the progress of the operation, from 0 to 100
} = operation;
}
// The listOperations method is paged, and you can iterate by page using the `byPage` method.
const pages = client.listOperations().byPage();
for await (const page of pages) {
// Each page is an array of operation info objects and can be iterated synchronously
for (const operation of page) {
const {
operationId, // the operation's GUID
status, // the operation status, one of "notStarted", "running", "succeeded", "failed", or "canceled"
percentCompleted, // the progress of the operation, from 0 to 100
} = operation;
}
}
function listOperations(options?: ListOperationsOptions): PagedAsyncIterableIterator<OperationSummary, OperationSummary[], PageSettings>
Parametry
- options
- ListOperationsOptions
opcjonalne ustawienia żądań operacji
Zwraca
async iterable obiektów informacji o operacjach, które obsługują stronicowanie