gpt4 book ai didi

c# - 机器人在模拟器上工作,但在 Azure 上不工作(InternalServerError)

转载 作者:行者123 更新时间:2023-12-03 04:15:13 25 4
gpt4 key购买 nike

使用:

  • SDK 语言:C#
  • SDK 版本:4.1.5
  • 环境:本地主机、Azure
  • channel :网络聊天
<小时/>

问题描述

在 Bot Framework Emulator V4 中测试机器人时,它确实按预期工作,如下图所示:

Figure 1: Bot working on emulator

在 Azure 中部署后,遵循 this说明,机器人停止工作(既不发送也不接收消息)并在网络聊天 channel 部分收到此警报:

Figure 2: Alerts at the channel section

我发现了这些类似的问题:

https://github.com/Microsoft/BotFramework-Emulator/issues/296

https://github.com/Microsoft/BotBuilder/issues/3329

但就我而言,AppId 和密码都已定义,而另一个解决方案根本不起作用。我什至设法在 azure 平台上找到错误代码,但无法找到详细信息或获取错误来自何处...

Figure 3: AppInsights Error panel

代码概述

public async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken = default(CancellationToken))
{
bool reintentar = false;
//tried this but didn't work
//MicrosoftAppCredentials.TrustServiceUrl("http://botrps.azurewebsites.net");

//obtener el contexto de los dialogos
var dc = await _dialogs.CreateContextAsync(turnContext, cancellationToken);

if (turnContext.Activity.Type == ActivityTypes.Message && turnContext.Activity.From.Id != turnContext.Activity.Recipient.Id)
{
//bot operations on users messages
}

//if active dialog
await dc.ContinueDialogAsync(cancellationToken);

//else, start greeting dialog
if (turnContext.Activity.Type == ActivityTypes.ConversationUpdate &&
turnContext.Activity.MembersAdded[0].Id != turnContext.Activity.Recipient.Id)
{
await dc.BeginDialogAsync("dialogo", null, cancellationToken);
}

await _accessors.ConversationState.SaveChangesAsync(turnContext, false, cancellationToken);

// Guarda los cambios realizados en el Contexto, si hay alguno
await _accessors.UserState.SaveChangesAsync(turnContext, false, cancellationToken);
}

最佳答案

正如 tdurnford 所说在评论部分,有必要将生产 enpoint 服务添加到 .bot 配置中。生成的机器人文件:

{
"name": "BotMod2",
"services": [
{
"type": "endpoint",
"name": "development",
"endpoint": "http://localhost:3978/api/messages",
"appId": "",
"appPassword": "",
"id": "1"
},
{
"appId": "**********************",
"appPassword": "**********************",
"endpoint": "https://**********************.azurewebsites.net/api/messages",
"type": "endpoint",
"name": "production",
"id": "2"
},
{
"appId": "**********************",
"authoringKey": "**********************",
"version": "0.1",
"region": "westus",
"type": "luis",
"name": "**********************",
"id": "3"
},
{
"type": "qna",
"name": "**********************",
"kbId": "**********************",
"hostname": "https://**********************.azurewebsites.net/qnamaker",
"endpointKey": "**********************",
"subscriptionKey": "**********************",
"id": "4"
}
],
"padlock": "",
"version": "2.0"
}

关于c# - 机器人在模拟器上工作,但在 Azure 上不工作(InternalServerError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53629637/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com