问题
I am developing a bot which will respond to users query to my private use cases. Similarly i would like to enable bot to answer some of common questions like Weather or directions etc. So i built a own app in Luis and also trying to use Pre-built cortana intents. Sample below
[LuisModel("c413b2ef-382c-45bd-8ff0-f76dad0e2a821", "697asfc173ce6f40aca4c99e7d38assad6cad")]
public class myClass: LuisDialog<T>
{
}
This will only accept either Cortana Intents or my own Intents depends on subscription id and key.
How can i use both the Luis models in my Class? Please help
回答1:
Around 20 days ago, they updated the LuisDialog to support multiple LuisModel and ILuisService instances (check this commit). The change was already released in NuGet 1.2.4.
回答2:
My Bot will answer different usecases. So i have to use multiple classes for all each usecase. Use of this code is, we can write our task(anotated with Intents) in multiples classes.
I found solution by overriding the Handler Method of LuisDialog
as below. My Baseform
inherits the LuisDialog
class. All other classes which have intents will inherit my BaseForm
protected override IDictionary<string, IntentActivityHandler> GetHandlersByIntent()
{
var classCollection = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(assembly => assembly.GetTypes())
.Where(type => type.IsSubclassOf(typeof(BaseForm)));
List<KeyValuePair<string, IntentActivityHandler>> handler = new List<KeyValuePair<string, IntentActivityHandler>>();
foreach (var item in classCollection)
{
handler.AddRange(MyLuisDialog.EnumerateHandlers(Activator.CreateInstance(item)).ToList());
}
return handler.ToDictionary(kv => kv.Key, kv => kv.Value);
}
in the code there is EnumerateHandlers
method which is just a copy of the same from Luis Dialog sdk.
来源:https://stackoverflow.com/questions/38222920/how-to-integrate-multiple-luis-model-to-bot-framework