gpt4 book ai didi

azure - 无法在 Azure 机器人框架中调用 Luis

转载 作者:行者123 更新时间:2023-12-02 07:39:33 24 4
gpt4 key购买 nike

enter image description here我是 dotnet 以及 Luis 和 bot 框架的菜鸟。

我正在尝试让一些机器人示例在我的机器上工作

https://github.com/microsoft/BotBuilder-Samples .

我对这个特别感兴趣

https://github.com/microsoft/BotBuilder-Samples/tree/master/samples/csharp_dotnetcore/13.core-bot

当我运行机器人时,它无法连接到 Luis(请参阅下面的错误消息)。

  • 我通过导入应用程序中提供的意图,在 Luis 中创建并发布了一个应用程序。
  • 我在正确的 JSON 文件中写入了 LuisAppId、LuisAPIKey 和 LuisAPIHostName(见下文)。
  • 我将 dotnet 库添加到项目中:dotnet add package Cognitive.LUIS.Programmatic

然后,我只需在正确的文件夹中使用 cmd“dotnet run” 运行代码即可。

这里是 app.setting JSON。我使用订阅 key 作为 LuisAPIKey,使用应用程序 ID 作为 LuisAppId。

{
"MicrosoftAppId": "",
"MicrosoftAppPassword": "",
"LuisAppId": "2aa2b9c5-#######################7b557",
"LuisAPIKey": "1069d###############4347da9",
"LuisAPIHostName": "westus.api.cognitive.microsoft.com/luis/api/v2.0"
}

该机器人正在我的本地主机上运行。但它就是行不通。

bot : What can I help you with today? Say something like “Book a flight from Paris to Berlin on March 22, 2020”

me : “Please Book a flight from Paris to Berlin on March 22, 2020”

bot :"The bot encounted an error or bug."

bot :"To continue to run this bot, please fix the bot source code"


On the cmd line :
"fail: Microsoft.Bot.Builder.Integration.AspNet.Core.BotFrameworkHttpAdapter[0]
[OnTurnError] unhandled error : Operation returned an invalid status code 'NotFound'
Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Models.APIErrorException: Operation returned an invalid status code 'NotFound'
at Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.Prediction.ResolveWithHttpMessagesAsync(String appId, String query, Nullable`1 timezoneOffset, Nullable`1 verbose, Nullable`1 staging, Nullable`1 spellCheck, String bingSpellCheckSubscriptionKey, Nullable`1 log, Dictionary`2 customHeaders, CancellationToken cancellationToken)
at Microsoft.Azure.CognitiveServices.Language.LUIS.Runtime.PredictionExtensions.ResolveAsync(IPrediction operations, String appId, String query, Nullable`1 timezoneOffset, Nullable`1 verbose, Nullable`1 staging, Nullable`1 spellCheck, String bingSpellCheckSubscriptionKey, Nullable`1 log, CancellationToken cancellationToken)
at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.RecognizeInternalAsync(ITurnContext turnContext, LuisPredictionOptions predictionOptions, Dictionary`2 telemetryProperties, Dictionary`2 telemetryMetrics, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.AI.LUIS\LuisRecognizer.cs:line 345
at Microsoft.Bot.Builder.AI.Luis.LuisRecognizer.RecognizeAsync[T](ITurnContext turnContext, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.AI.LUIS\LuisRecognizer.cs:line 163
at Microsoft.BotBuilderSamples.FlightBookingRecognizer.RecognizeAsync[T](ITurnContext turnContext, CancellationToken cancellationToken) in C:\Users\flabare\botbuilder-samples\samples\csharp_dotnetcore\13.core-bot\FlightBookingRecognizer.cs:line 38
at Microsoft.BotBuilderSamples.Dialogs.MainDialog.ActStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) in C:\Users\flabare\botbuilder-samples\samples\csharp_dotnetcore\13.core-bot\Dialogs\MainDialog.cs:line 67
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog.OnStepAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\WaterfallDialog.cs:line 166
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog.RunStepAsync(DialogContext dc, Int32 index, DialogReason reason, Object result, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\WaterfallDialog.cs:line 188
at Microsoft.Bot.Builder.Dialogs.WaterfallDialog.ResumeDialogAsync(DialogContext dc, DialogReason reason, Object result, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\WaterfallDialog.cs:line 113
at Microsoft.Bot.Builder.Dialogs.DialogContext.EndDialogAsync(Object result, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 196
at Microsoft.Bot.Builder.Dialogs.Prompt`1.ContinueDialogAsync(DialogContext dc, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\Prompts\Prompt.cs:line 147
at Microsoft.Bot.Builder.Dialogs.DialogContext.ContinueDialogAsync(CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 160
at Microsoft.Bot.Builder.Dialogs.ComponentDialog.ContinueDialogAsync(DialogContext outerDc, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\ComponentDialog.cs:line 84
at Microsoft.Bot.Builder.Dialogs.DialogContext.ContinueDialogAsync(CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogContext.cs:line 160
at Microsoft.Bot.Builder.Dialogs.DialogExtensions.RunAsync(Dialog dialog, ITurnContext turnContext, IStatePropertyAccessor`1 accessor, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder.Dialogs\DialogExtensions.cs:line 18
at Microsoft.BotBuilderSamples.Bots.DialogBot`1.OnMessageActivityAsync(ITurnContext`1 turnContext, CancellationToken cancellationToken) in C:\Users\flabare\botbuilder-samples\samples\csharp_dotnetcore\13.core-bot\Bots\DialogBot.cs:line 48
at Microsoft.BotBuilderSamples.Bots.DialogBot`1.OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken) in C:\Users\flabare\botbuilder-samples\samples\csharp_dotnetcore\13.core-bot\Bots\DialogBot.cs:line 36
at Microsoft.Bot.Builder.BotFrameworkAdapter.TenantIdWorkaroundForTeamsMiddleware.OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder\BotFrameworkAdapter.cs:line 995
at Microsoft.Bot.Builder.MiddlewareSet.ReceiveActivityWithStatusAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder\MiddlewareSet.cs:line 55
at Microsoft.Bot.Builder.BotAdapter.RunPipelineAsync(ITurnContext turnContext, BotCallbackHandler callback, CancellationToken cancellationToken) in d:\a\1\s\libraries\Microsoft.Bot.Builder\BotAdapter.cs:line 167"

正如我所提到的,我对此很陌生,因此对上述内容的任何见解将不胜感激!

最佳答案

问题出在您的 appsettings.json 中。您只需将 LuisAPIHostName 设为 westus.api.cognitive.microsoft.com。如果这不起作用,请尝试 westus。该示例经常更改,一旦 LUIS 发布其新的 API 端点,我们计划在所有示例和文档中对其进行标准化。

Here's the instructions in the Sample README

Here's a Pull Request noting how common this issue is

编辑:正如@vikasramereddi 下面提到的,您还需要确保您的 LUIS 应用发布到 Production 而不是 Staging。

关于azure - 无法在 Azure 机器人框架中调用 Luis,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58540829/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com