1+ import logging
12import json
23import time
34import uuid
45from typing import Optional
56
67from open_webui .internal .db import Base , get_db
78from open_webui .models .tags import TagModel , Tag , Tags
8-
9+ from open_webui . env import SRC_LOG_LEVELS
910
1011from pydantic import BaseModel , ConfigDict
1112from sqlalchemy import BigInteger , Boolean , Column , String , Text , JSON
1617# Chat DB Schema
1718####################
1819
20+ log = logging .getLogger (__name__ )
21+ log .setLevel (SRC_LOG_LEVELS ["MODELS" ])
1922
2023class Chat (Base ):
2124 __tablename__ = "chat"
@@ -670,7 +673,7 @@ def get_chats_by_user_id_and_search_text(
670673 # Perform pagination at the SQL level
671674 all_chats = query .offset (skip ).limit (limit ).all ()
672675
673- print ( len (all_chats ))
676+ log . info ( f"The number of chats: { len (all_chats )} " )
674677
675678 # Validate and return chats
676679 return [ChatModel .model_validate (chat ) for chat in all_chats ]
@@ -731,7 +734,7 @@ def get_chat_list_by_user_id_and_tag_name(
731734 query = db .query (Chat ).filter_by (user_id = user_id )
732735 tag_id = tag_name .replace (" " , "_" ).lower ()
733736
734- print ( db .bind .dialect .name )
737+ log . info ( f"DB dialect name: { db .bind .dialect .name } " )
735738 if db .bind .dialect .name == "sqlite" :
736739 # SQLite JSON1 querying for tags within the meta JSON field
737740 query = query .filter (
@@ -752,7 +755,7 @@ def get_chat_list_by_user_id_and_tag_name(
752755 )
753756
754757 all_chats = query .all ()
755- print ( "all_chats" , all_chats )
758+ log . debug ( f "all_chats: { all_chats } " )
756759 return [ChatModel .model_validate (chat ) for chat in all_chats ]
757760
758761 def add_chat_tag_by_id_and_user_id_and_tag_name (
@@ -810,7 +813,7 @@ def count_chats_by_tag_name_and_user_id(self, tag_name: str, user_id: str) -> in
810813 count = query .count ()
811814
812815 # Debugging output for inspection
813- print (f"Count of chats for tag '{ tag_name } ':" , count )
816+ log . info (f"Count of chats for tag '{ tag_name } ': { count } " )
814817
815818 return count
816819
0 commit comments