Spaces:
Sleeping
Sleeping
Update conversation_manager.py
Browse files- conversation_manager.py +5 -6
conversation_manager.py
CHANGED
|
@@ -92,7 +92,7 @@ class ConversationManager:
|
|
| 92 |
logger.error(f"Error retrieving history for chat {chat_id}: {e}")
|
| 93 |
return []
|
| 94 |
|
| 95 |
-
def save_history(self, chat_id: str, history: List[Dict[str, Any]]) -> bool:
|
| 96 |
"""
|
| 97 |
Save conversation history for a specific chat ID
|
| 98 |
|
|
@@ -113,8 +113,8 @@ class ConversationManager:
|
|
| 113 |
|
| 114 |
try:
|
| 115 |
# Check if conversation exists
|
| 116 |
-
existing = self.supabase.table('conversations').select('session_id').eq('session_id', chat_id).execute()
|
| 117 |
-
|
| 118 |
if existing.data and len(existing.data) > 0:
|
| 119 |
# Update existing conversation
|
| 120 |
response = self.supabase.table('conversations').update({
|
|
@@ -218,7 +218,7 @@ class ConversationManager:
|
|
| 218 |
logger.error(f"Error deleting history for chat {chat_id}: {e}")
|
| 219 |
return False
|
| 220 |
|
| 221 |
-
def get_all_chat_sessions(self) -> List[Dict[str, Any]]:
|
| 222 |
"""
|
| 223 |
Get all chat sessions with basic information
|
| 224 |
|
|
@@ -226,8 +226,7 @@ class ConversationManager:
|
|
| 226 |
List of dictionaries with chat session information
|
| 227 |
"""
|
| 228 |
try:
|
| 229 |
-
response = self.supabase.table('conversations').select('session_id, history, created_at, updated_at').execute()
|
| 230 |
-
|
| 231 |
sessions = []
|
| 232 |
for conv in response.data:
|
| 233 |
session_id = conv.get('session_id')
|
|
|
|
| 92 |
logger.error(f"Error retrieving history for chat {chat_id}: {e}")
|
| 93 |
return []
|
| 94 |
|
| 95 |
+
def save_history(self, chat_id: str, history: List[Dict[str, Any]], user_id: str) -> bool:
|
| 96 |
"""
|
| 97 |
Save conversation history for a specific chat ID
|
| 98 |
|
|
|
|
| 113 |
|
| 114 |
try:
|
| 115 |
# Check if conversation exists
|
| 116 |
+
existing = self.supabase.table('conversations').select('session_id').eq('session_id', chat_id).eq('user_id', user_id).execute()
|
| 117 |
+
|
| 118 |
if existing.data and len(existing.data) > 0:
|
| 119 |
# Update existing conversation
|
| 120 |
response = self.supabase.table('conversations').update({
|
|
|
|
| 218 |
logger.error(f"Error deleting history for chat {chat_id}: {e}")
|
| 219 |
return False
|
| 220 |
|
| 221 |
+
def get_all_chat_sessions(self, user_id: str) -> List[Dict[str, Any]]:
|
| 222 |
"""
|
| 223 |
Get all chat sessions with basic information
|
| 224 |
|
|
|
|
| 226 |
List of dictionaries with chat session information
|
| 227 |
"""
|
| 228 |
try:
|
| 229 |
+
response = self.supabase.table('conversations').select('session_id, history, created_at, updated_at').eq('user_id', user_id).execute()
|
|
|
|
| 230 |
sessions = []
|
| 231 |
for conv in response.data:
|
| 232 |
session_id = conv.get('session_id')
|