mirror of
https://github.com/zylon-ai/private-gpt.git
synced 2025-12-22 20:12:55 +01:00
Event listener for updating total documents
This commit is contained in:
parent
bf135b1692
commit
8bc7fb0039
16 changed files with 153 additions and 65 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue