mirror of
https://github.com/deepset-ai/haystack.git
synced 2025-07-30 20:31:44 +00:00

* Fist attempt at using setup.cfg for dependency management * Trying the new package on the CI and in Docker too * Add composite extras_require * Add the safe_import function for document store imports and add some try-catch statements on rest_api and ui imports * Fix bug on class import and rephrase error message * Introduce typing for optional modules and add type: ignore in sparse.py * Include importlib_metadata backport for py3.7 * Add colab group to extra_requires * Fix pillow version * Fix grpcio * Separate out the crawler as another extra * Make paths relative in rest_api and ui * Update the test matrix in the CI * Add try catch statements around the optional imports too to account for direct imports * Never mix direct deps with self-references and add ES deps to the base install * Refactor several paths in tests to make them insensitive to the execution path * Include tstadel review and re-introduce Milvus1 in the tests suite, to fix * Wrap pdf conversion utils into safe_import * Update some tutorials and rever Milvus1 as default for now, see #2067 * Fix mypy config Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
43 lines
1.6 KiB
Python
43 lines
1.6 KiB
Python
import pytest
|
|
|
|
from haystack.pipelines import TranslationWrapperPipeline, SearchSummarizationPipeline
|
|
from haystack.nodes import DensePassageRetriever, EmbeddingRetriever
|
|
from test_summarizer import SPLIT_DOCS
|
|
|
|
# Keeping few (retriever,document_store) combination to reduce test time
|
|
@pytest.mark.slow
|
|
@pytest.mark.elasticsearch
|
|
@pytest.mark.summarizer
|
|
@pytest.mark.parametrize(
|
|
"retriever,document_store",
|
|
[("embedding", "memory"), ("elasticsearch", "elasticsearch")],
|
|
indirect=True,
|
|
)
|
|
def test_summarization_pipeline_with_translator(
|
|
document_store,
|
|
retriever,
|
|
summarizer,
|
|
en_to_de_translator,
|
|
de_to_en_translator
|
|
):
|
|
document_store.write_documents(SPLIT_DOCS)
|
|
|
|
if isinstance(retriever, EmbeddingRetriever) or isinstance(retriever, DensePassageRetriever):
|
|
document_store.update_embeddings(retriever=retriever)
|
|
|
|
query = "Wo steht der Eiffelturm?"
|
|
base_pipeline = SearchSummarizationPipeline(retriever=retriever, summarizer=summarizer)
|
|
pipeline = TranslationWrapperPipeline(
|
|
input_translator=de_to_en_translator,
|
|
output_translator=en_to_de_translator,
|
|
pipeline=base_pipeline
|
|
)
|
|
output = pipeline.run(query=query, params={"Retriever": {"top_k": 2}, "Summarizer": {"generate_single_summary": True}})
|
|
# SearchSummarizationPipeline return answers but Summarizer return documents
|
|
documents = output["documents"]
|
|
assert len(documents) == 1
|
|
assert documents[0].content in [
|
|
"Der Eiffelturm ist ein Wahrzeichen in Paris, Frankreich.",
|
|
"Der Eiffelturm, der 1889 in Paris, Frankreich, erbaut wurde, ist das höchste freistehende Bauwerk der Welt."
|
|
]
|