Passing model and subscription key to a LuisDialog other than via an attribute

跟風遠走 提交于 2019-12-10 11:14:54

问题


I am writing a bot that can speak two languages. Therefore I need to use two separate LUIS apps (one for each language).

The LuisDialog in the Bot Framework is initialized like this (example from Microsoft):

[LuisModel("c413b2ef-382c-45bd-8ff0-f76d60e2a821", "6d0966209c6e4f6b835ce34492f3e6d9")]
[Serializable]
public class SimpleAlarmDialog : LuisDialog<object>
{

However, I need to use a dynamic app ID and subscription key depending on the language of the user that I have determined.

All the methods, intents etc in the two LUIS apps are the same.

Attributes in C# cannot be dynamic.

What is another way that I can dynamically pass the app and subscription key to a LuisDialog instead of hardcoding them?


回答1:


You will have to register your LuisModelAttribute in the Autofac container. You can take a look here at how that was done in the AlarmBot sample from the BotBuilder repository




回答2:


I solved the issue by slightly changing the approach. You can actually decorate the class with two or more LuisModel attributes and the bot framework will query all of them at the same time.



来源:https://stackoverflow.com/questions/39244030/passing-model-and-subscription-key-to-a-luisdialog-other-than-via-an-attribute

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!