mirror of
https://github.com/wassname/stampy-chat.git
synced 2026-09-10 12:40:44 +08:00
Implemented upsert_entries in the Pinecone handler
This commit is contained in:
@@ -50,11 +50,38 @@ class PineconeDB:
|
||||
),
|
||||
batch_size=upsert_size
|
||||
)
|
||||
|
||||
|
||||
def upsert_entries(self, entries_batch, chunks_batch, chunks_ids_batch, embeddings, upsert_size=100):
|
||||
self.index.upsert(
|
||||
vectors=list(
|
||||
zip(
|
||||
chunks_ids_batch,
|
||||
embeddings.tolist(),
|
||||
[
|
||||
{
|
||||
'entry_id': entry['id'],
|
||||
'source': entry['source'],
|
||||
'title': entry['title'],
|
||||
'authors': entry['authors'],
|
||||
'text': chunk,
|
||||
}
|
||||
for entry in entries_batch
|
||||
for chunk in chunks_batch
|
||||
]
|
||||
)
|
||||
),
|
||||
batch_size=upsert_size
|
||||
)
|
||||
|
||||
def delete_entry(self, id):
|
||||
self.index.delete(
|
||||
filter={"entry_id": {"$eq": id}}
|
||||
)
|
||||
|
||||
def delete_entries(self, ids):
|
||||
self.index.delete(
|
||||
filter={"entry_id": {"$in": ids}}
|
||||
)
|
||||
|
||||
def create_index(self, replace_current_index: bool = True):
|
||||
if replace_current_index:
|
||||
|
||||
Reference in New Issue
Block a user