Skip to content

Commit

Permalink
Merge pull request transitive-bullshit#504 from 189/fix/defer-save
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Apr 2, 2023
2 parents 34990a5 + 7db108d commit dd25220
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/chatgpt-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export class ChatGPTAPI {
parentMessageId,
text
}
await this._upsertMessage(message)

const latestQuestion = message

const { messages, maxTokens, numTokens } = await this._buildMessages(
text,
Expand Down Expand Up @@ -313,7 +314,7 @@ export class ChatGPTAPI {
}
}

return this._upsertMessage(message).then(() => message)
return Promise.all([ this._upsertMessage(latestQuestion), this._upsertMessage(message) ]).then(() => message)
})

if (timeoutMs) {
Expand Down

0 comments on commit dd25220

Please sign in to comment.