首页 文章

机器人配置不包含id为“basic-bot-LUIS”的服务类型`luis` . (.NET核心)

提问于
浏览
2

当我尝试创建一个Basic Bot时

  • 用于VS 4.0.6.6版的Bot Builder V4 SDK模板

  • VS 2017社区

  • .NET核心2.1

  • 更新NuGet Manager中的包(除了 Microsoft.AspNetCore.All ,因为它需要.NET 2.2预览)

构建和运行后 . 我尝试使用Bot Emulator,打开.bot配置文件 . 当我向bot发送消息时 . 我在控制台上收到错误

Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]
      An unhandled exception has occurred while executing the request
System.InvalidOperationException: The bot configuration does not contain a service type of `luis` with the id `basic-bot-LUIS`.
   at BotBasicV4.BasicBot..ctor(BotServices services, UserState userState, ConversationState conversationState, ILoggerFactory loggerFactory) in D:\workspace\AI_INTERN_BOT\BotBasicV4\BotBasicV4\BasicBot.cs:line 61
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Microsoft.Bot.Builder.Integration.AspNet.Core.Handlers.BotMessageHandlerBase.HandleAsync(HttpContext httpContext) in D:\a\1\s\libraries\integration\Microsoft.Bot.Builder.Integration.AspNet.Core\BotMessageHandlerBase.cs:line 63
   at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[0]

Bot Builder v4(4.0.6.6)的 Echo Bot V4 建筑没问题 . 但是 Basic Bot 在我第一次运行时遇到错误(没有修改任何东西)

有人可以向我解释为什么会这样吗?

4 回答

  • 0

    阅读生成的项目中的README.md文件 . 您将找到有关设置将由机器人使用的LUIS应用程序的一些指导 . 您需要设置LUIS,然后在BotConfiguration.bot的“services”数组中添加这样的配置

    {
      "type": "luis",
      "name": "basic-bot-LUIS",
      "region": "westus",
      "appId": "<your app id>",
      "authoringKey": "<your authoring key>",
      "version": "0.1",
      "id": "basic-bot-LUIS"
    }
    
  • 1

    我阅读了之前的所有答案,但仍然发现README.MD文件缺乏一点清晰度,我需要做什么,以便让Bot Builder Basic Bot V4项目开箱即用 .

    所以,这就是BotConfiguration.bot文件的样子,现在它编译并运行:

    {
      "name": "Bot_Builder_Basic_Bot_V4",
      "services": [
        {
          "type": "endpoint",
          "name": "development",
          "endpoint": "http://localhost:3978/api/messages",
          "appPassword": "",
          "version": "0.1",
          "id": "1"
        },
        {
          "type": "luis",
          "name": "basic-bot-LUIS",
          "region": "westus",
          "appId": "<APP ID>",
          "authoringKey": "<AUTHORING KEY>",
          "version": "0.1",
          "id": "basic-bot-LUIS"
        }
      ],
      "padlock": "",
      "version": "2.0"
    }
    

    在创建帐户和创建应用程序后,以下值来自https://www.luis.ai站点:

    • < AUTHORING KEY > < - 单击屏幕右上角的名称,然后单击“设置” .

    • < APP ID > < - 单击顶部导航栏中的'My apps',然后单击应用程序,然后单击'Manage' .

    更新:这是Microsoft Docs页面的链接,有关于此的更多信息:enter link description here

  • 2

    Visual Studio模板无法创建所需的文件:BasicBot.bot导致此错误 . 请注意,拉德克的评论仍然有效;我需要两个更改才能工作(即向BotConfiguration.bot添加一个部分) .

  • 0

    Radek和markau的评论是正确的,所以为了解决这个问题,我将该部分添加到Radek评论的BotConfiguration.bot中,并使用以下代码在解决方案的根目录中创建了一个BasicBot.bot文件 .

    {
      "name": "basic-bot-LUIS",
      "services": [
        {
          "type": "luis",
          "name": "basic-bot-LUIS",
          "region": "westus",
          "appId": "<your appID>",
          "authoringKey": "<your authoringKey>",
          "version": "0.1",
          "id": "basic-bot-LUIS"
        }
      ],
      "padlock": "",
      "version": "2.0"
    }
    

相关问题