我需要获取 Watson 中某个问题的可用选项对话 API?
例如,我有一个对话应用程序,在某些情况下,您需要为用户提供一个列表以从中选择一个选项。
因此,我正在寻找一种方法来获取特定问题的可用回复选项。
最佳答案
我无法回答 NPM 部分,但您可以通过将 alternate_intents
设置为 true
来获取前 10 个可能答案的列表。例如。
{
"context":{
"conversation_id":"cbbea7b5-6971-4437-99e0-a82927607079",
"system":{
"dialog_stack":["root"
],
"dialog_turn_counter":1,
"dialog_request_counter":1
}
},
"alternate_intents":true,
"input":{
"text":"Is it hot outside?"
}
}
这最多会返回前十个答案。如果意图数量有限,它只会显示它们。
您的 JSON 响应的一部分将具有如下内容:
"intents":[{
"intent":"temperature",
"confidence":0.9822100598134365
},
{
"intent":"conditions",
"confidence":0.017789940186563623
}
这不会从节点获得输出文本。因此,您需要将答案存储在其他地方以供交叉引用。
另请注意,仅仅因为它位于列表中,并不意味着它是向最终用户提供的有效答案。需要考虑置信水平。
置信度也不像正常置信度那样工作。您需要确定您的上限和下限。我detail this briefly here 。
Unlike earlier versions of WEA, the confidence is relative to the number of intents you have. So the quickest way to find the lowest confidence is to send a really ambiguous word.
These are the results I get for determining temperature or conditions.
treehouse = conditions / 0.5940327076534431
goldfish = conditions / 0.5940327076534431
music = conditions / 0.5940327076534431
See a pattern?🙂 So the low confidence level I will set at 0.6. Next is to determine the higher confidence range. You can do this by mixing intents within the same question text. It may take a few goes to get a reasonable result.
These are results from trying this (C = Conditions, T = Temperature).
hot rain = T/0.7710267712183176, C/0.22897322878168241
windy desert = C/0.8597747113239446, T/0.14022528867605547
ice wind = C/0.5940327076534431, T/0.405967292346557
I purposely left out high confidence ones. In this I am going to go with 0.8 as the high confidence level.
关于npm - Watson 对话 api 中的问题选项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39678301/