mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-10 22:43:29 +00:00
refac
This commit is contained in:
parent
b0c5f7b668
commit
d938eb0e76
2 changed files with 6 additions and 3 deletions
|
|
@ -137,7 +137,7 @@ def upgrade() -> None:
|
|||
try:
|
||||
conn.execute(
|
||||
sa.insert(chat_message_table).values(
|
||||
id=message_id,
|
||||
id=f"{chat_id}-{message_id}",
|
||||
chat_id=chat_id,
|
||||
user_id=user_id,
|
||||
role=role,
|
||||
|
|
|
|||
|
|
@ -137,7 +137,10 @@ class ChatMessageTable:
|
|||
now = int(time.time())
|
||||
timestamp = data.get("timestamp", now)
|
||||
|
||||
existing = db.get(ChatMessage, message_id)
|
||||
# Use composite ID: {chat_id}-{message_id}
|
||||
composite_id = f"{chat_id}-{message_id}"
|
||||
|
||||
existing = db.get(ChatMessage, composite_id)
|
||||
if existing:
|
||||
# Update existing
|
||||
if "role" in data:
|
||||
|
|
@ -183,7 +186,7 @@ class ChatMessageTable:
|
|||
info = data.get("info", {})
|
||||
usage = info.get("usage") if info else None
|
||||
message = ChatMessage(
|
||||
id=message_id,
|
||||
id=composite_id,
|
||||
chat_id=chat_id,
|
||||
user_id=user_id,
|
||||
role=data.get("role", "user"),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue