男はこれに問題があります。Luis の助けを借りて単純なボットを作成しようとしています。ボットを作成して Azure でホストすることができました。また、LUIS とエンティティでインテントを作成しました。私はいくつかの発話を作成しましたが、その側は正常に機能しています。
次に、LuisDialogによって c# で作成しました。Azure でCognitive Services APIサブスクリプションを作成する必要があり、 LuisDialogに生成された 2 つのキーにコピーしました。
私のダイアログは次のようになります。
/// <summary>
/// Entities for the PiiiCK LUIS model.
/// </summary>
public static partial class PiiiCK
{
public const string DefaultCategory = "none";
public const string ChooseCategoryIntent = "Choose category";
}
[Serializable]
public class PiiiCKLuisDialog : LuisDialog<object>
{
/// <summary>
/// Tries to find the category
/// </summary>
/// <param name="result">The Luis result</param>
/// <param name="alarm"></param>
/// <returns></returns>
public string TryFindCategory(LuisResult result)
{
// Variable for the title
EntityRecommendation title;
// If we find our enenty, return it
if (result.TryFindEntity(PiiiCK.ChooseCategoryIntent, out title))
return title.Entity;
// Default fallback
return PiiiCK.DefaultCategory;
}
[LuisIntent("")]
public async Task None(IDialogContext context, LuisResult result)
{
// Create our response
var response = $"Sorry I did not understand";
// Post our response back to the user
await context.PostAsync(response);
// Execute the message recieved delegate
context.Wait(MessageReceived);
}
[LuisIntent("Choose category")]
public async Task ChooseCategory(IDialogContext context, LuisResult result)
{
// Get our category
var category = TryFindCategory(result);
// Create our response
var response = $"Found our entity: { category }";
// Post our response back to the user
await context.PostAsync(response);
// Execute the message recieved delegate
context.Wait(MessageReceived);
}
}
プロジェクトを実行し、ボット エミュレーターを使用して応答を取得すると、常に何もヒットしません。発話と全く同じメッセージを書いても。今は、自分が混乱しているからだと思います。Cognitive Serviceアカウントからキーを取得してLUISエンドポイントにリンクした後、別の手順があると思いますが、次に何をすべきか知っている人はいますか?
アップデート
アラーム ボットの例を使用してボットを作成していましたが、混乱していたので (これまで Autofac を使用したことがなかったことが主な理由です)、代わりにシンプルなアラーム ボットの例に切り替えました。私が行う必要がある変更は Global.asax でした:
protected void Application_Start() => GlobalConfiguration.Configure(WebApiConfig.Register);
次のようにLuisModelデータ注釈をPiiiCKluisDialogに追加します。
[Serializable]
[LuisModel("The Luis App Id", "The microsoft cognitive services subscription key")]
public class PiiiCKLuisDialog : LuisDialog<object>
アプリケーションを実行してもエラーは発生せず、Microsoft ボット エミュレーターを MicrosoftAppId とシークレットで使用すると、メッセージを入力できますが、以前と同じように動作します。それは常にNone Luis Intentに行き、「Choose category」には決して行きません。LuisResultは常に nullであることに注意してください...
何か案は?