C# LUIS Chatbot 从 LuisResult 中提取所有意图

C# LUIS Chatbot extract all intents from LuisResult

我有一个与 LUIS 连接的聊天机器人,我知道虽然对话只会进入具有最高匹配意图的对话,但是我仍然想显示其余意图的分数,是吗?一种方法来做到这一点? 我已经有

[LuisModel("XXXX", "XXXX", Verbose = true)]

到目前为止,这是我正在使用的:

    [LuisIntent("")]
    [LuisIntent("None")]
    public async Task None(IDialogContext context, LuisResult result)
    {

        string allIntents = "";



        //Loop throught all intents found in JSON
        foreach (var foundIntent in result.Intents)
        {
            allIntents += ("Intent: " + foundIntent.Intent + "\n\n" + "Score: " + foundIntent.Score + "\n\n");
        }
        await context.PostAsync(allIntents);
        context.Wait(this.MessageReceived);
    }

我的 JSON 就像

{
  "query": "hey there",
  "topScoringIntent": {
  "intent": "None",
  "score": 0.17292054
  },
  "intents": [
    {
      "intent": "None",
      "score": 0.17292054
    },
    {
      "intent": "intentSearch",
      "score": 0.122199811
    },
    {
      "intent": "fromIntent",
      "score": 0.0327471271
    },
    {
      "intent": "goWithIntent",
      "score": 0.010828237
    }
  ],
  "entities": []
}

但是我的机器人只会 return none 意图及其分数。有没有办法 return 在一个对话框中包含所有意图?

编辑:答案在某种程度上对新项目有效,我不知道为什么

您必须像这样在 LuisModelAttribute 中将详细标志设置为 true:

[LuisModel("e7a9c2d5-0b92-47d3-9d73-xxxxxxxxxxxx",
"4941fa348c49494db1e8e8xxxxxxxxxx", Verbose = true)]

这是获取所有意图的代码,您可以从中获取分数

    [LuisIntent("greeting")]
    public async Task Greeting(IDialogContext context, LuisResult result)
    {
        string allIntents = "";
        //Loop throught all intents found in JSON
        foreach (var foundIntent in result.Intents)
        {
            allIntents += ("Intent: " + foundIntent.Intent + "\n\n" + "Score: " + foundIntent.Score + "\n\n");
        }
        await context.PostAsync(allIntents);

        context.Wait(this.MessageReceived);
    }

使用这段代码我得到了这个结果: