mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-09 16:18:30 +00:00
fix: Update metadata type handling in KnowledgeStorage
Co-Authored-By: Joe Moura <joao@crewai.com>
This commit is contained in:
@@ -154,13 +154,15 @@ class KnowledgeStorage(BaseKnowledgeStorage):
|
||||
filtered_ids.append(doc_id)
|
||||
|
||||
# If we have no metadata at all, set it to None
|
||||
final_metadata: Optional[List[Dict[str, Union[str, int, float, bool]]]] = (
|
||||
None if all(m is None for m in filtered_metadata) else [
|
||||
{k: v for k, v in m.items() if isinstance(v, (str, int, float, bool))}
|
||||
if m is not None else None
|
||||
for m in filtered_metadata
|
||||
]
|
||||
)
|
||||
final_metadata: Optional[List[Dict[str, Union[str, int, float, bool]]]] = None
|
||||
if not all(m is None for m in filtered_metadata):
|
||||
final_metadata = []
|
||||
for m in filtered_metadata:
|
||||
if m is not None:
|
||||
filtered_m = {k: v for k, v in m.items() if isinstance(v, (str, int, float, bool))}
|
||||
final_metadata.append(filtered_m)
|
||||
else:
|
||||
final_metadata.append({"empty": True})
|
||||
|
||||
self.collection.upsert(
|
||||
documents=filtered_docs,
|
||||
|
||||
Reference in New Issue
Block a user