refac
This commit is contained in:
@@ -197,13 +197,19 @@ def get_session_user_chat_usage_stats(
|
||||
)
|
||||
|
||||
|
||||
|
||||
############################
|
||||
# GetChatStatsExport
|
||||
############################
|
||||
|
||||
|
||||
@router.get("/stats/export", response_model=list[ChatStatsExport])
|
||||
class ChatStatsExportList(BaseModel):
|
||||
type: str = "chats"
|
||||
items: list[ChatStatsExport]
|
||||
total: int
|
||||
page: int
|
||||
|
||||
|
||||
@router.get("/stats/export", response_model=ChatStatsExportList)
|
||||
async def export_chat_stats(
|
||||
request: Request,
|
||||
chat_id: Optional[str] = None,
|
||||
@@ -264,7 +270,9 @@ async def export_chat_stats(
|
||||
if isinstance(content, str):
|
||||
content_length = len(content)
|
||||
else:
|
||||
content_length = 0 # Handle cases where content might be None or not string
|
||||
content_length = (
|
||||
0 # Handle cases where content might be None or not string
|
||||
)
|
||||
|
||||
# Extract rating safely
|
||||
rating = message.get("annotation", {}).get("rating")
|
||||
@@ -372,7 +380,9 @@ async def export_chat_stats(
|
||||
)
|
||||
)
|
||||
|
||||
return chat_stats_export_list
|
||||
return ChatStatsExportList(
|
||||
items=chat_stats_export_list, total=result.total, page=page
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
log.exception(e)
|
||||
@@ -381,7 +391,6 @@ async def export_chat_stats(
|
||||
)
|
||||
|
||||
|
||||
|
||||
@router.delete("/", response_model=bool)
|
||||
async def delete_all_user_chats(request: Request, user=Depends(get_verified_user)):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user