Luis Skill Recognizer枚举错误-需要通过更改来更新.luis和.qna文件

我有一个虚拟助理调度员,可以将控制权转交给使用QnA制造商的知识库技能。我最终将拥有几个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,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);
    }
}
longfeimicu 回答:Luis Skill Recognizer枚举错误-需要通过更改来更新.luis和.qna文件

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/

本文链接:https://www.f2er.com/3026508.html

大家都在问