forked from open-webui/open-webui
		
	feat: export all chats from db
admin only
This commit is contained in:
		
							parent
							
								
									c4ca46637e
								
							
						
					
					
						commit
						7c2f297c84
					
				
					 4 changed files with 103 additions and 9 deletions
				
			
		|  | @ -70,9 +70,9 @@ class ChatTable: | |||
|             **{ | ||||
|                 "id": id, | ||||
|                 "user_id": user_id, | ||||
|                 "title": form_data.chat["title"] | ||||
|                 if "title" in form_data.chat | ||||
|                 else "New Chat", | ||||
|                 "title": ( | ||||
|                     form_data.chat["title"] if "title" in form_data.chat else "New Chat" | ||||
|                 ), | ||||
|                 "chat": json.dumps(form_data.chat), | ||||
|                 "timestamp": int(time.time()), | ||||
|             } | ||||
|  | @ -131,6 +131,12 @@ class ChatTable: | |||
|             .order_by(Chat.timestamp.desc()) | ||||
|         ] | ||||
| 
 | ||||
|     def get_all_chats(self) -> List[ChatModel]: | ||||
|         return [ | ||||
|             ChatModel(**model_to_dict(chat)) | ||||
|             for chat in Chat.select().order_by(Chat.timestamp.desc()) | ||||
|         ] | ||||
| 
 | ||||
|     def get_all_chats_by_user_id(self, user_id: str) -> List[ChatModel]: | ||||
|         return [ | ||||
|             ChatModel(**model_to_dict(chat)) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Timothy J. Baek
						Timothy J. Baek