gpt4 book ai didi

azure - 当 Microsoft Bot 处理任何请求时显示 "TypingIndicator"

转载 作者:行者123 更新时间:2023-12-02 06:58:41 25 4
gpt4 key购买 nike

我试图在 chatBot(Microsoft Bot Framework)处理任何请求时显示“sendTypingIndicator”。我添加了 sendTypingIndicator: truesendTyping: true 但它仍然没有显示任何动画,我在 Microsoft 文档中搜索但没有找到任何具体内容。这就是我所拥有的:

window.WebChat.renderWebChat(
{
directLine: window.WebChat.createDirectLine({
token: conversationInfo.token,
}),
store: store,
styleOptions,
sendTypingIndicator: true,
sendTyping: true
},
document.getElementById("powerVAwebchat")
);

有没有办法自动为所有请求添加打字动画,或者我是否必须为每个请求动态添加它?您能指导我找到解决方案吗?

谢谢

最佳答案

因此,您需要的是在收到消息请求时从机器人发送打字事件。

ShowTypingMiddleware 中间件就可以做到这一点。

您只需将其添加到适配器中,如下所示:

public class AdapterWithErrorHandler : BotFrameworkHttpAdapter
{
public AdapterWithErrorHandler(
IConfiguration configuration,
ILogger<BotFrameworkHttpAdapter> logger,
IStorage storage,
UserState userState,
ConversationState conversationState)
: base(configuration, logger)
{
Use(new ShowTypingMiddleware());

//...
}

}

请注意,如果机器人回复“快”,您将不会在聊天中看到打字指示器。您始终可以模拟它,例如,在机器人中添加 await Task.Delay(5000)

关于azure - 当 Microsoft Bot 处理任何请求时显示 "TypingIndicator",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67391534/

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