mirror of
				https://github.com/deepset-ai/haystack.git
				synced 2025-11-04 03:39:31 +00:00 
			
		
		
		
	* add 2 example scripts * fixing faq script * updating PR based on comments * black * updating s3 buckets * first attempt at testing * Add basic tests to two scripts PR: #3588 * make tests runnable * reformat files * only run in PRs touching an example Co-authored-by: bilgeyucel <bilgeyucel96@gmail.com> Co-authored-by: Massimiliano Pippi <mpippi@gmail.com>
		
			
				
	
	
		
			24 lines
		
	
	
		
			903 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			903 B
		
	
	
	
		
			Python
		
	
	
	
	
	
from examples.basic_qa_pipeline import basic_qa_pipeline
 | 
						|
 | 
						|
from haystack.schema import Answer, Document
 | 
						|
 | 
						|
 | 
						|
def test_basic_qa_pipeline():
 | 
						|
    prediction = basic_qa_pipeline()
 | 
						|
 | 
						|
    assert prediction is not None
 | 
						|
    assert prediction["query"] == "Who is the father of Arya Stark?"
 | 
						|
 | 
						|
    assert len(prediction["answers"]) == 5  # top-k of Reader
 | 
						|
    assert type(prediction["answers"][0]) == Answer
 | 
						|
    assert prediction["answers"][0].answer == "Ned"
 | 
						|
    assert prediction["answers"][0].score <= 1
 | 
						|
    assert prediction["answers"][0].score >= 0
 | 
						|
    assert prediction["answers"][0].meta["name"] == "43_Arya_Stark.txt"
 | 
						|
 | 
						|
    assert len(prediction["documents"]) == 10  # top-k of Retriever
 | 
						|
    assert type(prediction["documents"][0]) == Document
 | 
						|
    assert prediction["documents"][0].score <= 1
 | 
						|
    assert prediction["documents"][0].score >= 0
 | 
						|
    assert prediction["documents"][0].meta["name"] == "450_Baelor.txt"
 |