Event listener for updating total documents

This commit is contained in:
Saurab-Shrestha9639*969**9858//852 2024-04-17 17:09:50 +05:45
parent bf135b1692
commit 8bc7fb0039
16 changed files with 153 additions and 65 deletions

View file

@ -11,19 +11,25 @@ from private_gpt.users.schemas.chat import ChatHistoryCreate, ChatHistoryCreate,
class CRUDChat(CRUDBase[ChatHistory, ChatHistoryCreate, ChatHistoryCreate]):
def get_by_id(self, db: Session, *, id: uuid.UUID) -> Optional[ChatHistory]:
return db.query(self.model).filter(ChatHistory.conversation_id == id).first()
return (
db.query(self.model)
.filter(ChatHistory.conversation_id == id)
.order_by(asc(getattr(ChatHistory, 'created_at')))
.first()
)
def get_chat_history(
self, db: Session, *, skip: int = 0, limit: int = 100
self, db: Session, *,user_id:int, skip: int = 0, limit: int = 100
) -> List[ChatHistory]:
return (
db.query(self.model)
.filter(ChatHistory.user_id == user_id)
.order_by(desc(getattr(ChatHistory, 'created_at')))
.offset(skip)
.limit(limit)
.all()
)
class CRUDChatItem(CRUDBase[ChatItem, ChatItemCreate, ChatItemUpdate]):
pass