gpt4 book ai didi

Botframework 模拟器和 404 错误

转载 作者:行者123 更新时间:2023-12-04 04:23:26 26 4
gpt4 key购买 nike

我正在尝试编写一个使用 LUIS 的简单机器人,但似乎在更新后出现问题。

因此,在将 Botbuilder 更新到 1.1 之前,我遇到了无法找到 Luis.Models 的问题。升级后,解决一个coding error ,并删除 Microsoft.Bot.Connector.Utilities,我可以编译并成功运行,但无法通过模拟器连接。

这是我正在使用的代码。

using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Description;
using System.Collections.Generic;
using Microsoft.Bot.Connector;
using Microsoft.Bot.Builder.Dialogs;
//using Microsoft.Bot.Connector.Utilities;
using Microsoft.Bot.Builder.Luis;
using Microsoft.Bot.Builder.Luis.Models;
using Newtonsoft.Json;

[LuisModel("c413b2ef-382c-45bd-8ff0-f76d60e2a821", "6d0966209c6e4f6b835ce34492f3e6d9")]
[Serializable]
public class Mybot : LuisDialog<object>
{

[LuisIntent("")]
public async Task None(IDialogContext context, LuisResult result)
{
string message = "I'm sorry I didn't understand. Try asking about your bill.";
await context.PostAsync(message);
context.Wait(MessageReceived);
}

[LuisIntent("NextInvoiceDate")]
public async Task NextInvoiceDate(IDialogContext context, LuisResult result)
{
string message = "Your next payment will go out on the 17th of the month.";
await context.PostAsync(message);
context.Wait(MessageReceived);
}

[LuisIntent("NextAmount")]
public async Task NextAmount(IDialogContext context, LuisResult result)
{
string message = $"Your next amount is expected to be around £29.72.";
await context.PostAsync(message);
context.Wait(MessageReceived);
}
}

当我运行该项目时,它启动时没有错误,我得到的网页显示:

我的机器人在此处描述您的机器人以及您的使用条款等。访问 Bot Framework 以注册您的机器人。注册时,请记住将机器人的端点设置为 https://your_bots_hostname/api/messages

当我运行指向 https://localhost/api/messages 的模拟器时,它返回“发送请求时发生错误”。

JSON 在这里:

System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:443
at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Microsoft.Bot.Connector.Emulator.ConversationModel.<SendMessageAsync>d__50.MoveNext()

我也只尝试过 HTTP(而不是 HTTPS)。

最佳答案

你能检查一下你是否为你的机器人使用了正确的 url 吗?检查项目属性中的项目 url 并确保使用正确的端口号。默认情况下,Bot Framework 项目模板使用 http://localhost :3978/

Project Properties

关于Botframework 模拟器和 404 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37700397/

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