mirror of
https://github.com/zylon-ai/private-gpt.git
synced 2025-12-22 23:22:57 +01:00
Update with filter for audit
This commit is contained in:
parent
8bc7fb0039
commit
97317b82e0
7 changed files with 91 additions and 8 deletions
|
|
@ -11,12 +11,20 @@ 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)
|
||||
.order_by(asc(getattr(ChatHistory, 'created_at')))
|
||||
.first()
|
||||
chat_history = (
|
||||
db.query(self.model)
|
||||
.filter(ChatHistory.conversation_id == id)
|
||||
.order_by(asc(getattr(ChatHistory, 'created_at')))
|
||||
.first()
|
||||
)
|
||||
if chat_history:
|
||||
chat_history.chat_items = (
|
||||
db.query(ChatItem)
|
||||
.filter(ChatItem.conversation_id == id)
|
||||
.order_by(asc(getattr(ChatItem, 'index')))
|
||||
.all()
|
||||
)
|
||||
return chat_history
|
||||
|
||||
def get_chat_history(
|
||||
self, db: Session, *,user_id:int, skip: int = 0, limit: int = 100
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue