我有一个虚拟助理调度员,可以将控制权转交给使用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,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);
}
}