Update app.py
Browse files
app.py
CHANGED
|
@@ -45,15 +45,15 @@ def create_retriever_from_chroma(vectorstore_path="docs/chroma/", search_type='m
|
|
| 45 |
|
| 46 |
|
| 47 |
# Check if vectorstore exists
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
# Load documents from the specified data path
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
|
| 58 |
|
| 59 |
|
|
|
|
| 45 |
|
| 46 |
|
| 47 |
# Check if vectorstore exists
|
| 48 |
+
if os.path.exists(vectorstore_path) and os.listdir(vectorstore_path):
|
| 49 |
+
# Load the existing vectorstore
|
| 50 |
+
vectorstore = Chroma(persist_directory=vectorstore_path,embedding_function=embeddings)
|
| 51 |
+
else:
|
| 52 |
# Load documents from the specified data path
|
| 53 |
+
loader = DirectoryLoader('./data/', glob="./*.txt", loader_cls=TextLoader)
|
| 54 |
+
docs = loader.load()
|
| 55 |
+
text_splitter = RecursiveCharacterTextSplitter(chunk_size=chunk_size, chunk_overlap=chunk_overlap)
|
| 56 |
+
split_docs = text_splitter.split_documents(docs)
|
| 57 |
|
| 58 |
|
| 59 |
|