From 39a2b9789c5b1f86f25e25e35116410047a72f7a Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Fri, 26 Dec 2025 16:16:10 +0400 Subject: [PATCH] refac --- backend/open_webui/models/chats.py | 1 + backend/open_webui/routers/chats.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/backend/open_webui/models/chats.py b/backend/open_webui/models/chats.py index 797878afae..d7153a2330 100644 --- a/backend/open_webui/models/chats.py +++ b/backend/open_webui/models/chats.py @@ -218,6 +218,7 @@ class MessageStats(BaseModel): token_count: Optional[int] = None timestamp: Optional[int] = None rating: Optional[int] = None # Derived from message.annotation.rating + tags: Optional[list[str]] = None # Derived from message.annotation.tags class ChatHistoryStats(BaseModel): diff --git a/backend/open_webui/routers/chats.py b/backend/open_webui/routers/chats.py index 3465205338..13bae42b21 100644 --- a/backend/open_webui/routers/chats.py +++ b/backend/open_webui/routers/chats.py @@ -274,6 +274,8 @@ async def export_chat_stats( # Extract rating safely rating = message.get("annotation", {}).get("rating") + tags = message.get("annotation", {}).get("tags") + message_stat = MessageStats( id=message.get("id"), role=message.get("role"), @@ -282,6 +284,7 @@ async def export_chat_stats( content_length=content_length, token_count=None, # Populate if available, e.g. message.get("info", {}).get("token_count") rating=rating, + tags=tags, ) export_messages[key] = message_stat