first commit
This commit is contained in:
+38
-12
@@ -96,27 +96,53 @@ class QdrantVectorStore:
|
||||
limit: int = 5,
|
||||
score_threshold: float | None = None,
|
||||
sensor_uuid: str | None = None,
|
||||
kb_name: str | None = None,
|
||||
) -> list[dict]:
|
||||
"""
|
||||
جستجوی شباهت بر اساس query vector.
|
||||
از query_points استفاده میکند (qdrant-client >= 2.0).
|
||||
sensor_uuid: اجباری — فقط chunks مربوط به این سنسور یا __global__ برگردانده میشود.
|
||||
kb_name: اختیاری — فیلتر بر اساس پایگاه دانش (chat/irrigation/fertilization).
|
||||
اگر مشخص شود، فقط chunks همان KB و __all__ برگردانده میشود.
|
||||
"""
|
||||
query_filter = None
|
||||
must_conditions = []
|
||||
|
||||
if sensor_uuid:
|
||||
query_filter = qmodels.Filter(
|
||||
should=[
|
||||
qmodels.FieldCondition(
|
||||
key="sensor_uuid",
|
||||
match=qmodels.MatchValue(value=sensor_uuid),
|
||||
),
|
||||
qmodels.FieldCondition(
|
||||
key="sensor_uuid",
|
||||
match=qmodels.MatchValue(value="__global__"),
|
||||
),
|
||||
]
|
||||
must_conditions.append(
|
||||
qmodels.Filter(
|
||||
should=[
|
||||
qmodels.FieldCondition(
|
||||
key="sensor_uuid",
|
||||
match=qmodels.MatchValue(value=sensor_uuid),
|
||||
),
|
||||
qmodels.FieldCondition(
|
||||
key="sensor_uuid",
|
||||
match=qmodels.MatchValue(value="__global__"),
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
if kb_name:
|
||||
must_conditions.append(
|
||||
qmodels.Filter(
|
||||
should=[
|
||||
qmodels.FieldCondition(
|
||||
key="kb_name",
|
||||
match=qmodels.MatchValue(value=kb_name),
|
||||
),
|
||||
qmodels.FieldCondition(
|
||||
key="kb_name",
|
||||
match=qmodels.MatchValue(value="__all__"),
|
||||
),
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
query_filter = None
|
||||
if must_conditions:
|
||||
query_filter = qmodels.Filter(must=must_conditions)
|
||||
|
||||
response = self.client.query_points(
|
||||
collection_name=self.qdrant.collection_name,
|
||||
query=query_vector,
|
||||
|
||||
Reference in New Issue
Block a user