【问题标题】:Luis Skill Recognizer Enumerations Error - Need to Update .luis & .qna files with changesLuis 技能识别器枚举错误 - 需要更新 .luis 和 .qna 文件并进行更改
【发布时间】:2020-03-22 06:33:15
【问题描述】:

我有一个虚拟助理调度,它将控制权交给使用 QnA maker 的知识库技能。我最终将拥有几个 QnA 知识库,但现在,我遇到了第一个工作的问题。我已经创建/编辑、训练和发布/发布了 QnA 创客知识库、知识库技能 Luis 模型和虚拟助手的调度模型。

当我的知识库技能的 Luis 模型返回意图时,成功分发技能后会生成异常。我有一个 switch 语句,最终将指向与用户问题对应的知识库。

text: "Exception Message: Could not convert string 'helpdesk_faq' to dictionary key type
'Luis.KnowledgeBaseSkillLuis+Intent'. Create a TypeConverter to convert 
from the string to the key type object.

我用新意图的名称更新了我的KnowledgeBaseSkillLuis.cs 意图枚举(如下所示),但我想知道我是否不需要这样做。我注意到我的 KnowledgeBaseSkill.luisFaq.qna 文件没有更新的更改;这引出了我的问题-

如何将更新的模型拉入我的本地环境?我是否需要运行 botskills 或 dispatch 命令来将新发布的意图拉入代码中,或者我是否正确地使用我的新技能手动更新意图枚举?我是否需要将助手和/或技能从本地计算机重新发布到 Azure 以获取它们?

我已经阅读了这些文章,但我很难利用它们:

// Full file included lower in the post
public enum Intent
{
    Sample,
    q_Faq,
    helpdesk_faq, // Newly created intent (others were auto generated with Deploy scripts provided in skill template
    None
};

MainDialog.cs:

...
switch (intent)
{
    case KnowledgeBaseSkillLuis.Intent.Sample:
        {
            await innerDc.BeginDialogAsync(_sampleDialog.Id);
            break;
        }
    case KnowledgeBaseSkillLuis.Intent.helpdesk_faq:
        {
            cognitiveModels.QnAServices.TryGetValue("Faq", out var qnaService); // "Faq" is the name of the QnA maker knowledge base. 

            if (qnaService == null)
            {
                await innerDc.Context.SendActivityAsync("I'm having issues looking up the information for you.");
                throw new Exception("QnA Maker Service could not be found in the Bot Services Configuration."); 
            }
            else
            {
                var answers = await qnaService.GetAnswersAsync(innerDc.Context, null, null);

                if (answers != null && answers.Count() > 0)
                {
                    await innerDc.Context.SendActivityAsync(answers[0].Answer);
                }
                else
                {
                    await innerDc.Context.SendActivityAsync(_templateEngine.GenerateActivityForLocale("ConfusedMessage"));
                }
            }
            break;
        }
    case KnowledgeBaseSkillLuis.Intent.None:
    default:
        {
            // intent was identified but not yet implemented
            await innerDc.Context.SendActivityAsync(_templateEngine.GenerateActivityForLocale("UnsupportedMessage"));
            break;
        }
}
...

KnowledgeBaseSkillLuis.cs

 public class KnowledgeBaseSkillLuis : IRecognizerConvert
{
    public string Text;
    public string AlteredText;
    public enum Intent
    {
        Sample,
        q_Faq,
        helpdesk_faq,
        None
    };
    public Dictionary<Intent, IntentScore> Intents;

    public class _Entities
    {

        // Instance
        public class _Instance
        {
        }
        [JsonProperty("$instance")]
        public _Instance _instance;
    }
    public _Entities Entities;

    [JsonExtensionData(ReadData = true, WriteData = true)]
    public IDictionary<string, object> Properties { get; set; }

    public void Convert(dynamic result)
    {
        var app = JsonConvert.DeserializeObject<KnowledgeBaseSkillLuis>(JsonConvert.SerializeObject(result));
        Text = app.Text;
        AlteredText = app.AlteredText;
        Intents = app.Intents;
        Entities = app.Entities;
        Properties = app.Properties;
    }

    public (Intent intent, double score) TopIntent()
    {
        Intent maxIntent = Intent.None;
        var max = 0.0;
        foreach (var entry in Intents)
        {
            if (entry.Value.Score > max)
            {
                maxIntent = entry.Key;
                max = entry.Value.Score.Value;
            }
        }
        return (maxIntent, max);
    }
}

【问题讨论】:

    标签: botframework azure-language-understanding qnamaker


    【解决方案1】:

    LUISGen 是在您的情况下创建/更新识别器类 (KnowledgeBaseSkillLuis) 的工具。

    如何将更新的模型拉入我的本地环境?我是否需要运行 botskills 或 dispatch 命令来将新发布的意图拉入代码中,或者我是否正确地使用我的新技能手动更新了意图枚举?

    您应该使用update_cognitive_models.ps1 脚本(在Deployments\Scripts 文件夹中)和RemoteToLocal 开关。这将从在线模型更新到本地文件。

    我是否需要从本地重新发布助手和/或技能 机器到 Azure 来获取它们?

    使用脚本更新后,您应该重新发布新代码(用于更新的 KnowledgeBaseSkillLuis)。

    更多信息:

    https://microsoft.github.io/botframework-solutions/virtual-assistant/handbook/deployment-scripts/#scripts

    https://microsoft.github.io/botframework-solutions/virtual-assistant/handbook/devops/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-31
      • 2019-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多