Skip to content

Commit

Permalink
feat(nlu): add new parameter to create/updateClassificationsModel
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinkowa committed Aug 9, 2022
1 parent 495295f commit e7d0b01
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2019, 2021.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -35,10 +35,10 @@ public partial interface INaturalLanguageUnderstandingService
DetailedResponse<CategoriesModel> GetCategoriesModel(string modelId);
DetailedResponse<CategoriesModel> UpdateCategoriesModel(string modelId, string language, System.IO.MemoryStream trainingData, string trainingDataContentType = null, string name = null, string description = null, string modelVersion = null, string workspaceId = null, string versionDescription = null);
DetailedResponse<DeleteModelResults> DeleteCategoriesModel(string modelId);
DetailedResponse<ClassificationsModel> CreateClassificationsModel(string language, System.IO.MemoryStream trainingData, string trainingDataContentType = null, string name = null, string description = null, string modelVersion = null, string workspaceId = null, string versionDescription = null);
DetailedResponse<ClassificationsModel> CreateClassificationsModel(string language, System.IO.MemoryStream trainingData, string trainingDataContentType = null, string name = null, string description = null, string modelVersion = null, string workspaceId = null, string versionDescription = null, ClassificationsTrainingParameters trainingParameters = null);
DetailedResponse<ClassificationsModelList> ListClassificationsModels();
DetailedResponse<ClassificationsModel> GetClassificationsModel(string modelId);
DetailedResponse<ClassificationsModel> UpdateClassificationsModel(string modelId, string language, System.IO.MemoryStream trainingData, string trainingDataContentType = null, string name = null, string description = null, string modelVersion = null, string workspaceId = null, string versionDescription = null);
DetailedResponse<ClassificationsModel> UpdateClassificationsModel(string modelId, string language, System.IO.MemoryStream trainingData, string trainingDataContentType = null, string name = null, string description = null, string modelVersion = null, string workspaceId = null, string versionDescription = null, ClassificationsTrainingParameters trainingParameters = null);
DetailedResponse<DeleteModelResults> DeleteClassificationsModel(string modelId);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

using Newtonsoft.Json;

namespace IBM.Watson.NaturalLanguageUnderstanding.v1.Model
{
/// <summary>
/// Optional classifications training parameters along with model train requests.
/// </summary>
public class ClassificationsTrainingParameters
{
/// <summary>
/// Model type selector to train either a single_label or a multi_label classifier.
/// </summary>
public class ModelTypeEnumValue
{
/// <summary>
/// Constant SINGLE_LABEL for single_label
/// </summary>
public const string SINGLE_LABEL = "single_label";
/// <summary>
/// Constant MULTI_LABEL for multi_label
/// </summary>
public const string MULTI_LABEL = "multi_label";

}

/// <summary>
/// Model type selector to train either a single_label or a multi_label classifier.
/// Constants for possible values can be found using ClassificationsTrainingParameters.ModelTypeEnumValue
/// </summary>
[JsonProperty("model_type", NullValueHandling = NullValueHandling.Ignore)]
public string ModelType { get; set; }
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* (C) Copyright IBM Corp. 2017, 2022.
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -16,7 +16,7 @@
*/

/**
* IBM OpenAPI SDK Code Generator Version: 3.46.0-a4e29da0-20220224-210428
* IBM OpenAPI SDK Code Generator Version: 3.53.0-9710cac3-20220713-193508
*/

using System.Collections.Generic;
Expand Down Expand Up @@ -1150,8 +1150,10 @@ public DetailedResponse<DeleteModelResults> DeleteCategoriesModel(string modelId
/// <param name="workspaceId">ID of the Watson Knowledge Studio workspace that deployed this model to Natural
/// Language Understanding. (optional)</param>
/// <param name="versionDescription">The description of the version. (optional)</param>
/// <param name="trainingParameters">Optional classifications training parameters along with model train
/// requests. (optional)</param>
/// <returns><see cref="ClassificationsModel" />ClassificationsModel</returns>
public DetailedResponse<ClassificationsModel> CreateClassificationsModel(string language, System.IO.MemoryStream trainingData, string trainingDataContentType = null, string name = null, string description = null, string modelVersion = null, string workspaceId = null, string versionDescription = null)
public DetailedResponse<ClassificationsModel> CreateClassificationsModel(string language, System.IO.MemoryStream trainingData, string trainingDataContentType = null, string name = null, string description = null, string modelVersion = null, string workspaceId = null, string versionDescription = null, ClassificationsTrainingParameters trainingParameters = null)
{
if (string.IsNullOrEmpty(Version))
{
Expand Down Expand Up @@ -1222,6 +1224,13 @@ public DetailedResponse<ClassificationsModel> CreateClassificationsModel(string
formData.Add(versionDescriptionContent, "version_description");
}

if (trainingParameters != null)
{
var trainingParametersContent = new StringContent(JsonConvert.SerializeObject(trainingParameters), Encoding.UTF8, HttpMediaType.APPLICATION_JSON);
trainingParametersContent.Headers.ContentType = null;
formData.Add(trainingParametersContent, "training_parameters");
}

IClient client = this.Client;
SetAuthentication();

Expand Down Expand Up @@ -1391,8 +1400,10 @@ public DetailedResponse<ClassificationsModel> GetClassificationsModel(string mod
/// <param name="workspaceId">ID of the Watson Knowledge Studio workspace that deployed this model to Natural
/// Language Understanding. (optional)</param>
/// <param name="versionDescription">The description of the version. (optional)</param>
/// <param name="trainingParameters">Optional classifications training parameters along with model train
/// requests. (optional)</param>
/// <returns><see cref="ClassificationsModel" />ClassificationsModel</returns>
public DetailedResponse<ClassificationsModel> UpdateClassificationsModel(string modelId, string language, System.IO.MemoryStream trainingData, string trainingDataContentType = null, string name = null, string description = null, string modelVersion = null, string workspaceId = null, string versionDescription = null)
public DetailedResponse<ClassificationsModel> UpdateClassificationsModel(string modelId, string language, System.IO.MemoryStream trainingData, string trainingDataContentType = null, string name = null, string description = null, string modelVersion = null, string workspaceId = null, string versionDescription = null, ClassificationsTrainingParameters trainingParameters = null)
{
if (string.IsNullOrEmpty(Version))
{
Expand Down Expand Up @@ -1471,6 +1482,13 @@ public DetailedResponse<ClassificationsModel> UpdateClassificationsModel(string
formData.Add(versionDescriptionContent, "version_description");
}

if (trainingParameters != null)
{
var trainingParametersContent = new StringContent(JsonConvert.SerializeObject(trainingParameters), Encoding.UTF8, HttpMediaType.APPLICATION_JSON);
trainingParametersContent.Headers.ContentType = null;
formData.Add(trainingParametersContent, "training_parameters");
}

IClient client = this.Client;
SetAuthentication();

Expand Down

0 comments on commit e7d0b01

Please sign in to comment.