Improve message schema, assign or create main agent chat automatically

This commit is contained in:
Shivering Ocelot committed 2025-07-05 05:51:03 -05:00
1 parent 4aa374820c
commit b907698829
3 files changed
+47 -33

No files matched your search

+15 -19
View File
@@ -33,6 +33,7 @@ class Agent(Base):
visibility: Mapped[int] = mapped_column(default=0)
# Comma separated list of permission symbols
permissions: Mapped[str] = mapped_column(default="")
main_chat_id: Mapped[int] = mapped_column(ForeignKey("chats.id"))
name: Mapped[str]
description: Mapped[Optional[str]]
@@ -77,19 +78,27 @@ class Message(Base):
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
chat_id: Mapped[int] = mapped_column(ForeignKey("chats.id"))
thread_id: Mapped[Optional[int]] = mapped_column(ForeignKey("threads.id"))
# Timestamp of this message
time: Mapped[int]
# Identifier of the sender: user / system / $AGENT_ID
# Identifier of the sender: user / system / user-$ID / agent-$ID
sender: Mapped[str]
# Predefined set of message types, interpreted as 'text' when empty.
# Predefined set of message types:
# message, log, memory, file, note
kind: Mapped[str]
# Each kind has a set of subkinds, and a default for empty values
# message: (empty)
# log: debug, info
# memory: (depends on the agent)
# file: (empty)
# note: public, private, pinned
subkind: Mapped[Optional[str]]
# For the kinds message, log and note, a format can be specified,
# empty defaults to 'text' and can also be 'markdown', 'csv'
format: Mapped[Optional[str]]
content: Mapped[str]
# Tells whether this message continues in the chat after the session when it was sent.
persistent: Mapped[bool] = mapped_column(default=False)
thread_id: Mapped[Optional[int]] = mapped_column(ForeignKey("threads.id"))
# Represents a temporary topic or stage in a conversation
class Thread(Base):
@@ -118,16 +127,3 @@ class AgentResource(Base):
key: Mapped[str]
value = mapped_column(JSON, default=None)
# A log entry of an agent, the use and meaning depends on the agent class
class AgentLog(Base):
__modelname__ = 'agent_log'
__tablename__ = 'agent_logs'
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
agent_id: Mapped[int] = mapped_column(ForeignKey("agents.id"))
# Kind is the class of the resource
# Key is the specific identifier within the class
# Multiple resources can share key
value: Mapped[str]