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