Introduce message kinds, and handle them appropriately in user and agent chat

This commit is contained in:
Shivering Ocelot committed 2025-07-08 18:01:46 -05:00
1 parent cba41f1e7e
commit 396b06b05c
4 files changed
+89 -18

No files matched your search

+16 -3
View File
@@ -7,11 +7,13 @@ import database as db
MESSAGE_PAGE_SIZE = 256
class Message:
def __init__(self, id, content, sender, time=None):
def __init__(self, id, content, sender, time=None, kind='message', subkind=None):
self.id = id
self.content = content
self.sender = sender
self.time = time
self.kind = kind
self.subkind = subkind
def from_db_record(record):
return Message(record.id, record.content, record.sender, record.time)
@@ -27,6 +29,8 @@ class Thread:
self.description = description
self.messages = []
self.notes = []
self.memories = []
class ChatView:
def __init__(self, app, chat_id):
@@ -44,6 +48,9 @@ class ChatView:
self.thread_map = {}
# Long term summary of this chat
self.summary = None
# Separate list for note messages from any thread
# Is it better to exclude them or include them from threads? atm they're included
self.notes = []
# Id of the thread currently in focus, by default the last thread appearing in the conversation
self.current_thread_id = None
@@ -92,8 +99,14 @@ class ChatView:
self.thread_map[thread.id] = thread
self.threads.insert(0, thread)
# This is the oldest message so far, add it to the start of the chat
message = Message(record.id, record.content, record.sender, record.time)
thread.messages.insert(0, message)
message = Message(record.id, record.content, record.sender, record.time, record.kind, record.subkind)
if message.kind == 'note':
thread.notes.insert(0, message)
elif message.kind == 'memory':
thread.memories.insert(0, message)
else:
thread.messages.insert(0, message)
def get_thread(self, thread_id):
if thread_id == None: