Coverage for src / qdrant_loader_mcp_server / search / hybrid / interfaces.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-18 04:51 +0000

1""" 

2Interfaces for the hybrid search pipeline. 

3""" 

4 

5from __future__ import annotations 

6 

7from typing import Protocol 

8 

9from ..components.search_result_models import HybridSearchResult 

10 

11 

12class VectorSearcher(Protocol): 

13 """ 

14 Vector searcher interface for searching for vector results. 

15 Args: 

16 Protocol (_type_): _description_ 

17 """ 

18 

19 async def search( 

20 self, query: str, limit: int, project_ids: list[str] | None 

21 ) -> list[dict]: 

22 """ 

23 Search for vector results. 

24 """ 

25 ... 

26 

27 

28class KeywordSearcher(Protocol): 

29 """ 

30 Keyword searcher interface for searching for keyword results. 

31 Args: 

32 Protocol (_type_): _description_ 

33 """ 

34 

35 async def search( 

36 self, query: str, limit: int, project_ids: list[str] | None 

37 ) -> list[dict]: 

38 """ 

39 Search for keyword results. 

40 """ 

41 ... 

42 

43 

44class ResultCombinerLike(Protocol): 

45 """ 

46 Result combiner interface for combining search results. 

47 """ 

48 

49 async def combine_results( 

50 self, 

51 vector_results: list[dict], 

52 keyword_results: list[dict], 

53 query_context: dict, 

54 limit: int, 

55 source_types: list[str] | None, 

56 project_ids: list[str] | None, 

57 ) -> list[HybridSearchResult]: 

58 """ 

59 Combine the search results. 

60 """ 

61 ... 

62 

63 

64class Reranker(Protocol): 

65 """ 

66 Reranker interface for reranking search results. 

67 """ 

68 

69 def rerank( 

70 self, query: str, results: list[HybridSearchResult] 

71 ) -> list[HybridSearchResult]: 

72 """ 

73 Rerank the search results. 

74 """ 

75 ...