Skip to content

Commit

Permalink
Manage history message cache
Browse files Browse the repository at this point in the history
  • Loading branch information
pplam committed Dec 6, 2023
1 parent 4af88a2 commit 2dc6a78
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ai.devchat.cli.DevChatResponse
import ai.devchat.common.Log
import ai.devchat.devchat.BaseActionHandler
import ai.devchat.devchat.DevChatActions
import ai.devchat.idea.storage.ActiveConversation
import com.alibaba.fastjson.JSONObject
import java.io.File
import java.io.FileWriter
Expand Down Expand Up @@ -53,6 +54,14 @@ class SendMessageRequestHandler(metadata: JSONObject?, payload: JSONObject?) : B
response.update(line)
promptCallback(response)
}
val currentTopic = ActiveConversation.topic ?: response.promptHash!!
val newMessage = wrapper.logTopic(currentTopic, 1).getJSONObject(0)

if (currentTopic == ActiveConversation.topic) {
ActiveConversation.addMessage(newMessage)
} else {
ActiveConversation.reset(currentTopic, listOf(newMessage))
}
}

override fun except(exception: Exception) {
Expand Down

0 comments on commit 2dc6a78

Please sign in to comment.