coverage
This commit is contained in:
parent
57f273e000
commit
5de4d50622
3 changed files with 26 additions and 2 deletions
|
|
@ -4,7 +4,7 @@ try:
|
||||||
from sentence_transformers import (
|
from sentence_transformers import (
|
||||||
CrossEncoder, # pyright: ignore[reportMissingImports]
|
CrossEncoder, # pyright: ignore[reportMissingImports]
|
||||||
)
|
)
|
||||||
except ImportError as e:
|
except ImportError as e: # pragma: no cover
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"sentence-transformers is not installed. Install it with "
|
"sentence-transformers is not installed. Install it with "
|
||||||
"`pip install sentence-transformers` or use the cross-encoder optional dependency."
|
"`pip install sentence-transformers` or use the cross-encoder optional dependency."
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ try:
|
||||||
from transformers import (
|
from transformers import (
|
||||||
AutoModel, # pyright: ignore[reportMissingImports]
|
AutoModel, # pyright: ignore[reportMissingImports]
|
||||||
)
|
)
|
||||||
except ImportError as e:
|
except ImportError as e: # pragma: no cover
|
||||||
raise ImportError(
|
raise ImportError(
|
||||||
"transformers is not installed. Please install it with `pip install transformers torch` "
|
"transformers is not installed. Please install it with `pip install transformers torch` "
|
||||||
"or use the jina optional dependency."
|
"or use the jina optional dependency."
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,18 @@ async def test_mxbai_reranker():
|
||||||
pytest.skip("MxBAI package not installed")
|
pytest.skip("MxBAI package not installed")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_mxbai_reranker_empty_chunks():
|
||||||
|
try:
|
||||||
|
from haiku.rag.reranking.mxbai import MxBAIReranker
|
||||||
|
|
||||||
|
reranker = MxBAIReranker()
|
||||||
|
result = await reranker.rerank("query", [], top_n=2)
|
||||||
|
assert result == []
|
||||||
|
except ImportError:
|
||||||
|
pytest.skip("MxBAI package not installed")
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
@pytest.mark.vcr()
|
@pytest.mark.vcr()
|
||||||
async def test_cohere_reranker():
|
async def test_cohere_reranker():
|
||||||
|
|
@ -335,3 +347,15 @@ async def test_cross_encoder_reranker():
|
||||||
assert "0" in top_ids or "2" in top_ids
|
assert "0" in top_ids or "2" in top_ids
|
||||||
except ImportError:
|
except ImportError:
|
||||||
pytest.skip("sentence-transformers not installed")
|
pytest.skip("sentence-transformers not installed")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.asyncio
|
||||||
|
async def test_cross_encoder_reranker_empty_chunks():
|
||||||
|
try:
|
||||||
|
from haiku.rag.reranking.cross_encoder import CrossEncoderReranker
|
||||||
|
|
||||||
|
reranker = CrossEncoderReranker("cross-encoder/ms-marco-MiniLM-L-6-v2")
|
||||||
|
result = await reranker.rerank("query", [], top_n=2)
|
||||||
|
assert result == []
|
||||||
|
except ImportError:
|
||||||
|
pytest.skip("sentence-transformers not installed")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue