问题
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