SocraticAI / utils /clear_db.py
Deployer
Initial deployment commit with Git LFS tracking
a10a6c0
Raw
History Blame Contribute Delete
688 Bytes
import os
from langchain_chroma import Chroma
from langchain_huggingface import HuggingFaceEmbeddings
from dotenv import load_dotenv
load_dotenv()
CHROMA_PATH = "chroma_db"
def clear_db():
try:
embeddings = HuggingFaceEmbeddings(model_name="all-MiniLM-L6-v2")
vector_store = Chroma(collection_name="socratic_knowledge", embedding_function=embeddings, persist_directory=CHROMA_PATH)
print("Connected to ChromaDB. Deleting collection...")
vector_store.delete_collection()
print("Collection deleted successfully.")
except Exception as e:
print(f"Failed to delete collection via API: {e}")
if __name__ == "__main__":
clear_db()