Skip to content

Commit

Permalink
Remove last message in chat history
Browse files Browse the repository at this point in the history
  • Loading branch information
zionhann committed Aug 6, 2024
1 parent 92ca6aa commit cd68633
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class ChatService(
}

fun generateSummaryOf(chatId: String): ChatSummaryResponse {
val chatHistory = chatHistoryOf(chatId).toSimpleMessage()
val chatHistory = chatHistoryOf(chatId).removeLast().toSimpleMessage()

with(openAiProperties.completion) {
val requestBody = CompletionRequest.of(modelType.id, instructions, chatHistory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ data class MessageResponseWrapper(val data: List<MessageResponse>) {
}
}

fun removeLast(): MessageResponseWrapper {
return MessageResponseWrapper(data.dropLast(1))
}

companion object {
fun reverseOf(response: MessageResponseWrapper): MessageResponseWrapper {
return MessageResponseWrapper(response.data.reversed())
Expand Down

0 comments on commit cd68633

Please sign in to comment.