Chris4K commited on
Commit
881505f
1 Parent(s): 488e992

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -1
app.py CHANGED
@@ -186,8 +186,18 @@ def get_text_splitter(split_strategy, chunk_size, overlap_size, custom_separator
186
  else:
187
  raise ValueError(f"Unsupported split strategy: {split_strategy}")
188
 
189
- @lru_cache(maxsize=None)
190
  def get_vector_store(vector_store_type, chunks, embedding_model):
 
 
 
 
 
 
 
 
 
 
 
191
  if vector_store_type == 'FAISS':
192
  return FAISS.from_texts(chunks, embedding_model)
193
  elif vector_store_type == 'Chroma':
@@ -195,6 +205,7 @@ def get_vector_store(vector_store_type, chunks, embedding_model):
195
  else:
196
  raise ValueError(f"Unsupported vector store type: {vector_store_type}")
197
 
 
198
  def get_retriever(vector_store, search_type, search_kwargs):
199
  if search_type == 'similarity':
200
  return vector_store.as_retriever(search_type="similarity", search_kwargs=search_kwargs)
 
186
  else:
187
  raise ValueError(f"Unsupported split strategy: {split_strategy}")
188
 
 
189
  def get_vector_store(vector_store_type, chunks, embedding_model):
190
+ # Convert chunks to a tuple to make it hashable
191
+ chunks_tuple = tuple(chunks)
192
+
193
+ # Use a helper function for the actual vector store creation
194
+ return _create_vector_store(vector_store_type, chunks_tuple, embedding_model)
195
+
196
+ @lru_cache(maxsize=None)
197
+ def _create_vector_store(vector_store_type, chunks_tuple, embedding_model):
198
+ # Convert the tuple back to a list for use with the vector store
199
+ chunks = list(chunks_tuple)
200
+
201
  if vector_store_type == 'FAISS':
202
  return FAISS.from_texts(chunks, embedding_model)
203
  elif vector_store_type == 'Chroma':
 
205
  else:
206
  raise ValueError(f"Unsupported vector store type: {vector_store_type}")
207
 
208
+
209
  def get_retriever(vector_store, search_type, search_kwargs):
210
  if search_type == 'similarity':
211
  return vector_store.as_retriever(search_type="similarity", search_kwargs=search_kwargs)