Skip to content

Commit e7d0b01

Browse files
committed
feat(nlu): add new parameter to create/updateClassificationsModel
1 parent 495295f commit e7d0b01

File tree

3 files changed

+76
-7
lines changed

3 files changed

+76
-7
lines changed

src/IBM.Watson.NaturalLanguageUnderstanding.v1/INaturalLanguageUnderstandingService.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2019, 2021.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -35,10 +35,10 @@ public partial interface INaturalLanguageUnderstandingService
3535
DetailedResponse<CategoriesModel> GetCategoriesModel(string modelId);
3636
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);
3737
DetailedResponse<DeleteModelResults> DeleteCategoriesModel(string modelId);
38-
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);
38+
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);
3939
DetailedResponse<ClassificationsModelList> ListClassificationsModels();
4040
DetailedResponse<ClassificationsModel> GetClassificationsModel(string modelId);
41-
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);
41+
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);
4242
DetailedResponse<DeleteModelResults> DeleteClassificationsModel(string modelId);
4343
}
4444
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* (C) Copyright IBM Corp. 2022.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*
16+
*/
17+
18+
using Newtonsoft.Json;
19+
20+
namespace IBM.Watson.NaturalLanguageUnderstanding.v1.Model
21+
{
22+
/// <summary>
23+
/// Optional classifications training parameters along with model train requests.
24+
/// </summary>
25+
public class ClassificationsTrainingParameters
26+
{
27+
/// <summary>
28+
/// Model type selector to train either a single_label or a multi_label classifier.
29+
/// </summary>
30+
public class ModelTypeEnumValue
31+
{
32+
/// <summary>
33+
/// Constant SINGLE_LABEL for single_label
34+
/// </summary>
35+
public const string SINGLE_LABEL = "single_label";
36+
/// <summary>
37+
/// Constant MULTI_LABEL for multi_label
38+
/// </summary>
39+
public const string MULTI_LABEL = "multi_label";
40+
41+
}
42+
43+
/// <summary>
44+
/// Model type selector to train either a single_label or a multi_label classifier.
45+
/// Constants for possible values can be found using ClassificationsTrainingParameters.ModelTypeEnumValue
46+
/// </summary>
47+
[JsonProperty("model_type", NullValueHandling = NullValueHandling.Ignore)]
48+
public string ModelType { get; set; }
49+
}
50+
51+
}

src/IBM.Watson.NaturalLanguageUnderstanding.v1/NaturalLanguageUnderstandingService.cs

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* (C) Copyright IBM Corp. 2017, 2022.
2+
* (C) Copyright IBM Corp. 2022.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,7 +16,7 @@
1616
*/
1717

1818
/**
19-
* IBM OpenAPI SDK Code Generator Version: 3.46.0-a4e29da0-20220224-210428
19+
* IBM OpenAPI SDK Code Generator Version: 3.53.0-9710cac3-20220713-193508
2020
*/
2121

2222
using System.Collections.Generic;
@@ -1150,8 +1150,10 @@ public DetailedResponse<DeleteModelResults> DeleteCategoriesModel(string modelId
11501150
/// <param name="workspaceId">ID of the Watson Knowledge Studio workspace that deployed this model to Natural
11511151
/// Language Understanding. (optional)</param>
11521152
/// <param name="versionDescription">The description of the version. (optional)</param>
1153+
/// <param name="trainingParameters">Optional classifications training parameters along with model train
1154+
/// requests. (optional)</param>
11531155
/// <returns><see cref="ClassificationsModel" />ClassificationsModel</returns>
1154-
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)
1156+
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)
11551157
{
11561158
if (string.IsNullOrEmpty(Version))
11571159
{
@@ -1222,6 +1224,13 @@ public DetailedResponse<ClassificationsModel> CreateClassificationsModel(string
12221224
formData.Add(versionDescriptionContent, "version_description");
12231225
}
12241226

1227+
if (trainingParameters != null)
1228+
{
1229+
var trainingParametersContent = new StringContent(JsonConvert.SerializeObject(trainingParameters), Encoding.UTF8, HttpMediaType.APPLICATION_JSON);
1230+
trainingParametersContent.Headers.ContentType = null;
1231+
formData.Add(trainingParametersContent, "training_parameters");
1232+
}
1233+
12251234
IClient client = this.Client;
12261235
SetAuthentication();
12271236

@@ -1391,8 +1400,10 @@ public DetailedResponse<ClassificationsModel> GetClassificationsModel(string mod
13911400
/// <param name="workspaceId">ID of the Watson Knowledge Studio workspace that deployed this model to Natural
13921401
/// Language Understanding. (optional)</param>
13931402
/// <param name="versionDescription">The description of the version. (optional)</param>
1403+
/// <param name="trainingParameters">Optional classifications training parameters along with model train
1404+
/// requests. (optional)</param>
13941405
/// <returns><see cref="ClassificationsModel" />ClassificationsModel</returns>
1395-
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)
1406+
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)
13961407
{
13971408
if (string.IsNullOrEmpty(Version))
13981409
{
@@ -1471,6 +1482,13 @@ public DetailedResponse<ClassificationsModel> UpdateClassificationsModel(string
14711482
formData.Add(versionDescriptionContent, "version_description");
14721483
}
14731484

1485+
if (trainingParameters != null)
1486+
{
1487+
var trainingParametersContent = new StringContent(JsonConvert.SerializeObject(trainingParameters), Encoding.UTF8, HttpMediaType.APPLICATION_JSON);
1488+
trainingParametersContent.Headers.ContentType = null;
1489+
formData.Add(trainingParametersContent, "training_parameters");
1490+
}
1491+
14741492
IClient client = this.Client;
14751493
SetAuthentication();
14761494

0 commit comments

Comments
 (0)