繁体   English   中英

Watson Conversation node.js使用learning_opt_out创建工作空间

[英]Watson Conversation node.js create workspace with learning_opt_out

我正在尝试在node.js中创建一个新的watson-conversation工作区,其中learning_opt_out true 以下代码创建工作空间,但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
}

您所见learning_opt_out的参数是boolean

learning_opt_out(boolean,optional):IBM是否可以使用来自工作空间的培训数据来改进常规服务。 true表示不使用工作空间训练数据。

编辑:

在看了更多关于这个问题和参数learning_opt_out之后,我找到了答案,你需要在你的Conversation服务调用中设置一个header以及你的usernamepassword

例如:

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
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM