Merge pull request #822 from VaiTon/fix/env-not-existing
Better error message if .env is empty/does not exist.
This commit is contained in:
commit
2940f987c0
|
@ -6,6 +6,8 @@ load_dotenv()
|
|||
|
||||
# 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(
|
||||
|
|
|
@ -24,13 +24,14 @@ from langchain.text_splitter import RecursiveCharacterTextSplitter
|
|||
from langchain.vectorstores import Chroma
|
||||
from langchain.embeddings import HuggingFaceEmbeddings
|
||||
from langchain.docstore.document import Document
|
||||
|
||||
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_dotenv()
|
||||
|
||||
|
||||
# Load environment variables
|
||||
persist_directory = os.environ.get('PERSIST_DIRECTORY')
|
||||
source_directory = os.environ.get('SOURCE_DIRECTORY', 'source_documents')
|
||||
|
|
|
@ -10,7 +10,9 @@ import os
|
|||
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')
|
||||
|
|
Loading…
Reference in New Issue