【发布时间】:2021-04-22 08:38:59
【问题描述】:
我在 Azure 中托管了一个机器人,当通过机器人模拟器使用 ngrok 进行调试时,我收到一条错误消息:不知道这样的主机。我之前有过这样的机器人体验,这意味着 LUIS AI 配置,特别是 LuisAPIHostName 值,在 appsettings.json 中没有以正确的格式写入。
事实证明,当时甚至没有托管应用程序,问题是我从托管的 LUIS 服务中获得了一个端点,https://
回到当前问题,我试图通过绕过我的应用程序中的 LUIS 逻辑来隔离问题,并再次发布它,机器人开始在 Azure 网络聊天中正常工作。 所以,我猜问题可能出在 LUIS 配置上。但是,如果它与以前的解决方案一起在本地工作,LUIS 服务与机器人托管在同一个订阅中,要让它在 Azure 上工作需要什么?我为 LuisAPIHostName 尝试了一些组合,包括 Azure 提供的整个字符串,并在末尾添加了一个额外的“/”,但这并没有改变任何事情......
机器人是用:
v4.13.0 Bot Builder 库
.NET Core 3.1 框架
在 Azure 中作为 Web App Bot 托管,并带有相应的 AppService
更新:
添加如何在我的应用中配置 LUIS
BotServices 中的识别器可以在Microsoft LUIS docs找到
public BotServices(IConfiguration configuration)
{
// Read the setting for cognitive services (LUIS, QnA) from the appsettings.json
// If includeApiResults is set to true, the full response from the LUIS api (LuisResult)
// will be made available in the properties collection of the RecognizerResult
var luisApplication = new LuisApplication(
configuration["LuisAppId"],
configuration["LuisAPIKey"],
$"https://{configuration["LuisAPIHostName"]}.api.cognitive.microsoft.com");
// Set the recognizer options depending on which endpoint version you want to use.
// More details can be found in https://docs.microsoft.com/en-gb/azure/cognitive-services/luis/luis-migration-api-v3
var recognizerOptions = new LuisRecognizerOptionsV2(luisApplication)
{
IncludeAPIResults = true,
PredictionOptions = new LuisPredictionOptions()
{
IncludeAllIntents = true,
IncludeInstanceData = true
}
};
SampleQnA = new QnAMaker(new QnAMakerEndpoint
{
KnowledgeBaseId = configuration["QnAKnowledgebaseId"],
EndpointKey = configuration["QnAEndpointKey"],
Host = configuration["QnAEndpointHostName"]
});
Dispatch = new LuisRecognizer(recognizerOptions);
}
public LuisRecognizer Dispatch { get; private set; }
public QnAMaker SampleQnA { get; private set; }
}
如何从机器人调用服务,可以在Microsoft docs找到
//First, we use the dispatch model to determine which cognitive service(LUIS or QnA) to use.
var recognizerResult = await _botServices.Dispatch.RecognizeAsync(turnContext, cancellationToken);
// Top intent tell us which cognitive service to use.
var (intent, _) = recognizerResult.GetTopScoringIntent();
// Next, we call the dispatcher with the top intent.
await DispatchToTopIntentAsync(turnContext, intent, recognizerResult, cancellationToken, botUser);
【问题讨论】:
-
能否提供用于设置 LUIS 连接器和/或调用 LUIS API 的代码(已删除密钥/应用程序详细信息)?此外,您能否确认您正在使用哪些密钥和应用程序名称,因为 LUIS 同时具有预测和创作端点?
-
@billoverton 提供代码
-
Emulator 您正在获得 LUIS App 输出,然后尝试在 prod 或 slot 环境中重新发布该应用并检查输出。还要验证您的 qna 制造商呼叫。
-
抱歉@Rajeesh 我看不懂你的文字,你能改写一下吗?
标签: c# azure botframework luis.ai