Skip to content

Commit e7d0ab8

Browse files
authored
fix: insert in vector db passes only last chunk meta_data (#3363)
## Summary insert in vector db passes only last chunk meta_data Issue- https://discord.com/channels/965734768803192842/1219054452221153463/1376631140047130649 (If applicable, issue number: #____) ## Type of change - [x] Bug fix - [ ] New feature - [ ] Breaking change - [ ] Improvement - [ ] Model update - [ ] Other: --- ## Checklist - [x] Code complies with style guidelines - [x] Ran format/validation scripts (`./scripts/format.sh` and `./scripts/validate.sh`) - [x] Self-review completed - [ ] Documentation updated (comments, docstrings) - [ ] Examples and guides: Relevant cookbook examples have been included or updated (if applicable) - [x] Tested in clean environment - [ ] Tests added/updated (if applicable) --- ## Additional Notes Add any important context (deployment instructions, screenshots, security considerations, etc.)
1 parent ac1b411 commit e7d0ab8

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libs/agno/agno/knowledge/agent.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def load(
123123

124124
# Upsert documents if upsert is True and vector db supports upsert
125125
if upsert and self.vector_db.upsert_available():
126-
self.vector_db.upsert(documents=document_list, filters=doc.meta_data)
126+
for doc in document_list:
127+
self.vector_db.upsert(documents=[doc], filters=doc.meta_data)
127128
# Insert documents
128129
else:
129130
# Filter out documents which already exist in the vector db
@@ -132,7 +133,8 @@ def load(
132133
documents_to_load = self.filter_existing_documents(document_list)
133134

134135
if documents_to_load:
135-
self.vector_db.insert(documents=documents_to_load, filters=doc.meta_data)
136+
for doc in documents_to_load:
137+
self.vector_db.insert(documents=[doc], filters=doc.meta_data)
136138

137139
num_documents += len(documents_to_load)
138140
log_info(f"Added {len(documents_to_load)} documents to knowledge base")
@@ -174,7 +176,8 @@ async def aload(
174176

175177
# Upsert documents if upsert is True and vector db supports upsert
176178
if upsert and self.vector_db.upsert_available():
177-
await self.vector_db.async_upsert(documents=document_list, filters=doc.meta_data)
179+
for doc in document_list:
180+
await self.vector_db.async_upsert(documents=[doc], filters=doc.meta_data)
178181
# Insert documents
179182
else:
180183
# Filter out documents which already exist in the vector db
@@ -183,7 +186,8 @@ async def aload(
183186
documents_to_load = self.filter_existing_documents(document_list)
184187

185188
if documents_to_load:
186-
await self.vector_db.async_insert(documents=documents_to_load, filters=doc.meta_data)
189+
for doc in documents_to_load:
190+
await self.vector_db.async_insert(documents=[doc], filters=doc.meta_data)
187191

188192
num_documents += len(documents_to_load)
189193
log_info(f"Added {len(documents_to_load)} documents to knowledge base")

0 commit comments

Comments
 (0)