gpt4 book ai didi

node.js - 我无法从 Watson Discovery 收到任何答复

转载 作者:行者123 更新时间:2023-11-30 09:28:04 25 4
gpt4 key购买 nike

我正在使用 Watson Assistant 和 Discovery 的聊天机器人中工作,但我无法从 Discovery 收到任何答复这是我使用发现意图时的对话框 enter image description here

这是我设计的 UI 的输出 enter image description here

function updateMessage(res, input, response) {
// if (!response.output) {
// response.output = {};
// } else
if (response.output.action === 'callDiscovery') {
// if you want to use natural_language_query, set here the input from the user like my example:
params.natural_language_query = response.input.text || null;

console.log('Calling discovery');
discovery.query(params, (error, returnDiscovery) => {
if (error) {
next(error);
} else {
console.log('return from discovery: '+returnDiscovery);
//if you want to send all text returned from discovery, discomment these lines
var text;
for (i = 0; i < returnDiscovery.results.length; i++) {
text += returnDiscovery.results[i].text + "<br>";
}
//sending the TEXT returned from discovery results
response.output.text = 'Discovery call with success, check the results: <br>' + text; //results */
//sending the PASSAGES returned from discovery results
response.output.text = 'Discovery call with success, check the results: <br>' + returnDiscovery.passages[0].passage_text; //passageResults
return res.json(response);
};
});
} else if (response.output && response.output.text) {
return res.json(response);
}

}

最佳答案

分词器应该是 lemmatizer.lemmatize 而不是 lemmatizer

 lemmatizer = WordNetLemmatizer()
TFIDF = TfidfVectorizer(tokenizer=lemmatizer.lemmatize,analyzer= 'word',min_df=3,token_pattern=r'(?u)\b[A-Za-z]+\b',stop_words= 'english')

输出

TFIDF.fit_transform(['how are you', 'facing issue','hope this well help you' ])
#o/p
<3x3 sparse matrix of type '<class 'numpy.float64'>'
with 9 stored elements in Compressed Sparse Row format>

关于node.js - 我无法从 Watson Discovery 收到任何答复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56843878/

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