Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FormTrainingClient

Package version

Client class for training and managing custom form models.

Hierarchy

  • FormTrainingClient

Index

Constructors

constructor

Properties

endpointUrl

endpointUrl: string

Url to an Azure Form Recognizer service endpoint

Methods

beginCopyModel

  • Copies a custom model from this resource (the source) to the specified target Form Recognizer resource. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed. Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

    Example usage:

    const targetClient = new FormTrainingClient(targetEndpoint, new AzureKeyCredential(targetApiKey));
    const authorization = await targetClient.getCopyAuthorization(targetResourceId, targetResourceRegion);
    
    const sourceClient = new FormTrainingClient(endpoint, new AzureKeyCredential(apiKey));
    const poller = await sourceClient.beginCopyModel(sourceModelId, authorization, {
      onProgress: (state) => {
        console.log(`Copy model status: ${state.status}`);
      }
    });
    await poller.pollUntilDone();
    const result = poller.getResult();
    summary

    Copies custom model to target resource

    Parameters

    • modelId: string

      Id of the custom model in this resource to be copied to the target Form Recognizer resource

    • target: CopyAuthorization

      Copy authorization produced by calling targetTrainingClient.getCopyAuthorization()

    • Default value options: BeginCopyModelOptions = {}

    Returns Promise<PollerLike<PollOperationState<CustomFormModelInfo>, CustomFormModelInfo>>

beginTraining

  • Creates and trains a custom form model. This method returns a long running operation poller that allows you to wait indefinitely until the operation is completed. Note that the onProgress callback will not be invoked if the operation completes in the first request, and attempting to cancel a completed copy will result in an error being thrown.

    Note that when training operation fails, a model is still created in Azure Form Recognizer resource.

    Example usage:

    const trainingFilesUrl = "<url to the blob container storing training documents>";
    const trainingClient = new FormTrainingClient(endpoint, new AzureKeyCredential(apiKey));
    
    const poller = await trainingClient.beginTraining(trainingFilesUrl, false, {
      onProgress: (state) => { console.log("training status: "); console.log(state); }
    });
    await poller.pollUntilDone();
    const response = poller.getResult();
    summary

    Creates and trains a model

    Parameters

    • trainingFilesUrl: string

      Accessible url to an Azure Storage Blob container storing the training documents

    • useTrainingLabels: boolean

      specifies whether to training the model using label files

    • Default value options: BeginTrainingOptions = {}

    Returns Promise<PollerLike<PollOperationState<CustomFormModel>, CustomFormModel>>

deleteModel

getAccountProperties

getCopyAuthorization

getCustomModel

getFormRecognizerClient

listCustomModels

  • Returns an async iterable iterator to list information about all models in the cognitive service account.

    .byPage() returns an async iterable iterator to list the blobs in pages.

    Example using for await syntax:

    const client = new FormTrainingClient(endpoint, new AzureKeyCredential(apiKey));
    const result = client.listCustomModels();
    let i = 1;
    for await (const model of result) {
      console.log(`model ${i++}:`);
      console.log(model);
    }

    Example using iter.next():

    let i = 1;
    let iter = client.listCustomModels();
    let modelItem = await iter.next();
    while (!modelItem.done) {
      console.log(`model ${i++}: ${modelItem.value}`);
      modelItem = await iter.next();
    }

    Example using byPage():

     let i = 1;
     for await (const response of client.listCustomModels().byPage()) {
       for (const modelInfo of response.modelList!) {
         console.log(`model ${i++}: ${modelInfo.modelId}`);
       }
     }

    Parameters

    Returns PagedAsyncIterableIterator<CustomFormModelInfo, ListCustomModelsResponse>

Generated using TypeDoc