Update main/chatbot.py
Browse files- main/chatbot.py +16 -4
main/chatbot.py
CHANGED
|
@@ -76,7 +76,10 @@ class VietnameseLegalRAG:
|
|
| 76 |
|
| 77 |
if force_rebuild:
|
| 78 |
print("Force rebuild requested - recreating vector store...")
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
| 80 |
self.vector_store.add_documents(documents)
|
| 81 |
elif not has_documents:
|
| 82 |
print("Collection exists but is empty - adding documents...")
|
|
@@ -87,20 +90,29 @@ class VietnameseLegalRAG:
|
|
| 87 |
print(f"Could not get collection info: {info_e}")
|
| 88 |
if force_rebuild:
|
| 89 |
print("Force rebuild requested - recreating vector store...")
|
| 90 |
-
|
|
|
|
|
|
|
|
|
|
| 91 |
self.vector_store.add_documents(documents)
|
| 92 |
else:
|
| 93 |
print("Assuming collection has documents - skipping setup")
|
| 94 |
else:
|
| 95 |
# Collection doesn't exist, create it
|
| 96 |
print("Collection does not exist - creating new collection...")
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
| 98 |
self.vector_store.add_documents(documents)
|
| 99 |
|
| 100 |
except Exception as e:
|
| 101 |
print(f"Error during vector store setup: {e}")
|
| 102 |
print("Attempting to create collection...")
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
| 104 |
self.vector_store.add_documents(documents)
|
| 105 |
|
| 106 |
# Setup BM25 index
|
|
|
|
| 76 |
|
| 77 |
if force_rebuild:
|
| 78 |
print("Force rebuild requested - recreating vector store...")
|
| 79 |
+
if Config.EMBEDDING_MODEL == "bkai-foundation-models/vietnamese-bi-encoder":
|
| 80 |
+
self.vector_store.create_collection(force_recreate=True, vector_size=768)
|
| 81 |
+
else:
|
| 82 |
+
self.vector_store.create_collection(force_recreate=True)
|
| 83 |
self.vector_store.add_documents(documents)
|
| 84 |
elif not has_documents:
|
| 85 |
print("Collection exists but is empty - adding documents...")
|
|
|
|
| 90 |
print(f"Could not get collection info: {info_e}")
|
| 91 |
if force_rebuild:
|
| 92 |
print("Force rebuild requested - recreating vector store...")
|
| 93 |
+
if Config.EMBEDDING_MODEL == "bkai-foundation-models/vietnamese-bi-encoder":
|
| 94 |
+
self.vector_store.create_collection(force_recreate=True, vector_size=768)
|
| 95 |
+
else:
|
| 96 |
+
self.vector_store.create_collection(force_recreate=True)
|
| 97 |
self.vector_store.add_documents(documents)
|
| 98 |
else:
|
| 99 |
print("Assuming collection has documents - skipping setup")
|
| 100 |
else:
|
| 101 |
# Collection doesn't exist, create it
|
| 102 |
print("Collection does not exist - creating new collection...")
|
| 103 |
+
if Config.EMBEDDING_MODEL == "bkai-foundation-models/vietnamese-bi-encoder":
|
| 104 |
+
self.vector_store.create_collection(force_recreate=True, vector_size=768)
|
| 105 |
+
else:
|
| 106 |
+
self.vector_store.create_collection(force_recreate=True)
|
| 107 |
self.vector_store.add_documents(documents)
|
| 108 |
|
| 109 |
except Exception as e:
|
| 110 |
print(f"Error during vector store setup: {e}")
|
| 111 |
print("Attempting to create collection...")
|
| 112 |
+
if Config.EMBEDDING_MODEL == "bkai-foundation-models/vietnamese-bi-encoder":
|
| 113 |
+
self.vector_store.create_collection(force_recreate=True, vector_size=768)
|
| 114 |
+
else:
|
| 115 |
+
self.vector_store.create_collection(force_recreate=True)
|
| 116 |
self.vector_store.add_documents(documents)
|
| 117 |
|
| 118 |
# Setup BM25 index
|