DocumentIntelligenceAdministrationClient.ComposeModel Method

Definition

Overloads

ComposeModel(WaitUntil, ComposeDocumentModelContent, CancellationToken)

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

ComposeModel(WaitUntil, RequestContent, RequestContext)

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

ComposeModel(WaitUntil, ComposeDocumentModelContent, CancellationToken)

Source:
DocumentIntelligenceAdministrationClient.cs

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

public virtual Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails> ComposeModel (Azure.WaitUntil waitUntil, Azure.AI.DocumentIntelligence.ComposeDocumentModelContent composeRequest, System.Threading.CancellationToken cancellationToken = default);
abstract member ComposeModel : Azure.WaitUntil * Azure.AI.DocumentIntelligence.ComposeDocumentModelContent * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>
override this.ComposeModel : Azure.WaitUntil * Azure.AI.DocumentIntelligence.ComposeDocumentModelContent * System.Threading.CancellationToken -> Azure.Operation<Azure.AI.DocumentIntelligence.DocumentModelDetails>
Public Overridable Function ComposeModel (waitUntil As WaitUntil, composeRequest As ComposeDocumentModelContent, Optional cancellationToken As CancellationToken = Nothing) As 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 ComposeModel.

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 = client.ComposeModel(WaitUntil.Completed, composeRequest);
DocumentModelDetails responseData = operation.Value;

This sample shows how to call ComposeModel 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 = client.ComposeModel(WaitUntil.Completed, composeRequest);
DocumentModelDetails responseData = operation.Value;

Applies to

ComposeModel(WaitUntil, RequestContent, RequestContext)

Source:
DocumentIntelligenceAdministrationClient.cs

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

public virtual Azure.Operation<BinaryData> ComposeModel (Azure.WaitUntil waitUntil, Azure.Core.RequestContent content, Azure.RequestContext context = default);
abstract member ComposeModel : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
override this.ComposeModel : Azure.WaitUntil * Azure.Core.RequestContent * Azure.RequestContext -> Azure.Operation<BinaryData>
Public Overridable Function ComposeModel (waitUntil As WaitUntil, content As RequestContent, Optional context As RequestContext = Nothing) As 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 ComposeModel and parse the result.

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

using RequestContent content = RequestContent.Create(new
{
    modelId = "<modelId>",
    classifierId = "<classifierId>",
    docTypes = new
    {
        key = new object(),
    },
});
Operation<BinaryData> operation = client.ComposeModel(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());

This sample shows how to call ComposeModel with all parameters and request content and parse the result.

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

using RequestContent content = RequestContent.Create(new
{
    modelId = "<modelId>",
    description = "<description>",
    classifierId = "<classifierId>",
    split = "auto",
    docTypes = new
    {
        key = new
        {
            description = "<description>",
            buildMode = "template",
            fieldSchema = new
            {
                key = new
                {
                    type = "string",
                    description = "<description>",
                    example = "<example>",
                    properties = new { },
                },
            },
            fieldConfidence = new
            {
                key = 123.45F,
            },
            modelId = "<modelId>",
            confidenceThreshold = 123.45F,
            features = new object[]
            {
                "ocrHighResolution"
            },
            queryFields = new object[]
            {
                "<queryFields>"
            },
            maxDocumentsToAnalyze = 1234,
        },
    },
    tags = new
    {
        key = "<tags>",
    },
});
Operation<BinaryData> operation = client.ComposeModel(WaitUntil.Completed, content);
BinaryData responseData = operation.Value;

JsonElement result = JsonDocument.Parse(responseData.ToStream()).RootElement;
Console.WriteLine(result.GetProperty("modelId").ToString());
Console.WriteLine(result.GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("createdDateTime").ToString());
Console.WriteLine(result.GetProperty("expirationDateTime").ToString());
Console.WriteLine(result.GetProperty("apiVersion").ToString());
Console.WriteLine(result.GetProperty("tags").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("buildMode").ToString());
Console.WriteLine(result.GetProperty("azureBlobSource").GetProperty("containerUrl").ToString());
Console.WriteLine(result.GetProperty("azureBlobSource").GetProperty("prefix").ToString());
Console.WriteLine(result.GetProperty("azureBlobFileListSource").GetProperty("containerUrl").ToString());
Console.WriteLine(result.GetProperty("azureBlobFileListSource").GetProperty("fileList").ToString());
Console.WriteLine(result.GetProperty("classifierId").ToString());
Console.WriteLine(result.GetProperty("split").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("buildMode").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("example").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("items").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("items").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("items").GetProperty("example").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("example").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("items").GetProperty("type").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("items").GetProperty("description").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldSchema").GetProperty("<key>").GetProperty("properties").GetProperty("<key>").GetProperty("items").GetProperty("example").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("fieldConfidence").GetProperty("<key>").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("modelId").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("confidenceThreshold").ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("features")[0].ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("queryFields")[0].ToString());
Console.WriteLine(result.GetProperty("docTypes").GetProperty("<key>").GetProperty("maxDocumentsToAnalyze").ToString());
Console.WriteLine(result.GetProperty("warnings")[0].GetProperty("code").ToString());
Console.WriteLine(result.GetProperty("warnings")[0].GetProperty("message").ToString());
Console.WriteLine(result.GetProperty("warnings")[0].GetProperty("target").ToString());
Console.WriteLine(result.GetProperty("trainingHours").ToString());

Applies to