Skip to content

Commit

Permalink
add draw and serialization/deserialization to e2e pipeline examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ZanSara committed Sep 28, 2023
1 parent 9340c57 commit ed48ccb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion e2e/preview/pipelines/test_extractive_qa_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from haystack.preview.components.readers import ExtractiveReader


def test_extractive_qa_pipeline():
def test_extractive_qa_pipeline(tmp_path):
document_store = MemoryDocumentStore()

documents = [
Expand All @@ -20,6 +20,11 @@ def test_extractive_qa_pipeline():
qa_pipeline.add_component(instance=ExtractiveReader(model_name_or_path="deepset/tinyroberta-squad2"), name="reader")
qa_pipeline.connect("retriever", "reader")

qa_pipeline.draw(tmp_path / "test_extractive_qa_pipeline.png")

serialized_pipeline = qa_pipeline.to_dict()
qa_pipeline = Pipeline.from_dict(serialized_pipeline)

questions = ["Who lives in Paris?", "Who lives in Berlin?", "Who lives in Rome?"]
answers_spywords = ["Jean", "Mark", "Giorgio"]

Expand Down
14 changes: 12 additions & 2 deletions e2e/preview/pipelines/test_rag_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
not os.environ.get("OPENAI_API_KEY", None),
reason="Export an env var called OPENAI_API_KEY containing the OpenAI API key to run this test.",
)
def test_bm25_rag_pipeline():
def test_bm25_rag_pipeline(tmp_path):
document_store = MemoryDocumentStore()

documents = [
Expand Down Expand Up @@ -47,6 +47,11 @@ def test_bm25_rag_pipeline():
rag_pipeline.connect("llm.metadata", "answer_builder.metadata")
rag_pipeline.connect("retriever", "answer_builder.documents")

rag_pipeline.draw(tmp_path / "test_bm25_rag_pipeline.png")

serialized_pipeline = rag_pipeline.to_dict()
rag_pipeline = Pipeline.from_dict(serialized_pipeline)

questions = ["Who lives in Paris?", "Who lives in Berlin?", "Who lives in Rome?"]
answers_spywords = ["Jean", "Mark", "Giorgio"]

Expand All @@ -71,7 +76,7 @@ def test_bm25_rag_pipeline():
not os.environ.get("OPENAI_API_KEY", None),
reason="Export an env var called OPENAI_API_KEY containing the OpenAI API key to run this test.",
)
def test_embedding_retrieval_rag_pipeline():
def test_embedding_retrieval_rag_pipeline(tmp_path):
document_store = MemoryDocumentStore()

documents = [
Expand Down Expand Up @@ -115,6 +120,11 @@ def test_embedding_retrieval_rag_pipeline():
rag_pipeline.connect("llm.metadata", "answer_builder.metadata")
rag_pipeline.connect("retriever", "answer_builder.documents")

rag_pipeline.draw(tmp_path / "test_embedding_rag_pipeline.png")

serialized_pipeline = rag_pipeline.to_dict()
rag_pipeline = Pipeline.from_dict(serialized_pipeline)

questions = ["Who lives in Paris?", "Who lives in Berlin?", "Who lives in Rome?"]
answers_spywords = ["Jean", "Mark", "Giorgio"]

Expand Down

0 comments on commit ed48ccb

Please sign in to comment.