diff --git a/constants.py b/constants.py index cae3c101f..5a10f5d1b 100644 --- a/constants.py +++ b/constants.py @@ -6,6 +6,8 @@ # Define the folder for storing database PERSIST_DIRECTORY = os.environ.get('PERSIST_DIRECTORY') +if PERSIST_DIRECTORY is None: + raise Exception("Please set the PERSIST_DIRECTORY environment variable") # Define the Chroma settings CHROMA_SETTINGS = Settings( diff --git a/ingest.py b/ingest.py index b24b30236..d7a663513 100755 --- a/ingest.py +++ b/ingest.py @@ -24,12 +24,13 @@ from langchain.vectorstores import Chroma from langchain.embeddings import HuggingFaceEmbeddings from langchain.docstore.document import Document -from constants import CHROMA_SETTINGS -import chromadb - -load_dotenv() +if not load_dotenv(): + print("Could not load .env file or it is empty. Please check if it exists and is readable.") + exit(1) +from constants import CHROMA_SETTINGS +import chromadb # Load environment variables persist_directory = os.environ.get('PERSIST_DIRECTORY') diff --git a/privateGPT.py b/privateGPT.py index e8bd58792..75603c2c2 100755 --- a/privateGPT.py +++ b/privateGPT.py @@ -10,7 +10,9 @@ import argparse import time -load_dotenv() +if not load_dotenv(): + print("Could not load .env file or it is empty. Please check if it exists and is readable.") + exit(1) embeddings_model_name = os.environ.get("EMBEDDINGS_MODEL_NAME") persist_directory = os.environ.get('PERSIST_DIRECTORY')