gpt4 book ai didi

javascript - Watson Conversation node.js 使用 learning_opt_out 创建工作区

转载 作者:搜寻专家 更新时间:2023-10-31 23:45:20 25 4
gpt4 key购买 nike

我正在尝试在 node.js 中使用 learning_opt_out true 创建一个新的 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
}

最佳答案

作为you can seelearning_opt_out 的参数是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.

编辑:

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

例如:

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
}

关于javascript - Watson Conversation node.js 使用 learning_opt_out 创建工作区,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46974865/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com