代码之家  ›  专栏  ›  技术社区  ›  Leo

Watson对话节点。js使用learning\u opt\u out创建工作区

  •  3
  • Leo  · 技术社区  · 8 年前

    learning_opt_out true 在节点中。js。 以下代码创建了工作区,但是 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
    }
    
    1 回复  |  直到 7 年前
        1
  •  3
  •   Sayuri Mizuguchi    8 年前

    you can see ,参数 learning_opt_out 是 布尔型

    IBM可以使用workspace进行一般服务改进。真的 指示不使用工作区训练数据。

    在看到关于这个问题和参数learning\u opt\u out的更多信息后,我 found 答案是,你需要设定一个 header 在通话服务和 username 和 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
    }