diff --git a/context_chat_backend/vectordb/pgvector.py b/context_chat_backend/vectordb/pgvector.py index 217aa34..513c8aa 100644 --- a/context_chat_backend/vectordb/pgvector.py +++ b/context_chat_backend/vectordb/pgvector.py @@ -127,20 +127,10 @@ def add_indocuments(self, indocuments: list[InDocument]) -> list[str]: modified=datetime.fromtimestamp(indoc.modified), chunks=chunk_ids, ) - - access = [ - AccessListStore( - uid=user_id, - source_id=indoc.source_id, - ) - for user_id in indoc.userIds - ] - session.add(doc) session.commit() - session.add_all(access) - session.commit() + self.decl_update_access(indoc.userIds, indoc.source_id, session) added_sources.append(indoc.source_id) except Exception as e: log_error('Error adding documents to vectordb:', e) @@ -206,6 +196,7 @@ def decl_update_access(self, user_ids: list[str], source_id: str, session_: orm. .filter(AccessListStore.source_id == source_id) ) session.execute(stmt) + session.commit() access = [ AccessListStore(