mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-08-19 05:58:57 +00:00
fix: extend schema for prompt node results (#3891)
* extend schema for prompt node results * extend schema * update openapi * fix mypy for test module * added 1.14 specs * reverted schema for 1.13 --------- Co-authored-by: bogdankostic <bogdankostic@web.de> Co-authored-by: Mayank Jobanputra <mayankjobanputra@gmail.com> Co-authored-by: Sebastian <sjrl@users.noreply.github.com> Co-authored-by: ZanSara <sara.zanzottera@deepset.ai>
This commit is contained in:
parent
c855e18d78
commit
8002cf92d6
@ -977,6 +977,13 @@
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
"results": {
|
||||
"title": "Results",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"_debug": {
|
||||
"title": " Debug",
|
||||
"type": "object"
|
||||
|
@ -977,6 +977,13 @@
|
||||
},
|
||||
"default": []
|
||||
},
|
||||
"results": {
|
||||
"title": "Results",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"_debug": {
|
||||
"title": " Debug",
|
||||
"type": "object"
|
||||
|
@ -61,4 +61,5 @@ class QueryResponse(BaseModel):
|
||||
query: str
|
||||
answers: List[Answer] = []
|
||||
documents: List[Document] = []
|
||||
results: Optional[List[str]] = None
|
||||
debug: Optional[Dict] = Field(None, alias="_debug")
|
||||
|
@ -1,3 +1,5 @@
|
||||
# mypy: disable_error_code = "empty-body, override, union-attr"
|
||||
|
||||
from typing import Dict, List, Optional, Union, Generator
|
||||
|
||||
import os
|
||||
@ -449,6 +451,34 @@ def test_query_with_dataframe(client):
|
||||
mocked_pipeline.run.assert_called_with(query=TEST_QUERY, params={}, debug=False)
|
||||
|
||||
|
||||
def test_query_with_prompt_node(client):
|
||||
with mock.patch("rest_api.controller.search.query_pipeline") as mocked_pipeline:
|
||||
# `run` must return a dictionary containing a `query` key
|
||||
mocked_pipeline.run.return_value = {
|
||||
"query": TEST_QUERY,
|
||||
"documents": [
|
||||
Document(
|
||||
content="test",
|
||||
content_type="text",
|
||||
score=0.9,
|
||||
meta={"test_key": "test_value"},
|
||||
embedding=np.array([0.1, 0.2, 0.3]),
|
||||
)
|
||||
],
|
||||
"results": ["test"],
|
||||
}
|
||||
response = client.post(url="/query", json={"query": TEST_QUERY})
|
||||
assert 200 == response.status_code
|
||||
assert len(response.json()["documents"]) == 1
|
||||
assert response.json()["documents"][0]["content"] == "test"
|
||||
assert response.json()["documents"][0]["content_type"] == "text"
|
||||
assert response.json()["documents"][0]["embedding"] == [0.1, 0.2, 0.3]
|
||||
assert len(response.json()["results"]) == 1
|
||||
assert response.json()["results"][0] == "test"
|
||||
# Ensure `run` was called with the expected parameters
|
||||
mocked_pipeline.run.assert_called_with(query=TEST_QUERY, params={}, debug=False)
|
||||
|
||||
|
||||
def test_write_feedback(client, feedback):
|
||||
response = client.post(url="/feedback", json=feedback)
|
||||
assert 200 == response.status_code
|
||||
|
Loading…
x
Reference in New Issue
Block a user