[Feature] Update db.query to return source of context (#831)
This commit is contained in:
@@ -123,7 +123,7 @@ class TestZillizDBCollection:
|
||||
# Mock the MilvusClient search method
|
||||
with patch.object(zilliz_db.client, "search") as mock_search:
|
||||
# Mock the search result
|
||||
mock_search.return_value = [[{"entity": {"text": "result_doc"}}]]
|
||||
mock_search.return_value = [[{"entity": {"text": "result_doc", "url": "url_1", "doc_id": "doc_id_1"}}]]
|
||||
|
||||
# Call the query method with skip_embedding=True
|
||||
query_result = zilliz_db.query(input_query=["query_text"], n_results=1, where={}, skip_embedding=True)
|
||||
@@ -133,11 +133,11 @@ class TestZillizDBCollection:
|
||||
collection_name=mock_config.collection_name,
|
||||
data=["query_text"],
|
||||
limit=1,
|
||||
output_fields=["text"],
|
||||
output_fields=["text", "url", "doc_id"],
|
||||
)
|
||||
|
||||
# Assert that the query result matches the expected result
|
||||
assert query_result == ["result_doc"]
|
||||
assert query_result == [("result_doc", "url_1", "doc_id_1")]
|
||||
|
||||
@patch("embedchain.vectordb.zilliz.MilvusClient", autospec=True)
|
||||
@patch("embedchain.vectordb.zilliz.connections", autospec=True)
|
||||
@@ -162,7 +162,7 @@ class TestZillizDBCollection:
|
||||
mock_embedder.embedding_fn.return_value = ["query_vector"]
|
||||
|
||||
# Mock the search result
|
||||
mock_search.return_value = [[{"entity": {"text": "result_doc"}}]]
|
||||
mock_search.return_value = [[{"entity": {"text": "result_doc", "url": "url_1", "doc_id": "doc_id_1"}}]]
|
||||
|
||||
# Call the query method with skip_embedding=False
|
||||
query_result = zilliz_db.query(input_query=["query_text"], n_results=1, where={}, skip_embedding=False)
|
||||
@@ -172,8 +172,8 @@ class TestZillizDBCollection:
|
||||
collection_name=mock_config.collection_name,
|
||||
data=["query_vector"],
|
||||
limit=1,
|
||||
output_fields=["text"],
|
||||
output_fields=["text", "url", "doc_id"],
|
||||
)
|
||||
|
||||
# Assert that the query result matches the expected result
|
||||
assert query_result == ["result_doc"]
|
||||
assert query_result == [("result_doc", "url_1", "doc_id_1")]
|
||||
|
||||
Reference in New Issue
Block a user