Luis 技能识别器枚举错误 - 需要使用更改更新 .luis 和 .qna 文件

Luis Skill Recognizer Enumerations Error - Need to Update .luis & .qna files with changes

我有一个虚拟助手调度,可以将控制权交给使用 QnA maker 的知识库技能。我最终将拥有多个 QnA 知识库,但现在,我 运行 正在解决第一个工作的问题。我已经 created/edited、训练和 publised/released QnA maker KB、知识库技能 Luis 模型和虚拟助手的调度模型。

当我的知识库技能的 Luis 模型 returns 意图成功发送技能后会生成异常。我有一个 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 命令来将新发布的意图拉入代码,或者我用我的新技能手动更新意图枚举是否正确?我是否需要将助手 and/or 技能从我的本地计算机重新发布到 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);
    }
}

LUISGen 是 creates/updates 识别器 class (KnowledgeBaseSkillLuis) 的工具。

How do I pull the updated models into my local environment? Do I need to run a botskills or dispatch command to pull the newly published intents into the code, or was I correct in manually updating the intent enumeration with my new skill?

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

Do I need to re-publish the Assistant and/or Skill from my local machine to Azure to get them?

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

更多信息:

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

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