如何在项目appsettings.json中配置多个QnA模型?

时间:2019-09-17 09:44:32

标签: c# botframework dispatch qnamaker

我有一个使用Dispatch工具在Luis&QnA模型上运行的机器人。现在这里的问题是我已经制作了另一个QnA模型,我想在我的bot项目中进行配置,即我想更新c#项目的appsettings.json中的知识库ID。 我怎样才能做到这一点?因为没有第二个QnA没有被选择。

{
  "Logging": {
    "LogLevel": {
      "Default": "Warning"
    }
  },

  "MicrosoftAppId": "xxxxxxxxxxxxx",
  "MicrosoftAppPassword": "xxxxxxxxxxxxxxxx",

  "QnAKnowledgebaseId": "xxxxxxxxxxxx",
  "QnAAuthKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "QnAEndpointHostName": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",

   "QnAKnowledgebaseId": "xxxxxxxxxxxx",
  "QnAAuthKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "QnAEndpointHostName": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",



  "LuisAppId": "xxxxxxxxxxxxxxxxxxxx",
  "LuisAPIKey": "xxxxxxxxxxxxxxxxxxxxx",
  "LuisAPIHostName": "xxxxxx",



 `enter code here`"AllowedHosts": "*"
}

1 个答案:

答案 0 :(得分:0)

为什么不能只在应用程序设置中将其设置为MODELNAME_QnAKnowledgebaseId等,然后使用简单的开关盒或在您的机器人中调度它来调用它?

},

  "MicrosoftAppId": "xxxxxxxxxxxxx",
  "MicrosoftAppPassword": "xxxxxxxxxxxxxxxx",

  "MODEL1_QnAKnowledgebaseId": "xxxxxxxxxxxx",
  "MODEL1_QnAAuthKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "MODEL1_QnAEndpointHostName": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",

  "MODEL2_QnAKnowledgebaseId": "xxxxxxxxxxxx",
  "MODEL2_QnAAuthKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
  "MODEL2_QnAEndpointHostName": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",

  "LuisAppId": "xxxxxxxxxxxxxxxxxxxx",
  "LuisAPIKey": "xxxxxxxxxxxxxxxxxxxxx",
  "LuisAPIHostName": "xxxxxx",

 "AllowedHosts": "*"
}

然后在您的BotServices中:


public BotServices(IConfiguration configuration)
        {
            // Read the setting for cognitive services (LUIS, QnA) from the appsettings.json

            MODEL1_QnA = new QnAMaker(new QnAMakerEndpoint
            {
                KnowledgeBaseId = configuration["MODEL1_QnAKnowledgebaseId"],
                EndpointKey = configuration["MODEL1_QnAEndpointKey"],
                Host = configuration["MODEL1_QnAEndpointHostName"]
            });
        }