我有一个虚拟助理调度,它将控制交给使用QnA maker的知识库技能。我最终会有几个QnA知识库,但现在,我遇到了第一个问题。我创建/编辑、培训并发布/发布了QnA maker KB、知识库技能Luis模型和虚拟助理的调度模型。
当我的知识库技术的Luis模型返回意图时,将在成功的技能分派之后生成异常。我有一个开关语句,它将最终指向与用户问题相对应的知识库。
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.luis
和Faq.qna
文件没有更新的更改;这就引出了我的问题-
如何将更新的模型拖到本地环境中?是否需要运行僵尸技能或调度命令将新发布的意图导入代码,还是使用新技能手动更新意图枚举是否正确?我是否需要重新发布助理和/或技能从我的本地机器到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);
}
}
发布于 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/devops/
https://stackoverflow.com/questions/59057723
复制相似问题