feat(search): enhance phrase matching and reranking logic with improved async handling
This commit is contained in:
@@ -10,7 +10,7 @@ import pytest
|
||||
|
||||
from python.ebook_search.config import EbookSearchConfig, RerankConfig, load_rerank_config
|
||||
from python.ebook_search.rerank import rerank_chunks
|
||||
from python.ebook_search.search import SearchResult, apply_rerank, skip_rerank
|
||||
from python.ebook_search.search import SearchResult, apply_rerank
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pytest_mock import MockerFixture
|
||||
@@ -57,10 +57,10 @@ def test_config_defaults_enable_reranking(mocker: MockerFixture) -> None:
|
||||
assert config.timeout_seconds == 30
|
||||
|
||||
|
||||
def test_reranking_disabled_returns_original_fused_order() -> None:
|
||||
async def test_reranking_disabled_returns_original_fused_order(mocker: MockerFixture) -> None:
|
||||
config = EbookSearchConfig(rerank=RerankConfig(enabled=False), top_k=2)
|
||||
|
||||
response = skip_rerank("query", candidates(), config)
|
||||
response = await apply_rerank(mocker.Mock(), "query", candidates(), config, rerank=False)
|
||||
|
||||
assert response.rank_label == "Hybrid"
|
||||
assert [result.chunk_id for result in response.results] == [1, 2]
|
||||
@@ -133,7 +133,7 @@ async def test_vllm_rerank_timeout_raises(mocker: MockerFixture) -> None:
|
||||
config = EbookSearchConfig(rerank=RerankConfig(enabled=True), top_k=2)
|
||||
|
||||
with pytest.raises(httpx.TimeoutException, match="timeout"):
|
||||
await apply_rerank(mocker.Mock(), "query", candidates(), config)
|
||||
await apply_rerank(mocker.Mock(), "query", candidates(), config, rerank=True)
|
||||
|
||||
|
||||
async def test_malformed_vllm_rerank_json_does_not_crash_search(mocker: MockerFixture) -> None:
|
||||
|
||||
Reference in New Issue
Block a user