Spaces:
Sleeping
Sleeping
DrishtiSharma
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -135,15 +135,22 @@ def initialize_vector_store(documents, persist_dir):
|
|
135 |
"""
|
136 |
Initialize the vector store with the provided documents.
|
137 |
"""
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
|
|
|
|
|
|
|
|
146 |
|
|
|
|
|
|
|
147 |
|
148 |
def create_retriever(vectordb):
|
149 |
"""
|
|
|
135 |
"""
|
136 |
Initialize the vector store with the provided documents.
|
137 |
"""
|
138 |
+
try:
|
139 |
+
# Initialize HuggingFace embeddings
|
140 |
+
embeddings = HuggingFaceEmbeddings()
|
141 |
+
|
142 |
+
# Create a Chroma vector store with the embeddings
|
143 |
+
vectordb = Chroma.from_documents(
|
144 |
+
documents=documents,
|
145 |
+
embedding=embeddings, # Pass embeddings directly
|
146 |
+
persist_directory=persist_dir
|
147 |
+
)
|
148 |
+
vectordb.persist() # Persist the vector store to disk
|
149 |
+
return vectordb
|
150 |
|
151 |
+
except Exception as e:
|
152 |
+
st.error(f"Failed to initialize the vector store: {e}")
|
153 |
+
st.stop()
|
154 |
|
155 |
def create_retriever(vectordb):
|
156 |
"""
|