test: verify real kbqa workflow
This commit is contained in:
@@ -14,6 +14,7 @@ class MilvusVectorStore:
|
||||
|
||||
def ensure_collection(self) -> None:
|
||||
if self.client.has_collection(self.collection_name):
|
||||
self.client.load_collection(self.collection_name)
|
||||
return
|
||||
schema = self.client.create_schema(auto_id=False, enable_dynamic_field=False)
|
||||
schema.add_field(
|
||||
@@ -44,6 +45,7 @@ class MilvusVectorStore:
|
||||
schema=schema,
|
||||
index_params=index_params,
|
||||
)
|
||||
self.client.load_collection(self.collection_name)
|
||||
|
||||
def upsert(self, chunks: list[PreparedChunk], vectors: list[list[float]]) -> None:
|
||||
if len(chunks) != len(vectors):
|
||||
@@ -67,7 +69,7 @@ class MilvusVectorStore:
|
||||
data=[vector],
|
||||
anns_field="vector",
|
||||
limit=limit,
|
||||
output_fields=["document_id", "order_index"],
|
||||
output_fields=["chunk_id", "document_id", "order_index"],
|
||||
search_params={"metric_type": "COSINE"},
|
||||
)
|
||||
hits: list[VectorHit] = []
|
||||
@@ -75,7 +77,7 @@ class MilvusVectorStore:
|
||||
entity = item.get("entity", {})
|
||||
hits.append(
|
||||
VectorHit(
|
||||
chunk_id=str(item["id"]),
|
||||
chunk_id=str(entity["chunk_id"]),
|
||||
document_id=str(entity["document_id"]),
|
||||
order_index=int(entity["order_index"]),
|
||||
score=float(item["distance"]),
|
||||
|
||||
Reference in New Issue
Block a user