Fix linting
This commit is contained in:
@@ -115,8 +115,9 @@ class ChromaVectorDBStorage(BaseVectorStorage):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
import time
|
import time
|
||||||
|
|
||||||
current_time = int(time.time())
|
current_time = int(time.time())
|
||||||
|
|
||||||
ids = list(data.keys())
|
ids = list(data.keys())
|
||||||
documents = [v["content"] for v in data.values()]
|
documents = [v["content"] for v in data.values()]
|
||||||
metadatas = [
|
metadatas = [
|
||||||
|
@@ -425,7 +425,11 @@ class FaissVectorDBStorage(BaseVectorStorage):
|
|||||||
if not metadata:
|
if not metadata:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
return {**metadata, "id": metadata.get("__id__"), "created_at": metadata.get("__created_at__")}
|
return {
|
||||||
|
**metadata,
|
||||||
|
"id": metadata.get("__id__"),
|
||||||
|
"created_at": metadata.get("__created_at__"),
|
||||||
|
}
|
||||||
|
|
||||||
async def get_by_ids(self, ids: list[str]) -> list[dict[str, Any]]:
|
async def get_by_ids(self, ids: list[str]) -> list[dict[str, Any]]:
|
||||||
"""Get multiple vector data by their IDs
|
"""Get multiple vector data by their IDs
|
||||||
@@ -445,7 +449,13 @@ class FaissVectorDBStorage(BaseVectorStorage):
|
|||||||
if fid is not None:
|
if fid is not None:
|
||||||
metadata = self._id_to_meta.get(fid, {})
|
metadata = self._id_to_meta.get(fid, {})
|
||||||
if metadata:
|
if metadata:
|
||||||
results.append({**metadata, "id": metadata.get("__id__"), "created_at": metadata.get("__created_at__")})
|
results.append(
|
||||||
|
{
|
||||||
|
**metadata,
|
||||||
|
"id": metadata.get("__id__"),
|
||||||
|
"created_at": metadata.get("__created_at__"),
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
@@ -80,8 +80,9 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|||||||
return
|
return
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
current_time = int(time.time())
|
current_time = int(time.time())
|
||||||
|
|
||||||
list_data: list[dict[str, Any]] = [
|
list_data: list[dict[str, Any]] = [
|
||||||
{
|
{
|
||||||
"id": k,
|
"id": k,
|
||||||
@@ -124,10 +125,10 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|||||||
print(results)
|
print(results)
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
**dp["entity"],
|
**dp["entity"],
|
||||||
"id": dp["id"],
|
"id": dp["id"],
|
||||||
"distance": dp["distance"],
|
"distance": dp["distance"],
|
||||||
"created_at": dp["entity"].get("created_at")
|
"created_at": dp["entity"].get("created_at"),
|
||||||
}
|
}
|
||||||
for dp in results[0]
|
for dp in results[0]
|
||||||
]
|
]
|
||||||
@@ -268,7 +269,7 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|||||||
# Ensure the result contains created_at field
|
# Ensure the result contains created_at field
|
||||||
if "created_at" not in result[0]:
|
if "created_at" not in result[0]:
|
||||||
result[0]["created_at"] = None
|
result[0]["created_at"] = None
|
||||||
|
|
||||||
return result[0]
|
return result[0]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error retrieving vector data for ID {id}: {e}")
|
logger.error(f"Error retrieving vector data for ID {id}: {e}")
|
||||||
@@ -297,12 +298,12 @@ class MilvusVectorDBStorage(BaseVectorStorage):
|
|||||||
filter=filter_expr,
|
filter=filter_expr,
|
||||||
output_fields=list(self.meta_fields) + ["id", "created_at"],
|
output_fields=list(self.meta_fields) + ["id", "created_at"],
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure each result contains created_at field
|
# Ensure each result contains created_at field
|
||||||
for item in result:
|
for item in result:
|
||||||
if "created_at" not in item:
|
if "created_at" not in item:
|
||||||
item["created_at"] = None
|
item["created_at"] = None
|
||||||
|
|
||||||
return result or []
|
return result or []
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error retrieving vector data for IDs {ids}: {e}")
|
logger.error(f"Error retrieving vector data for IDs {ids}: {e}")
|
||||||
|
@@ -1001,8 +1001,9 @@ class MongoVectorDBStorage(BaseVectorStorage):
|
|||||||
|
|
||||||
# Add current time as Unix timestamp
|
# Add current time as Unix timestamp
|
||||||
import time
|
import time
|
||||||
|
|
||||||
current_time = int(time.time())
|
current_time = int(time.time())
|
||||||
|
|
||||||
list_data = [
|
list_data = [
|
||||||
{
|
{
|
||||||
"_id": k,
|
"_id": k,
|
||||||
@@ -1067,10 +1068,10 @@ class MongoVectorDBStorage(BaseVectorStorage):
|
|||||||
# Format and return the results with created_at field
|
# Format and return the results with created_at field
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
**doc,
|
**doc,
|
||||||
"id": doc["_id"],
|
"id": doc["_id"],
|
||||||
"distance": doc.get("score", None),
|
"distance": doc.get("score", None),
|
||||||
"created_at": doc.get("created_at") # Include created_at field
|
"created_at": doc.get("created_at"), # Include created_at field
|
||||||
}
|
}
|
||||||
for doc in results
|
for doc in results
|
||||||
]
|
]
|
||||||
@@ -1165,10 +1166,10 @@ class MongoVectorDBStorage(BaseVectorStorage):
|
|||||||
# Format results, ensuring created_at is included
|
# Format results, ensuring created_at is included
|
||||||
results = [
|
results = [
|
||||||
{
|
{
|
||||||
**doc,
|
**doc,
|
||||||
"id": doc["_id"],
|
"id": doc["_id"],
|
||||||
"created_at": doc.get("created_at") # Include created_at field
|
"created_at": doc.get("created_at"), # Include created_at field
|
||||||
}
|
}
|
||||||
for doc in matching_records
|
for doc in matching_records
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@@ -88,10 +88,11 @@ class QdrantVectorDBStorage(BaseVectorStorage):
|
|||||||
logger.info(f"Inserting {len(data)} to {self.namespace}")
|
logger.info(f"Inserting {len(data)} to {self.namespace}")
|
||||||
if not data:
|
if not data:
|
||||||
return
|
return
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
current_time = int(time.time())
|
current_time = int(time.time())
|
||||||
|
|
||||||
list_data = [
|
list_data = [
|
||||||
{
|
{
|
||||||
"id": k,
|
"id": k,
|
||||||
@@ -144,10 +145,10 @@ class QdrantVectorDBStorage(BaseVectorStorage):
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
**dp.payload,
|
**dp.payload,
|
||||||
"distance": dp.score,
|
"distance": dp.score,
|
||||||
"created_at": dp.payload.get("created_at")
|
"created_at": dp.payload.get("created_at"),
|
||||||
}
|
}
|
||||||
for dp in results
|
for dp in results
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -310,12 +311,12 @@ class QdrantVectorDBStorage(BaseVectorStorage):
|
|||||||
|
|
||||||
if not result:
|
if not result:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
# Ensure the result contains created_at field
|
# Ensure the result contains created_at field
|
||||||
payload = result[0].payload
|
payload = result[0].payload
|
||||||
if "created_at" not in payload:
|
if "created_at" not in payload:
|
||||||
payload["created_at"] = None
|
payload["created_at"] = None
|
||||||
|
|
||||||
return payload
|
return payload
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error retrieving vector data for ID {id}: {e}")
|
logger.error(f"Error retrieving vector data for ID {id}: {e}")
|
||||||
@@ -343,7 +344,7 @@ class QdrantVectorDBStorage(BaseVectorStorage):
|
|||||||
ids=qdrant_ids,
|
ids=qdrant_ids,
|
||||||
with_payload=True,
|
with_payload=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure each result contains created_at field
|
# Ensure each result contains created_at field
|
||||||
payloads = []
|
payloads = []
|
||||||
for point in results:
|
for point in results:
|
||||||
@@ -351,7 +352,7 @@ class QdrantVectorDBStorage(BaseVectorStorage):
|
|||||||
if "created_at" not in payload:
|
if "created_at" not in payload:
|
||||||
payload["created_at"] = None
|
payload["created_at"] = None
|
||||||
payloads.append(payload)
|
payloads.append(payload)
|
||||||
|
|
||||||
return payloads
|
return payloads
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Error retrieving vector data for IDs {ids}: {e}")
|
logger.error(f"Error retrieving vector data for IDs {ids}: {e}")
|
||||||
|
Reference in New Issue
Block a user