tdecae commited on
Commit
f2e7370
1 Parent(s): 6fc6073

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -1
app.py CHANGED
@@ -117,8 +117,12 @@ embedding_model = SentenceTransformer("sentence-transformers/all-MiniLM-L6-v2")
117
  texts = [doc.page_content for doc in docs]
118
  embeddings = embedding_model.encode(texts).tolist() # Convert numpy arrays to lists
119
 
 
 
 
 
120
  # Create a Chroma vector store with an embedding function and add documents and their embeddings
121
- vectorstore = Chroma(persist_directory="./db", embedding_function=embedding_model.encode)
122
  vectorstore.add_texts(texts=texts, metadatas=[{"id": i} for i in range(len(texts))], embeddings=embeddings)
123
  vectorstore.persist()
124
 
@@ -182,3 +186,4 @@ demo.launch(debug=True)
182
 
183
 
184
 
 
 
117
  texts = [doc.page_content for doc in docs]
118
  embeddings = embedding_model.encode(texts).tolist() # Convert numpy arrays to lists
119
 
120
+ # Create a wrapper function for the embedding function
121
+ def embedding_function(texts):
122
+ return embedding_model.encode(texts).tolist()
123
+
124
  # Create a Chroma vector store with an embedding function and add documents and their embeddings
125
+ vectorstore = Chroma(persist_directory="./db", embedding_function=embedding_function)
126
  vectorstore.add_texts(texts=texts, metadatas=[{"id": i} for i in range(len(texts))], embeddings=embeddings)
127
  vectorstore.persist()
128
 
 
186
 
187
 
188
 
189
+