gpt4 book ai didi

javascript - 为什么记录记录器/webBot 在刷新网页后会存储之前对话的事件?

转载 作者:行者123 更新时间:2023-11-28 03:40:36 26 4
gpt4 key购买 nike

我使用 ITranscriptLogger 和 TranscriptLoggerMiddleware 将聊天记录存储在 Cosmos DB 中。我正在创建一个新文档,其 id 等于对话 ID。当我刷新网络聊天时,它会重新开始并生成新的用户 ID 和新的对话 ID。

问题是,cosmos DB 中的新文档/项目除了最新的对话之外,还包含之前所有对话的聊天记录。最重要的是,与工作中的另一个用户(在另一台计算机上)的所有对话都存储在同一个聊天记录中,并且还堆积在之前的对话之上。这是为什么?如何在刷新网页时单独存储每个对话,更关键的是如何分离与不同用户的对话?

我之前发布过如何设置存储 here ,这就是网络聊天的设置方式:

<!DOCTYPE html>
<html lang="en-US">
<head>
<script src="https://cdn.botframework.com/botframework-webchat/latest/webchat.js"></script>
<style>
...
</style>
</head>
<body>
<div id="container" style="width: 370px; height: 500px; margin: 0; display:inline-block; ">
<div id="header" style="
background-color:#2f2f2f; height:30px; padding: 8px 8px 0 8px; font-weight: 500; font-family: Segoe UI, sans-serif;
color:#e3ce8e
">

<span>MyBot</span></div>
<div id="webchat" role = "main">
</div>
</div>

<script>
const groupTimestamp = 0;
(async function () {
const res = await fetch('https://directline.botframework.com/v3/directline/tokens/generate', { method: 'POST', headers:
{ Authorization: 'SecretKeyFromAzureDirectLineSettings' } });
const { token } = await res.json();
const styleOptions = {
botAvatarImage: 'botPictureUrl',
botAvatarInitials: 'PP',
userAvatarImage: 'userPictureUrl',
userAvatarInitials: 'PP',
hideUploadButton: true,
sendTypingIndicator: true,
};
const store = window.WebChat.createStore({}, ({ dispatch }) => next => action => {
if (action.type === 'DIRECT_LINE/CONNECT_FULFILLED') {
dispatch({
type: 'WEB_CHAT/SEND_EVENT',
payload: {
name: 'webchat/join',
value: { language: window.navigator.language }
}
});
}
return next(action);
});
window.WebChat.renderWebChat({
directLine: window.WebChat.createDirectLine({ token }),
store,
styleOptions,
hideUploadButton: true,
groupTimestamp: groupTimestamp,
}, document.getElementById('webchat'));
document.querySelector('#webchat > *').focus();

})().catch(err => console.error(err));
</script>
</body>
</html>

最佳答案

我将用户和机器人响应添加到了一个列表中,该列表在新对话开始时从未被清除,所以这就是问题的解释。解决方案只是在新对话开始时清除列表......

关于javascript - 为什么记录记录器/webBot 在刷新网页后会存储之前对话的事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57329873/

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