我有一个虚拟助理调度员,可以将控制权转交给使用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.luis
和Faq.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);
}
}
LUISGen
是根据您的情况创建/更新识别器类(KnowledgeBaseSkillLuis
)的工具。
如何将更新的模型放入本地环境?我是否需要运行botskills或dispatch命令以将新发布的意图拖入代码中,还是使用我的新技能手动更新意图枚举是否正确?
您应通过update_cognitive_models.ps1
开关使用Deployments\Scripts
脚本(在RemoteToLocal
文件夹中)。这将从在线模型更新为本地文件。
我是否需要从本地重新发布助手和/或技能机到Azure获取它们?
一旦使用脚本更新了新代码(对于更新的KnowledgeBaseSkillLuis,则应重新发布。)>
更多信息:
https://microsoft.github.io/botframework-solutions/virtual-assistant/handbook/devops/