Condividi tramite


DocumentIntelligenceAdministrationClient.ComposeModelAsync Method

Definition

Overloads

ComposeModelAsync(WaitUntil, ComposeDocumentModelContent, CancellationToken)

Creates a new document model from document types of existing document models.

ComposeModelAsync(WaitUntil, ComposeModelOptions, CancellationToken)

Creates a new document model from document types of existing document models.

ComposeModelAsync(WaitUntil, RequestContent, RequestContext)

[Protocol Method] Creates a new document model from document types of existing document models.

ComposeModelAsync(WaitUntil, ComposeDocumentModelContent, CancellationToken)

Source:
DocumentIntelligenceAdministrationClient.cs

Creates a new document model from document types of existing document models.

public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>> ComposeModelAsync (Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.ComposeDocumentModelContent composeRequest, System.Threading.CancellationToken cancellationToken = default);
abstract member ComposeModelAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.ComposeDocumentModelContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
override this.ComposeModelAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.ComposeDocumentModelContent * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
Public Overridable Function ComposeModelAsync (waitUntil As WaitUntil, composeRequest As ComposeDocumentModelContent, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Operation(Of DocumentModelDetails))

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

composeRequest
ComposeDocumentModelContent

Compose request parameters.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

composeRequest is null.

Examples

This sample shows how to call ComposeModelAsync.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

ComposeDocumentModelContent composeRequest = new ComposeDocumentModelContent("<modelId>", "<classifierId>", new Dictionary<string, DocumentTypeDetails>
{
    ["key"] = new DocumentTypeDetails()
});
Operation<DocumentModelDetails> operation = await client.ComposeModelAsync(WaitUntil.Completed, composeRequest);
DocumentModelDetails responseData = operation.Value;

This sample shows how to call ComposeModelAsync with all parameters.

Uri endpoint = new Uri("<https://my-service.azure.com>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

ComposeDocumentModelContent composeRequest = new ComposeDocumentModelContent("<modelId>", "<classifierId>", new Dictionary<string, DocumentTypeDetails>
{
    ["key"] = new DocumentTypeDetails
    {
        Description = "<description>",
        BuildMode = DocumentBuildMode.Template,
        FieldSchema =
        {
            ["key"] = new DocumentFieldSchema(DocumentFieldType.String)
            {
                Description = "<description>",
                Example = "<example>",
                Items = default,
                Properties =
                {
                    ["key"] = default
                },
            }
        },
        FieldConfidence =
        {
            ["key"] = 123.45F
        },
        ModelId = "<modelId>",
        ConfidenceThreshold = 123.45F,
        Features = { DocumentAnalysisFeature.OcrHighResolution },
        QueryFields = { "<queryFields>" },
        MaxDocumentsToAnalyze = 1234,
    }
})
{
    Description = "<description>",
    Split = SplitMode.Auto,
    Tags =
    {
        ["key"] = "<tags>"
    },
};
Operation<DocumentModelDetails> operation = await client.ComposeModelAsync(WaitUntil.Completed, composeRequest);
DocumentModelDetails responseData = operation.Value;

Applies to

ComposeModelAsync(WaitUntil, ComposeModelOptions, CancellationToken)

Source:
DocumentIntelligenceAdministrationClient.cs

Creates a new document model from document types of existing document models.

public virtual System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>> ComposeModelAsync (Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.ComposeModelOptions options, System.Threading.CancellationToken cancellationToken = default);
abstract member ComposeModelAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.ComposeModelOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
override this.ComposeModelAsync : Azure.WaitUntil * Azure.AI.DocumentIntelligence.ComposeModelOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>>
Public Overridable Function ComposeModelAsync (waitUntil As WaitUntil, options As ComposeModelOptions, Optional cancellationToken As CancellationToken = Nothing) As Task(Of Operation(Of DocumentModelDetails))

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

options
ComposeModelOptions

Compose request options.

cancellationToken
CancellationToken

The cancellation token to use.

Returns

Exceptions

options is null.

Examples

This sample shows how to call ComposeModelAsync.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

ComposeModelOptions composeRequest = new ComposeModelOptions("composedModel", "customClassifier", new Dictionary<string, DocumentTypeDetails>
{
    ["formA"] = new DocumentTypeDetails
    {
        ModelId = "model1",
    },
    ["formB"] = new DocumentTypeDetails
    {
        ModelId = "model2",
    }
})
{
    Description = "Composed model description",
};
Operation<DocumentModelDetails> operation = await client.ComposeModelAsync(WaitUntil.Completed, composeRequest);
DocumentModelDetails responseData = operation.Value;

Applies to

ComposeModelAsync(WaitUntil, RequestContent, RequestContext)

Source:
DocumentIntelligenceAdministrationClient.cs
Source:
DocumentIntelligenceAdministrationClient.cs

[Protocol Method] Creates a new document model from document types of existing document models.

public virtual System.Threading.Tasks.Task<Azure.Operation<BinaryData>> ComposeModelAsync (Azure.WaitUntil waitUntil, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member ComposeModelAsync : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
override this.ComposeModelAsync : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Operation<BinaryData>>
Public Overridable Function ComposeModelAsync (waitUntil As WaitUntil, content As RequestContent, Optional context As RequestContext = Nothing) As Task(Of Operation(Of BinaryData))

Parameters

waitUntil
WaitUntil

Completed if the method should wait to return until the long-running operation has completed on the service; Started if it should return after starting the operation. For more information on long-running operations, please see Azure.Core Long-Running Operation samples.

content
RequestContent

The content to send as the body of the request.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The Operation representing an asynchronous operation on the service.

Exceptions

content is null.

Service returned a non-success status code.

Examples

This sample shows how to call ComposeModelAsync and parse the result.

Uri endpoint = new Uri("<endpoint>");
AzureKeyCredential credential = new AzureKeyCredential("<key>");
DocumentIntelligenceAdministrationClient client = new DocumentIntelligenceAdministrationClient(endpoint, credential);

using RequestContent content = RequestContent.Create(new
{
    modelId = "composedModel",
    description = "Composed model description",
    classifierId = "customClassifier",
    docTypes = new
    {
        formA = new
        {
            modelId = "model1",
        },
        formB = new
        {
            modelId = "model2",
        },
    },
});
Operation<BinaryData> operation = await client.ComposeModelAsync(WaitUntil.Completed, content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("modelId").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());

Applies to