update chat history
Browse files
modules/chatbot/sidebar_chat.py
CHANGED
|
@@ -107,7 +107,7 @@ def display_sidebar_chat(lang_code: str, chatbot_t: dict):
|
|
| 107 |
store_chat_history(
|
| 108 |
username=st.session_state.username,
|
| 109 |
messages=st.session_state.sidebar_messages,
|
| 110 |
-
|
| 111 |
metadata={
|
| 112 |
'text_sample': st.session_state.semantic_agent_data['text'][:500],
|
| 113 |
'concepts': st.session_state.semantic_agent_data['metrics']['key_concepts'][:5]
|
|
|
|
| 107 |
store_chat_history(
|
| 108 |
username=st.session_state.username,
|
| 109 |
messages=st.session_state.sidebar_messages,
|
| 110 |
+
analysis_type='semantic_analysis',
|
| 111 |
metadata={
|
| 112 |
'text_sample': st.session_state.semantic_agent_data['text'][:500],
|
| 113 |
'concepts': st.session_state.semantic_agent_data['metrics']['key_concepts'][:5]
|
modules/database/chat_mongo_db.py
CHANGED
|
@@ -45,9 +45,13 @@ def get_chat_history(username: str, analysis_type: str = 'sidebar', limit: int =
|
|
| 45 |
"""
|
| 46 |
try:
|
| 47 |
query = {
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
collection = get_collection(COLLECTION_NAME)
|
| 53 |
if collection is None:
|
|
@@ -88,6 +92,7 @@ def get_chat_history(username: str, analysis_type: str = 'sidebar', limit: int =
|
|
| 88 |
logger.error(f"Error al recuperar historial de chat: {str(e)}")
|
| 89 |
return []
|
| 90 |
|
|
|
|
| 91 |
def store_chat_history(username: str, messages: list, analysis_type: str = 'sidebar', metadata: dict = None) -> bool:
|
| 92 |
"""
|
| 93 |
Guarda el historial del chat con codificaci贸n UTF-8 segura.
|
|
|
|
| 45 |
"""
|
| 46 |
try:
|
| 47 |
query = {
|
| 48 |
+
"username": username,
|
| 49 |
+
"$or": [
|
| 50 |
+
{"analysis_type": analysis_type},
|
| 51 |
+
{"analysis_type": {"$exists": False}},
|
| 52 |
+
{"analysis_type": None}
|
| 53 |
+
]
|
| 54 |
+
}
|
| 55 |
|
| 56 |
collection = get_collection(COLLECTION_NAME)
|
| 57 |
if collection is None:
|
|
|
|
| 92 |
logger.error(f"Error al recuperar historial de chat: {str(e)}")
|
| 93 |
return []
|
| 94 |
|
| 95 |
+
|
| 96 |
def store_chat_history(username: str, messages: list, analysis_type: str = 'sidebar', metadata: dict = None) -> bool:
|
| 97 |
"""
|
| 98 |
Guarda el historial del chat con codificaci贸n UTF-8 segura.
|