This commit is contained in:
GH Action - Upstream Sync
2023-05-19 01:02:15 +00:00
23 changed files with 452 additions and 55 deletions

View File

@@ -487,18 +487,26 @@ export function Chat() {
// stop response
const onUserStop = (messageId: number) => {
ChatControllerPool.stop(sessionIndex, messageId);
};
useEffect(() => {
chatStore.updateCurrentSession((session) => {
const stopTiming = Date.now() - REQUEST_TIMEOUT_MS;
session.messages.forEach((m) => {
// check if should stop all stale messages
if (m.streaming && new Date(m.date).getTime() < stopTiming) {
m.isError = false;
m.streaming = false;
if (new Date(m.date).getTime() < stopTiming) {
if (m.streaming) {
m.streaming = false;
}
if (m.content.length === 0) {
m.content = "No content in this message.";
}
}
});
});
ChatControllerPool.stop(sessionIndex, messageId);
};
}, []);
// check if should send message
const onInputKeyDown = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {