diff --git a/.gitignore b/.gitignore index ab27d63..424a4c2 100644 --- a/.gitignore +++ b/.gitignore @@ -5,13 +5,15 @@ abandoned/ bin/ datasources/ diskcache_dir/ -docs/recordings/00_chapters.txt +docs/recordings/* etc/ example_projects/ lib/ share/ +tmp/* src/ansari_backend.egg-info/* +.__atomic-write* .env .history *.pyc diff --git a/src/ansari/ansari_db.py b/src/ansari/ansari_db.py index 4641662..5b98015 100644 --- a/src/ansari/ansari_db.py +++ b/src/ansari/ansari_db.py @@ -616,11 +616,11 @@ def get_thread_llm_whatsapp(self, thread_id: str, user_id_whatsapp: int) -> list ORDER BY timestamp; """ result = self._execute_query(select_cmd, (thread_id, user_id_whatsapp), "all")[0] - return ( - [{"role": x[0], "content": x[1], "name": x[2]} if x[2] else {"role": x[0], "content": x[1]} for x in result] - if result - else [] - ) + msgs = [] + for db_row in result: + msgs.extend(self.convert_message_llm(db_row)) + + return msgs except Exception as e: logger.warning(f"Warning (possible error): {e}") return []