gpt4 book ai didi

c# - 在提示用户提及缺少的实体后,我如何使用 luis 操作绑定(bind)来触发意图

转载 作者:太空宇宙 更新时间:2023-11-03 19:43:15 25 4
gpt4 key购买 nike

这篇文章与 C#(.Net) 中的 bot 框架相关

所以我想知道如果我对用户的预期话语是:

“显示 3 月 3 日开始的项目”

但用户错过了日期实体并写入

“显示开始的项目”

现在我想提示用户输入日期(这是缺少的实体),请提及日期。

然后现在就简单地运行意图。

哪种方法是推进它的最佳方法?

最佳答案

在Nicolas R的回复中,他分享了实现你的要求的思路和方法,你可以引用一下。

此外,您还可以引用以下示例代码,在达到特定意图和缺少所需实体时提示提供日期。

[Serializable]
public class BasicLuisDialog : LuisDialog<object>
{

string bdate;
public BasicLuisDialog() : base(new LuisService(new LuisModelAttribute(
"{ID_here}",
"{subscriptionKey_here}",
domain: "westus.api.cognitive.microsoft.com")))
{
}

//....
//for other intents

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

if (result.Entities.Count == 0)
{
PromptDialog.Text(
context: context,
resume: ResumeGetDate,
prompt: "Please enter the date",
retry: "Please try again.");
}
else
{
await this.ShowLuisResult(context, result);
}


}

public async Task ResumeGetDate(IDialogContext context, IAwaitable<string> mes)
{
bdate = await mes;

await context.PostAsync($"You reached GetProjectInfo intent. And you entered the date: {bdate}");

context.Wait(MessageReceived);
}


private async Task ShowLuisResult(IDialogContext context, LuisResult result)
{
await context.PostAsync($"You have reached {result.Intents[0].Intent}. You said: {result.Query}");
context.Wait(MessageReceived);
}
}

测试结果:

enter image description here

关于c# - 在提示用户提及缺少的实体后,我如何使用 luis 操作绑定(bind)来触发意图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49795141/

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