haystack/examples/test_getting_started.py
Nicola Procopio c102b152dc
fix: Run update_embeddings in examples (#6008)
* added hybrid search example

Added an example about hybrid search for faq pipeline on covid dataset

* formatted with back formatter

* renamed document

* fixed

* fixed typos

* added test

added test for hybrid search

* fixed withespaces

* removed test for hybrid search

* fixed pylint

* commented logging

* updated hybrid search example

* release notes

* Update hybrid_search_faq_pipeline.py-815df846dca7e872.yaml

* Update hybrid_search_faq_pipeline.py

* mention hybrid search example in release notes

* reduce installed dependencies in examples test workflow

* do not install cuda dependencies

* skip models if API key not set; delete document indices

* skip models if API key not set; delete document indices

* skip models if API key not set; delete document indices

* keep roberta-base model and inference extra

* pylint

* disable pylint no-logging-basicconfig rule

---------

Co-authored-by: Julian Risch <julian.risch@deepset.ai>
2023-10-10 16:38:52 +02:00

27 lines
963 B
Python

import os
import pytest
from examples.getting_started import getting_started
from haystack.schema import Answer, Document
@pytest.mark.parametrize("provider", ["anthropic", "cohere", "huggingface", "openai"])
def test_getting_started(provider):
if provider == "anthropic":
api_key = os.environ.get("ANTHROPIC_API_KEY", "")
elif provider == "cohere":
api_key = os.environ.get("COHERE_API_KEY", "")
elif provider == "huggingface":
api_key = os.environ.get("HUGGINGFACE_API_KEY", "")
elif provider == "openai":
api_key = os.environ.get("OPENAI_API_KEY", "")
if api_key:
result = getting_started(provider=provider, API_KEY=api_key)
# Testing only for functionality. Since model predictions from APIs might change, we cannot test those directly.
assert isinstance(result, dict)
assert type(result["answers"][0]) == Answer
assert type(result["documents"][0]) == Document