gpt4 book ai didi

c# - Microsoft Bot Framework、LUIS 和 Action 参数

转载 作者:太空狗 更新时间:2023-10-29 23:43:47 25 4
gpt4 key购买 nike

我正在尝试使用 LUIS 构建一个机器人,但这比我想象的要难得多。到目前为止,我已经成功地创建了我的 LUIS 应用程序并创建了一个Intent 和一个Entity,并且我创建了一些似乎工作正常的话语 .

然后我创建了我的机器人并将其连接到 Luis。当我测试我的机器人时,它按预期工作。现在是有趣的部分。我想处理参数。在 Luis 上,我向我的Intent 添加了一个 Action :

enter image description here

如您所见,我添加了一个提示。我的机器人中的代码目前如下所示:

/// <summary>
/// Tries to find the category
/// </summary>
/// <param name="result">The Luis result</param>
/// <param name="alarm"></param>
/// <returns></returns>
public string TryFindCategory(LuisResult result)
{

// Variable for the title
EntityRecommendation title;

// If we find our enenty, return it
if (result.TryFindEntity(PiiiCK.Category, out title))
return title.Entity;

// Default fallback
return null;
}

[LuisIntent("Choose category")]
public async Task ChooseCategory(IDialogContext context, LuisResult result)
{

// Get our category
var category = TryFindCategory(result);
var response = "The category you have chosen is not in the system just yet.";

switch (category)
{
case "camera":
response = $"You need help buying a { category }, is this correct?";
this.started = true;
break;
default:
if (!string.IsNullOrEmpty(category)) response = $"Sorry, PiiiCK does not deal with { category.Pluralise() } just yet.";
break;
}

// Post our response back to the user
await context.PostAsync(response);

// Execute the message recieved delegate
context.Wait(MessageReceived);
}

我想你能猜到我要用这个做什么。如果用户键入Help me buy a camera,它将进入Choose category Intent 并选择正确的Entity。但如果他们输入Help me buy,它仍会转到正确的 Intent,但不会有选定的实体。我希望我的机器人看到它并使用我在 LUIS 中创建的 Prompt 中的文本,当用户选择他们的 entity 我希望它返回到 LUIS参数。

我不知道该怎么做,也找不到任何相关教程。任何帮助将不胜感激(甚至链接!)

最佳答案

首先,您需要确保在包含类别的话语中,您将它们标记为类别实体。这只需选择代表您的实体的词,然后在提交您的话语之前点击实际类别即可。

Labeling utterances

这与您添加的操作参数无关。要检查操作参数,您需要浏览实际意图。 IntentRecommendation 有一个 Actions 集合属性;其中包含一个 Parameters 集合属性。

Action parameters

这里要补充一点,在 develop 分支中,BotFramework 团队刚刚添加了对 LUIS v2 API 的支持,并添加了一些全新的功能。

例如,如果您的意图需要参数但未提供这些参数,现在 LuisDialog 将起作用。在那种情况下(这似乎是你的),LuisDialog 将 automatically launch a LuisActionDialog 并使用你在操作参数中定义的提示消息询问用户缺少的参数。

请注意,这还没有发布为 Nuget 包。

关于c# - Microsoft Bot Framework、LUIS 和 Action 参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40593016/

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