Azure 虚拟助理投掷';抱歉,看起来好像出了什么问题';

Azure 虚拟助理投掷';抱歉,看起来好像出了什么问题';,azure,botframework,Azure,Botframework,我已使用Microsoft virtual assistant模板创建了一个虚拟助手。当在模拟器中测试我发送的任何消息时,我都会得到一个“出错的回复” 我对整个bot框架生态系统还不熟悉,现在很难继续 在日志中,我可以看到: [11:26:32]Emulator listening on http://localhost:65233 [11:26:32]ngrok not configured (only needed when connecting to remotely hosted

我已使用Microsoft virtual assistant模板创建了一个虚拟助手。当在模拟器中测试我发送的任何消息时,我都会得到一个“出错的回复”

我对整个bot框架生态系统还不熟悉,现在很难继续

在日志中,我可以看到:

    [11:26:32]Emulator listening on http://localhost:65233
[11:26:32]ngrok not configured (only needed when connecting to remotely hosted bots)
[11:26:32]Connecting to bots hosted remotely
[11:26:32]Edit ngrok settings
[11:26:32]POST201directline.startConversation
[11:26:39]<-messageapplication/vnd.microsoft.card.adaptive
[11:26:39]POST200conversations.replyToActivity
[11:26:54]->messagehi
[11:26:55]<-traceThe given key 'en' was not present in the dictiona...
[11:26:55]POST200conversations.replyToActivity
[11:26:55]<-trace at System.Collections.Generic.Dictionary`2.get_...
[11:26:55]POST200conversations.replyToActivity
[11:26:55]<-messageSorry, it looks like something went wrong.
[11:26:55]POST200conversations.replyToActivity
[11:26:55]POST200directline.postActivity
[11:27:48]->messagehello
[11:27:48]<-traceThe given key 'en' was not present in the dictiona...
[11:27:48]POST200conversations.replyToActivity
[11:27:48]<-trace at System.Collections.Generic.Dictionary`2.get_...
[11:27:48]POST200conversations.replyToActivity
[11:27:48]<-messageSorry, it looks like something went wrong.
[11:27:48]POST200conversations.replyToActivity
[11:27:48]POST200directline.postActivity
[11:26:32]仿真器正在侦听http://localhost:65233
[11:26:32]未配置ngrok(仅当连接到远程托管的机器人时才需要)
[11:26:32]连接到远程托管的机器人程序
[11:26:32]编辑ngrok设置
[11:26:32]POST201directline.startConversation
[11:26:39]留言嗨

[11:26:55]我相信您遇到的问题是
mainload.cs
中以下几行的问题:

var locale = CultureInfo.CurrentUICulture.TwoLetterISOLanguageName;
var cognitiveModels = _services.CognitiveModelSets[locale];
这将尝试使用区域设置(根据从当前线程检索)作为键来访问
cognitivemodels.json
文件中的认知模型

cognitivemodels.json文件中,它应该如下所示:

{
  "cognitiveModels": {
    // This line below here is what could be missing/incorrect in yours
    "en": {
      "dispatchModel": {
        "type": "dispatch",
        "region": "westus",
        ...
      },
      "knowledgebases": [
        {
          "id": "chitchat",
          "name": "chitchat",
          ...
        },
        {
          "id": "faq",
          "name": "faq",
          ...
        },
      ],
      "languageModels": [
        {
          "id": "general",
          "name": "msag-test-va-boten_general",
          "region": "westus",
          ...
        }
      ]
    }
  },
  "defaultLocale": "en-us"
}

en
键位于
cognitiveModels
对象中,代码正试图使用它来检索您的认知模型,因此如果代码中提取的
locale
cognitiveModels.json中的locale键不匹配,那么您将得到字典键错误

编辑

OP遇到的问题是部署失败。我们采取的步骤是:

  • 检查
    Deployment
    文件夹中的
    deploy\u log.txt
    是否存在错误。
    • 如果这个案例是空的——这不是一个好迹象
  • 检查
    Deployment
    文件夹中的
    deploy\u conceptive\u models\u log.txt
    是否存在错误。
    • 出现错误
      错误:找不到模块'C:\Users\dip\u chatterjee\AppData\Roaming\npm\node\u modules\botdispatch\bin\dispatch.js
      • 为了修复此错误,我们按照的步骤5重新安装了所有必需的npm包,然后按照运行部署脚本

您可以在
DefaultAdapter
文件
OnTurnError=async(turnContext,exception)=>
中的以下块中放置断点,当抛出异常时,您的断点将被命中,您可以根据检查异常/堆栈跟踪。也就是说,英语是模板的默认语言,所以它应该是开箱即用的。您可以尝试检查emulator的区域设置(左下角的设置cog)是否设置为en US。我使用的是来自印度的,应该是区域设置,但我的bot托管为westus。。那我下一步该怎么办?我打算只使用英文版本的bot。你能确认你的
cognitivemodels.json
文件中有“en”键吗?在westus托管是可以的,因为这是一些认知服务在{“cognitiveModels”:{},“defaultLocale”:“en-us”}中可用的唯一区域。好的,这是您的问题,您的cognitiveModels部分是空的。当您使用Virtual Assistant模板创建新项目时,它应该如下所示。为了填写此表,您需要按照的步骤1和步骤2部署必要的认知服务。但我就是这样做的,我只遵循了上述指南。在我给westus的.\Deployment\Scripts\deploy.ps1位置字段中