Skip to content

Commit

Permalink
ChatThread now automatically appends a completion message to itself.
Browse files Browse the repository at this point in the history
  • Loading branch information
btfranklin committed May 6, 2023
1 parent 0b27339 commit 8767527
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/CleverBird/chat/ChatThread+complete.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ extension ChatThread {
let request = try await self.connection.createRequest(for: requestBody)
let response = try await self.connection.client.send(request)
let completion = response.value
let firstChoiceMessage = completion.choices.first?.message

return completion.choices.first?.message
// Append the response message to the thread
if let firstChoiceMessage {
_ = addMessage(firstChoiceMessage)
}

return firstChoiceMessage
} catch {
logger("Error executing request: \(error.localizedDescription)")
return nil
Expand Down

0 comments on commit 8767527

Please sign in to comment.