所以我在azure中创建了一个bot并下载了它。来自LUIS的免费1000次电话达到了极限。我在azure portal中创建了一个订阅(我确实做了docker容器的东西)。跟随this guide直到第6步。当我点击端点网址并直接在浏览器中查询它工作正常。
我通过Bot Emulator将它添加到机器人中,点击+登录服务并在那里添加机器人模型。但是当我运行bot时,我得到了标题错误。我在.bot文件中注意到,bot模拟器添加的创作密钥和订阅密钥是相同的。
所以我将订阅密钥更改为azure生成的密钥之一,但仍然是相同的错误。我已经尝试重置创作密钥仍然相同并删除我的luis.ai帐户并创建了一个新帐户。 (仍然是同样的电子邮件,因为这是登录天蓝色门户网站的那个。)并且仍然相同。
这里有一些图片供参考和错误。
这是通过Bot仿真器添加luis后的bot文件的图片。它具有相同的创作密钥和订阅密钥(仍然禁止)
以供参考:
这是机器人服务的代码。
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder.AI.Luis;
using Microsoft.Bot.Configuration;
namespace Microsoft.BotBuilderSamples
{
public class BotServices
{
public BotServices(BotConfiguration botConfiguration)
{
foreach (var service in botConfiguration.Services)
{
switch (service.Type)
{
case ServiceTypes.Luis:
{
var luis = (LuisService)service;
if (luis == null)
{
throw new InvalidOperationException("The LUIS service is not configured correctly in your '.bot' file.");
}
var endpoint = (luis.Region?.StartsWith("https://") ?? false) ? luis.Region : luis.GetEndpoint();
var app = new LuisApplication(luis.AppId, luis.AuthoringKey, endpoint);
var recognizer = new LuisRecognizer(app);
this.LuisServices.Add(luis.Name, recognizer);
break;
}
}
}
}
public Dictionary<string, LuisRecognizer> LuisServices { get; } = new Dictionary<string, LuisRecognizer>();
}
}
我试图解决这个问题已经4天了。谢谢!
谢谢你的所有图片。这是一个巨大的帮助!这是问题所在:
默认情况下,您的代码在本节中查找AuthoringKey
(第二行):
var endpoint = (luis.Region?.StartsWith("https://") ?? false) ? luis.Region : luis.GetEndpoint();
var app = new LuisApplication(luis.AppId, luis.AuthoringKey, endpoint);
var recognizer = new LuisRecognizer(app);
this.LuisServices.Add(luis.Name, recognizer);
由于你的.bot
文件仍然将authoringKey
设置为以ad9c...
开头的那个,它已达到极限,你的机器人一直遇到403错误。
因此,在你的.bot
文件中,将authoringKey
替换为你的一个endpointKey
s(它们以12ccc...
或b575...
开头)。
我理解你对此的困惑,特别是因为这需要你在你的endpointKey
财产中加入authoringKey
。我知道LUIS机器人将如何使用密钥有一些变化,但那可能是一个月或更长时间。
或者,您可以更改:
var app = new LuisApplication(luis.AppId, luis.AuthoringKey, endpoint);
至:
var app = new LuisApplication(luis.AppId, luis.SubscriptionKey, endpoint);
注意:如果您进行了其中任何一项更改,LUIS只能查询(通常很好),因为创作密钥会执行其他所有操作(请参阅下面的参考资料)
这些对你来说并不像可能遇到过这种情况的其他人那么多。