diff --git a/ai_ta_backend/vector_database.py b/ai_ta_backend/vector_database.py index fabbc999..ef4425ad 100644 --- a/ai_ta_backend/vector_database.py +++ b/ai_ta_backend/vector_database.py @@ -1745,6 +1745,8 @@ def append_doc_group(self, course_name: str, doc: MaterialDocument, doc_group: s """ Append a document group to a document's doc_groups array. """ + if doc.doc_groups is None: + doc.doc_groups = [] if doc_group not in doc.doc_groups: doc.doc_groups.append(doc_group) self.add_documents_to_doc_group(course_name, doc) @@ -1753,6 +1755,8 @@ def remove_doc_group(self, course_name: str, doc: MaterialDocument, doc_group: s """ Remove a document group from a document's doc_groups array. """ + if doc.doc_groups is None: + doc.doc_groups = [] if doc_group in doc.doc_groups: doc.doc_groups.remove(doc_group) self.add_documents_to_doc_group(course_name, doc)