首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >路易斯技能识别器数字错误-需要用更改更新.luis和.qna文件

路易斯技能识别器数字错误-需要用更改更新.luis和.qna文件
EN

Stack Overflow用户
提问于 2019-11-26 18:58:58
回答 1查看 65关注 0票数 1

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

当我的知识库技术的Luis模型返回意图时,将在成功的技能分派之后生成异常。我有一个开关语句,它将最终指向与用户问题相对应的知识库。

代码语言:javascript
运行
复制
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文件没有更新的更改;这就引出了我的问题-

如何将更新的模型拖到本地环境中?是否需要运行僵尸技能或调度命令将新发布的意图导入代码,还是使用新技能手动更新意图枚举是否正确?我是否需要重新发布助理和/或技能从我的本地机器到Azure获得他们?

我读过这些文章,但我很难利用它们:

代码语言:javascript
运行
复制
// 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

代码语言:javascript
运行
复制
...
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

代码语言:javascript
运行
复制
 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);
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-12-02 23:00:17

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

如何将更新的模型拖到本地环境中?是否需要运行僵尸技能或调度命令将新发布的意图导入代码,还是使用新技能手动更新意图枚举是否正确?

您应该使用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/

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59057723

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档