Skip to content

Commit

Permalink
Clear last message clears last user message as well as model's response.
Browse files Browse the repository at this point in the history
Editing the message history does not move the history cursor to the bottom, so you can keep editing another message.
Pressing esc moves history cursor to the bottom for new message.
  • Loading branch information
chigkim committed Feb 29, 2024
1 parent 910bdc8 commit 6068f39
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
21 changes: 13 additions & 8 deletions VOLlama.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = 17
version = 18
import wx
import threading
import sounddevice as sd
Expand Down Expand Up @@ -141,13 +141,12 @@ def setStatus(self, text):
self.SetStatusText(text)

def clearLast(self, event):
if len(self.model.messages)==0: return
if len(self.model.messages)==1 and self.model.messages[0].role == 'system': return
if self.model.messages[-1].role == 'user':
self.prompt.SetValue(self.model.messages[-1].content)
else:
if len(self.model.messages)==0 | (len(self.model.messages)==1 and self.model.messages[0].role == 'system'):
self.prompt.SetValue("")
self.model.messages = self.model.messages[:-1]
return
delete=-1 if self.model.messages[-1].role == 'user' else -2
self.prompt.SetValue(self.model.messages[delete].content)
self.model.messages = self.model.messages[:delete]
self.historyIndex = len(self.model.messages)
self.refreshChat()

Expand Down Expand Up @@ -260,6 +259,9 @@ def OnHistoryUp(self, event):
self.historyIndex -= 1
if self.historyIndex<0:
self.historyIndex = 0
if self.model.messages[self.historyIndex].role == "system":
self.historyIndex = 1
return
self.prompt.SetValue(self.model.messages[self.historyIndex].content)
self.prompt.SetInsertionPointEnd()
self.sendButton.SetLabel("Edit")
Expand All @@ -284,6 +286,10 @@ def FocusOnPrompt(self, event=None):
self.model.generate = False
self.speech.stop()
self.prompt.SetFocus()
self.historyIndex = len(self.model.messages)
self.prompt.SetValue("")
self.sendButton.SetLabel("Send")


def onStopGeneration(self):
play("receive.wav")
Expand All @@ -303,7 +309,6 @@ def processMessage(message):
if self.historyIndex<len(self.model.messages):
self.model.messages[self.historyIndex].content = message
self.refreshChat()
self.onStopGeneration()
return
self.response.AppendText("You: " + message + "\n")
self.sendButton.SetLabel("Stop")
Expand Down
5 changes: 4 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Change log

* Fixed setting history index incorrectly when there's a system message.
* Clear last message clears last user message as well as model's response.
* Editing the message history does not move the history cursor to the bottom, so you can keep editing another message.
* Pressing esc moves history cursor to the bottom for new message.
* Fixed incorrect history cursor when there's a system message.
* Changed send button to edit when editing history.
* Paste last cleared user message into the prompt for editing or simply resending.
* Edit history: alt+(or option on mac)+up/down
Expand Down

0 comments on commit 6068f39

Please sign in to comment.