Spaces:
Running
Running
Update app/policy_vector_db.py
Browse files- app/policy_vector_db.py +5 -4
app/policy_vector_db.py
CHANGED
|
@@ -8,10 +8,10 @@ from sentence_transformers import SentenceTransformer
|
|
| 8 |
|
| 9 |
class PolicyVectorDB:
|
| 10 |
"""Manages the creation and searching of a persistent vector database."""
|
| 11 |
-
def __init__(self, persist_directory: str = "
|
| 12 |
self.client = chromadb.PersistentClient(path=persist_directory)
|
| 13 |
self.collection_name = "neepco_dop_policies"
|
| 14 |
-
self.embedding_model = SentenceTransformer('BAAI/bge-large-en-v1.5', device
|
| 15 |
self.collection = self.client.get_or_create_collection(
|
| 16 |
name=self.collection_name,
|
| 17 |
metadata={"description": "NEEPCO Delegation of Powers Policy"}
|
|
@@ -75,7 +75,8 @@ class PolicyVectorDB:
|
|
| 75 |
|
| 76 |
def main():
|
| 77 |
"""Main function to build and verify the vector database."""
|
| 78 |
-
|
|
|
|
| 79 |
PERSIST_DIRECTORY = "/tmp/policy_vector_db"
|
| 80 |
|
| 81 |
if not os.path.exists(INPUT_CHUNKS_PATH):
|
|
@@ -125,4 +126,4 @@ def main():
|
|
| 125 |
print(" No results found.")
|
| 126 |
|
| 127 |
if __name__ == "__main__":
|
| 128 |
-
main()
|
|
|
|
| 8 |
|
| 9 |
class PolicyVectorDB:
|
| 10 |
"""Manages the creation and searching of a persistent vector database."""
|
| 11 |
+
def __init__(self, persist_directory: str = "/tmp/policy_vector_db"):
|
| 12 |
self.client = chromadb.PersistentClient(path=persist_directory)
|
| 13 |
self.collection_name = "neepco_dop_policies"
|
| 14 |
+
self.embedding_model = SentenceTransformer('BAAI/bge-large-en-v1.5', device='cpu')
|
| 15 |
self.collection = self.client.get_or_create_collection(
|
| 16 |
name=self.collection_name,
|
| 17 |
metadata={"description": "NEEPCO Delegation of Powers Policy"}
|
|
|
|
| 75 |
|
| 76 |
def main():
|
| 77 |
"""Main function to build and verify the vector database."""
|
| 78 |
+
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 79 |
+
INPUT_CHUNKS_PATH = os.path.join(BASE_DIR, "../processed_chunks.json")
|
| 80 |
PERSIST_DIRECTORY = "/tmp/policy_vector_db"
|
| 81 |
|
| 82 |
if not os.path.exists(INPUT_CHUNKS_PATH):
|
|
|
|
| 126 |
print(" No results found.")
|
| 127 |
|
| 128 |
if __name__ == "__main__":
|
| 129 |
+
main()
|