Skip to content

Commit

Permalink
Merge pull request zylon-ai#822 from VaiTon/fix/env-not-existing
Browse files Browse the repository at this point in the history
Better error message if .env is empty/does not exist.
  • Loading branch information
imartinez authored Aug 28, 2023
2 parents 7b294ed + 28537b6 commit 2940f98
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 5 additions & 4 deletions ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 3 additions & 1 deletion privateGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 2940f98

Please sign in to comment.