/// <summary> /// Creates a composed model from a collection of existing models. /// A composed model allows multiple models to be called with a single model ID. When a document is /// submitted to be analyzed with a composed model ID, a classification step is first performed to /// route it to the correct custom model. /// </summary> /// <param name="modelIds">List of model ids to use in the composed model.</param> /// <param name="modelId">A unique ID for your composed model. If not specified, a model ID will be created for you.</param> /// <param name="modelDescription">An optional description to add to the model.</param> /// <param name="tags">A list of user-defined key-value tag attributes associated with the model.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns> /// <para>A <see cref="BuildModelOperation"/> to wait on this long-running operation. Its Value upon successful /// completion will contain meta-data about the composed model.</para> /// </returns> public virtual async Task <BuildModelOperation> StartCreateComposedModelAsync(IEnumerable <string> modelIds, string modelId = default, string modelDescription = default, IDictionary <string, string> tags = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(modelIds, nameof(modelIds)); using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(DocumentModelAdministrationClient)}.{nameof(StartCreateComposedModel)}"); scope.Start(); try { modelId ??= Guid.NewGuid().ToString(); var composeRequest = new ComposeDocumentModelRequest(modelId, ConvertToComponentModelInfo(modelIds)) { Description = modelDescription }; if (tags != null) { foreach (var tag in tags) { composeRequest.Tags.Add(tag); } } var response = await ServiceClient.ComposeDocumentModelAsync(composeRequest, cancellationToken).ConfigureAwait(false); return(new BuildModelOperation(response.Headers.OperationLocation, response.GetRawResponse(), ServiceClient, Diagnostics)); } catch (Exception e) { scope.Failed(e); throw; } }
/// <summary> /// Creates a composed model from a collection of existing models. /// A composed model allows multiple models to be called with a single model ID. When a document is /// submitted to be analyzed with a composed model ID, a classification step is first performed to /// route it to the correct custom model. /// </summary> /// <param name="modelIds">List of model ids to use in the composed model.</param> /// <param name="modelId">A unique ID for your composed model. If not specified, a model ID will be created for you.</param> /// <param name="modelDescription">An optional description to add to the model.</param> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns> /// <para>A <see cref="BuildModelOperation"/> to wait on this long-running operation. Its Value upon successful /// completion will contain meta-data about the composed model.</para> /// </returns> public virtual BuildModelOperation StartCreateComposedModel(IEnumerable <string> modelIds, string modelId = default, string modelDescription = default, CancellationToken cancellationToken = default) { Argument.AssertNotNull(modelIds, nameof(modelIds)); using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(DocumentModelAdministrationClient)}.{nameof(StartCreateComposedModel)}"); scope.Start(); try { modelId ??= Guid.NewGuid().ToString(); var composeRequest = new ComposeDocumentModelRequest(modelId, ConvertToComponentModelInfo(modelIds)) { Description = modelDescription }; var response = ServiceClient.DocumentAnalysisComposeDocumentModel(composeRequest, cancellationToken); return(new BuildModelOperation(response.Headers.OperationLocation, response.GetRawResponse(), ServiceClient, Diagnostics)); } catch (Exception e) { scope.Failed(e); throw; } }