fix: send message error when last sent message not succeeded (#8682)

This commit is contained in:
Hash Brown
2024-09-23 18:44:09 +08:00
committed by GitHub
parent c7eacd1aac
commit 11d09a92d0
6 changed files with 27 additions and 37 deletions

View File

@@ -19,6 +19,15 @@ function getProcessedInputsFromUrlParams(): Record<string, any> {
return inputs
}
function getLastAnswer(chatList: ChatItem[]) {
for (let i = chatList.length - 1; i >= 0; i--) {
const item = chatList[i]
if (item.isAnswer && !item.isOpeningStatement)
return item
}
return null
}
function appendQAToChatList(chatList: ChatItem[], item: any) {
// we append answer first and then question since will reverse the whole chatList later
chatList.push({
@@ -71,5 +80,6 @@ function getPrevChatList(fetchedMessages: any[]) {
export {
getProcessedInputsFromUrlParams,
getLastAnswer,
getPrevChatList,
}