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>
39 lines
2.6 KiB
Python
39 lines
2.6 KiB
Python
from haystack.pipelines import QuestionAnswerGenerationPipeline, QuestionGenerationPipeline, RetrieverQuestionGenerationPipeline
|
||
from haystack.schema import Document
|
||
import pytest
|
||
|
||
|
||
text = 'The Living End are an Australian punk rockabilly band from Melbourne, formed in 1994. Since 2002, the line-up consists of Chris Cheney (vocals, guitar), Scott Owen (double bass, vocals), and Andy Strachan (drums). The band rose to fame in 1997 after the release of their EP Second Solution / Prisoner of Society, which peaked at No. 4 on the Australian ARIA Singles Chart. They have released eight studio albums, two of which reached the No. 1 spot on the ARIA Albums Chart: The Living End (October 1998) and State of Emergency (February 2006). They have also achieved chart success in the U.S. and the United Kingdom. The Band was nominated 27 times and won five awards at the Australian ARIA Music Awards ceremonies: "Highest Selling Single" for Second Solution / Prisoner of Society (1998), "Breakthrough Artist – Album" and "Best Group" for The Living End (1999), as well as "Best Rock Album" for White Noise (2008) and The Ending Is Just the Beginning Repeating (2011). In October 2010, their debut album was listed in the book "100 Best Australian Albums". Australian musicologist Ian McFarlane described the group as "one of Australia’s premier rock acts. By blending a range of styles (punk, rockabilly and flat out rock) with great success, The Living End has managed to produce anthemic choruses and memorable songs in abundance".'
|
||
document = Document(content=text)
|
||
query = "Living End"
|
||
|
||
|
||
def test_qg_pipeline(question_generator):
|
||
p = QuestionGenerationPipeline(question_generator)
|
||
result = p.run(documents=[document])
|
||
keys = list(result)
|
||
assert "generated_questions" in keys
|
||
assert len(result["generated_questions"][0]["questions"]) > 0
|
||
|
||
|
||
@pytest.mark.parametrize("retriever,document_store", [("tfidf", "memory")], indirect=True)
|
||
def test_rqg_pipeline(question_generator, retriever):
|
||
retriever.document_store.write_documents([document])
|
||
retriever.fit()
|
||
p = RetrieverQuestionGenerationPipeline(retriever, question_generator)
|
||
result = p.run(query)
|
||
keys = list(result)
|
||
assert "generated_questions" in keys
|
||
assert len(result["generated_questions"][0]["questions"]) > 0
|
||
|
||
|
||
@pytest.mark.parametrize("reader", ["farm"], indirect=True)
|
||
def test_qag_pipeline(question_generator, reader):
|
||
p = QuestionAnswerGenerationPipeline(question_generator, reader)
|
||
results = p.run(documents=[document])["results"]
|
||
assert len(results) > 0
|
||
assert results[0]["query"]
|
||
assert len(results[0]["answers"]) > 0
|
||
assert results[0]["answers"][0].answer is not None
|
||
|