3

我正在尝试learning_opt_out true在 node.js中创建一个新的 watson-conversation 工作区。以下代码创建了工作区,但learning_opt_out仍然是false.

你能帮我吗?

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));
  }
 });

运行此代码会创建以下输出:

{
  "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
}
4

1 回答 1

3

您所见,参数为learning_opt_out布尔

learning_opt_out(布尔型,可选):IBM 是否可以使用来自工作区的训练数据来改进一般服务。true 表示不使用工作区训练数据。

编辑:

在看到更多关于这个问题和参数 learning_opt_out 之后,我找到了答案,你需要header在你的通话中设置一个对话服务和你的usernameand password

例如:

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));
  }
});

结果:

{
  "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
}
于 2017-10-27T22:14:34.960 回答