[Feature] Add citations flag in query and chat functions of App to return context along with the answer (#859)
This commit is contained in:
@@ -129,7 +129,7 @@ class TestZillizDBCollection:
|
||||
query_result = zilliz_db.query(input_query=["query_text"], n_results=1, where={}, skip_embedding=True)
|
||||
|
||||
# Assert that MilvusClient.search was called with the correct parameters
|
||||
mock_search.assert_called_once_with(
|
||||
mock_search.assert_called_with(
|
||||
collection_name=mock_config.collection_name,
|
||||
data=["query_text"],
|
||||
limit=1,
|
||||
@@ -137,7 +137,20 @@ class TestZillizDBCollection:
|
||||
)
|
||||
|
||||
# Assert that the query result matches the expected result
|
||||
assert query_result == [("result_doc", "url_1", "doc_id_1")]
|
||||
assert query_result == ["result_doc"]
|
||||
|
||||
query_result_with_citations = zilliz_db.query(
|
||||
input_query=["query_text"], n_results=1, where={}, skip_embedding=True, citations=True
|
||||
)
|
||||
|
||||
mock_search.assert_called_with(
|
||||
collection_name=mock_config.collection_name,
|
||||
data=["query_text"],
|
||||
limit=1,
|
||||
output_fields=["text", "url", "doc_id"],
|
||||
)
|
||||
|
||||
assert query_result_with_citations == [("result_doc", "url_1", "doc_id_1")]
|
||||
|
||||
@patch("embedchain.vectordb.zilliz.MilvusClient", autospec=True)
|
||||
@patch("embedchain.vectordb.zilliz.connections", autospec=True)
|
||||
@@ -168,7 +181,7 @@ class TestZillizDBCollection:
|
||||
query_result = zilliz_db.query(input_query=["query_text"], n_results=1, where={}, skip_embedding=False)
|
||||
|
||||
# Assert that MilvusClient.search was called with the correct parameters
|
||||
mock_search.assert_called_once_with(
|
||||
mock_search.assert_called_with(
|
||||
collection_name=mock_config.collection_name,
|
||||
data=["query_vector"],
|
||||
limit=1,
|
||||
@@ -176,4 +189,17 @@ class TestZillizDBCollection:
|
||||
)
|
||||
|
||||
# Assert that the query result matches the expected result
|
||||
assert query_result == [("result_doc", "url_1", "doc_id_1")]
|
||||
assert query_result == ["result_doc"]
|
||||
|
||||
query_result_with_citations = zilliz_db.query(
|
||||
input_query=["query_text"], n_results=1, where={}, skip_embedding=False, citations=True
|
||||
)
|
||||
|
||||
mock_search.assert_called_with(
|
||||
collection_name=mock_config.collection_name,
|
||||
data=["query_vector"],
|
||||
limit=1,
|
||||
output_fields=["text", "url", "doc_id"],
|
||||
)
|
||||
|
||||
assert query_result_with_citations == [("result_doc", "url_1", "doc_id_1")]
|
||||
|
||||
Reference in New Issue
Block a user