diff --git a/constants.py b/constants.py index d5e4383..ea7b7ef 100644 --- a/constants.py +++ b/constants.py @@ -1,7 +1,11 @@ +import os +from dotenv import load_dotenv from chromadb.config import Settings +load_dotenv() + # Define the folder for storing database -PERSIST_DIRECTORY = 'db' +PERSIST_DIRECTORY = os.environ.get('PERSIST_DIRECTORY') # Define the Chroma settings CHROMA_SETTINGS = Settings( diff --git a/ingest.py b/ingest.py index 79434b3..1200da0 100644 --- a/ingest.py +++ b/ingest.py @@ -4,7 +4,6 @@ from langchain.document_loaders import TextLoader, PDFMinerLoader, CSVLoader from langchain.text_splitter import RecursiveCharacterTextSplitter from langchain.vectorstores import Chroma from langchain.embeddings import LlamaCppEmbeddings -from constants import PERSIST_DIRECTORY from constants import CHROMA_SETTINGS load_dotenv() @@ -28,7 +27,7 @@ def main(): # Create embeddings llama = LlamaCppEmbeddings(model_path=llama_embeddings_model, n_ctx=model_n_ctx) # Create and store locally vectorstore - db = Chroma.from_documents(texts, llama, persist_directory=PERSIST_DIRECTORY, client_settings=CHROMA_SETTINGS) + db = Chroma.from_documents(texts, llama, persist_directory=persist_directory, client_settings=CHROMA_SETTINGS) db.persist() db = None