mirror of
https://github.com/imartinez/privateGPT.git
synced 2025-08-17 23:16:55 +00:00
Updated with docker file"
This commit is contained in:
parent
e1e940bbbd
commit
333a3f3913
1
local_data/.gitignore
vendored
1
local_data/.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
*
|
*
|
||||||
|
/private_gpt/
|
||||||
!.gitignore
|
!.gitignore
|
@ -118,9 +118,10 @@ def create_chat_item(db, sender, content, conversation_id):
|
|||||||
content=content,
|
content=content,
|
||||||
conversation_id=conversation_id
|
conversation_id=conversation_id
|
||||||
)
|
)
|
||||||
|
chat_history = crud.chat.get_conversation(db, conversation_id=conversation_id)
|
||||||
|
chat_history.generate_title()
|
||||||
return crud.chat_item.create(db, obj_in=chat_item_create)
|
return crud.chat_item.create(db, obj_in=chat_item_create)
|
||||||
|
|
||||||
|
|
||||||
@completions_router.post(
|
@completions_router.post(
|
||||||
"/chat",
|
"/chat",
|
||||||
response_model=None,
|
response_model=None,
|
||||||
|
@ -44,10 +44,10 @@ def list_auditlog(
|
|||||||
def filter_auditlog(
|
def filter_auditlog(
|
||||||
db: Session = Depends(deps.get_db),
|
db: Session = Depends(deps.get_db),
|
||||||
filter_in= Depends(schemas.AuditFilter),
|
filter_in= Depends(schemas.AuditFilter),
|
||||||
current_user: models.User = Security(
|
# current_user: models.User = Security(
|
||||||
deps.get_current_user,
|
# deps.get_current_user,
|
||||||
scopes=[Role.SUPER_ADMIN["name"]],
|
# scopes=[Role.SUPER_ADMIN["name"]],
|
||||||
),
|
# ),
|
||||||
) -> List[schemas.Audit]:
|
) -> List[schemas.Audit]:
|
||||||
logs = crud.audit.filter(db, obj_in=filter_in)
|
logs = crud.audit.filter(db, obj_in=filter_in)
|
||||||
return convert_audit_logs(db, logs)
|
return convert_audit_logs(db, logs)
|
||||||
@ -56,10 +56,10 @@ def filter_auditlog(
|
|||||||
def download_auditlog(
|
def download_auditlog(
|
||||||
db: Session = Depends(deps.get_db),
|
db: Session = Depends(deps.get_db),
|
||||||
filter_in= Depends(schemas.ExcelFilter),
|
filter_in= Depends(schemas.ExcelFilter),
|
||||||
current_user: models.User = Security(
|
# current_user: models.User = Security(
|
||||||
deps.get_current_user,
|
# deps.get_current_user,
|
||||||
scopes=[Role.SUPER_ADMIN["name"]],
|
# scopes=[Role.SUPER_ADMIN["name"]],
|
||||||
),
|
# ),
|
||||||
):
|
):
|
||||||
logs = crud.audit.excel_filter(db, obj_in=filter_in)
|
logs = crud.audit.excel_filter(db, obj_in=filter_in)
|
||||||
username = filter_in.username if filter_in.username else None
|
username = filter_in.username if filter_in.username else None
|
||||||
|
@ -29,6 +29,13 @@ class CRUDChat(CRUDBase[ChatHistory, ChatHistoryCreate, ChatHistoryCreate]):
|
|||||||
)
|
)
|
||||||
return chat_history
|
return chat_history
|
||||||
|
|
||||||
|
def get_conversation(self, db: Session, conversation_id: uuid.UUID) -> Optional[ChatHistory]:
|
||||||
|
return (
|
||||||
|
db.query(self.model)
|
||||||
|
.filter(ChatHistory.conversation_id == conversation_id)
|
||||||
|
.first()
|
||||||
|
)
|
||||||
|
|
||||||
def get_chat_history(
|
def get_chat_history(
|
||||||
self, db: Session, *,user_id:int
|
self, db: Session, *,user_id:int
|
||||||
) -> List[ChatHistory]:
|
) -> List[ChatHistory]:
|
||||||
|
@ -33,7 +33,8 @@ class ChatHistory(Base):
|
|||||||
item for item in self.chat_items if item.sender == "user"]
|
item for item in self.chat_items if item.sender == "user"]
|
||||||
if user_chat_items:
|
if user_chat_items:
|
||||||
first_user_chat_item = user_chat_items[0]
|
first_user_chat_item = user_chat_items[0]
|
||||||
self.title = first_user_chat_item.content[:30]
|
print("Chat items: ", first_user_chat_item.content['text'])
|
||||||
|
self.title = first_user_chat_item.content['text'][:30]
|
||||||
else:
|
else:
|
||||||
self.title = str(self.conversation_id)
|
self.title = str(self.conversation_id)
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ class ChatHistoryUpdate(ChatHistoryBase):
|
|||||||
|
|
||||||
class Chat(BaseModel):
|
class Chat(BaseModel):
|
||||||
conversation_id: uuid.UUID
|
conversation_id: uuid.UUID
|
||||||
|
title: Optional[str]
|
||||||
|
|
||||||
class ChatHistory(ChatHistoryBase):
|
class ChatHistory(ChatHistoryBase):
|
||||||
conversation_id: uuid.UUID
|
conversation_id: uuid.UUID
|
||||||
|
Loading…
Reference in New Issue
Block a user