Reputation: 101
I'm trying to create a new watson-conversation workspace with learning_opt_out true
in node.js.
The following code creates the workspace, but learning_opt_out
is still false
.
Can you help?
var watson = require("watson-developer-cloud");
var conversation = new watson.ConversationV1({
username: 'user',
password: 'password',
url: 'https://gateway-fra.watsonplatform.net/conversation/api/',
version_date: '2017-05-26'
});
var workspace = {
name: 'API test',
description: 'Example workspace created via API.',
language: 'de',
learning_opt_out: 'true'
};
conversation.createWorkspace(workspace, function(err, response) {
if (err) {
console.error(err);
} else {
console.log(JSON.stringify(response, null, 2));
}
});
Running this code creates the following output:
{
"name": "API test",
"created": "2017-10-27T12:16:11.170Z",
"updated": "2017-10-27T12:16:11.170Z",
"language": "de",
"metadata": null,
"description": "Example workspace created via API.",
"workspace_id": "xxx",
"learning_opt_out": false
}
Upvotes: 3
Views: 242
Reputation: 5330
As you can see, the parameter for learning_opt_out
is boolean:
learning_opt_out (boolean, optional): Whether training data from the workspace can be used by IBM for general service improvements. true indicates that workspace training data is not to be used.
EDIT:
After saw more about this question and the parameter learning_opt_out, I found the answer, you need to set one header
inside your call for Conversation service and your username
and password
:
For example:
var watson = require("watson-developer-cloud");
var conversation = new watson.ConversationV1({
username: 'user',
password: 'pass',
url: 'https://gateway-fra.watsonplatform.net/conversation/api/',
version_date: '2017-05-26',
//X-WDC-PL-OPT-OUT: true
headers: {
'X-Watson-Learning-Opt-Out': true
}
});
var workspace = {
name: 'API test',
description: 'Example workspace created via API.',
language: 'de',
//'X-WDC-PL-OPT-OUT': true
};
conversation.createWorkspace(workspace, function(err, response) {
if (err) {
console.error(err);
} else {
console.log(JSON.stringify(response, null, 2));
}
});
And the result:
{
"name": "API test",
"created": "2017-11-03T12:16:08.025Z",
"updated": "2017-11-03T12:16:08.025Z",
"language": "de",
"metadata": null,
"description": "Example workspace created via API.",
"workspace_id": "c143cfd2-2350-491e-bc58-b9debf06e03f",
"learning_opt_out": true
}
Upvotes: 3