Skip to content

Commit

Permalink
Remove the parent_message_id constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
WongSaang committed Mar 22, 2023
1 parent 1ff1c46 commit ce0b100
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,12 @@ const abortFetch = () => {
}
fetchingResponse.value = false
}
const fetchReply = async (message, parentMessageId) => {
const fetchReply = async (message) => {
ctrl = new AbortController()
const data = Object.assign({}, currentModel.value, {
openaiApiKey: openaiApiKey.value,
message: message,
// parentMessageId: parentMessageId,
conversationId: currentConversation.value.id
})
Expand Down Expand Up @@ -94,9 +93,7 @@ const fetchReply = async (message, parentMessageId) => {
}
if (event === 'userMessageId') {
console.log(currentConversation.value.messages[currentConversation.value.messages.length - 1])
currentConversation.value.messages[currentConversation.value.messages.length - 1].id = data.userMessageId
console.log(currentConversation.value.messages[currentConversation.value.messages.length - 1])
return;
}
Expand Down Expand Up @@ -136,15 +133,8 @@ const scrollChatWindow = () => {
const send = (message) => {
fetchingResponse.value = true
let parentMessageId = null
if (currentConversation.value.messages.length > 0) {
const lastMessage = currentConversation.value.messages[currentConversation.value.messages.length - 1]
if (lastMessage.is_bot && lastMessage.id !== null) {
parentMessageId = lastMessage.id
}
}
currentConversation.value.messages.push({parentMessageId: parentMessageId, message: message})
fetchReply(message, parentMessageId)
currentConversation.value.messages.push({message: message})
fetchReply(message)
scrollChatWindow()
}
const stop = () => {
Expand Down

0 comments on commit ce0b100

Please sign in to comment.