tdecae commited on
Commit
1a97bfa
1 Parent(s): 53a8189

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -2
app.py CHANGED
@@ -119,8 +119,14 @@ embeddings = embedding_model.encode(texts).tolist() # Convert numpy arrays to l
119
 
120
  # Create a Chroma vector store and add documents and their embeddings
121
  vectorstore = Chroma(persist_directory="./data")
122
- for i, (text, embedding) in enumerate(zip(texts, embeddings)):
123
- vectorstore.add_texts([text], metadatas=[{"id": i}], embeddings=[embedding])
 
 
 
 
 
 
124
  vectorstore.persist()
125
 
126
  # Load the Hugging Face model for text generation
@@ -180,3 +186,4 @@ demo.launch(debug=True)
180
 
181
 
182
 
 
 
119
 
120
  # Create a Chroma vector store and add documents and their embeddings
121
  vectorstore = Chroma(persist_directory="./data")
122
+ vectorstore.add_texts(texts)
123
+ for i, embedding in enumerate(embeddings):
124
+ vectorstore._collection.upsert(
125
+ ids=[str(i)],
126
+ embeddings=[embedding],
127
+ metadatas=[{"id": i}],
128
+ documents=[texts[i]]
129
+ )
130
  vectorstore.persist()
131
 
132
  # Load the Hugging Face model for text generation
 
186
 
187
 
188
 
189
+