![](/img/trans.png)
[英]How to integrate multiple Luis languge models in single Luis Dialog in Bot Framework (C# SDK)
[英]Multiple LUIS models from config
我通过属性在1个LUIS对话框中使用2个LUIS模型
[LuisModel("model1", "")]
[LuisModel("model2", "")]
[Serializable]
public class LuisDialog
我需要从配置文件中获取这些模型。 在Autofac中,我只能注册1
builder.Register(c => new LuisModelAttribute("model1", ""))...
如何从配置中设置多个Luis模型?
我认为这不会起作用,因为LuisModel
被注入到您正在注册的LuisService
(这可能是您配置中的下一行),而LuisService只是期望单个模型而不是它们的数组。
我认为这可行的方式是,不应该将模型注册到Autofac
容器,而应该注册多个LuisService
,为每个模型定义构造函数的模型参数的值(参见本文 )。
这样,当您解决基于LuisDialog
的对话框时,它将注入多个ILuisService
(请参阅此内容 ),因为它准备接收一组服务。
我没试过这个,但你可以看看这样的东西是否有效:
var model1 = new LuisModelAttribute("model1", "");
var model2 = new LuisModelAttribute("model2", "");
builder.RegisterType<LuisService>()
.WithParameter("model", model1)
.Keyed<ILuisService>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance(); or // .InstancePerLifetimeScope()
builder.RegisterType<LuisService>()
.WithParameter("model", model2)
.Keyed<ILuisService>(FiberModule.Key_DoNotSerialize)
.AsImplementedInterfaces()
.SingleInstance(); or // .InstancePerLifetimeScope()
或者,您可以使用RegisterInstance
并将LuisService
的实例注册到其特定模型。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.