(
*,
candidate_strategy: str,
hits: list,
drawers_col,
query: str,
wing: str,
room: str,
n_results: int,
max_distance: float,
source_file: str = None,
)
| 869 | |
| 870 | |
| 871 | def _finalize_candidate_hits( |
| 872 | *, |
| 873 | candidate_strategy: str, |
| 874 | hits: list, |
| 875 | drawers_col, |
| 876 | query: str, |
| 877 | wing: str, |
| 878 | room: str, |
| 879 | n_results: int, |
| 880 | max_distance: float, |
| 881 | source_file: str = None, |
| 882 | ) -> tuple: |
| 883 | try: |
| 884 | _apply_candidate_strategy( |
| 885 | candidate_strategy, |
| 886 | hits, |
| 887 | drawers_col, |
| 888 | query, |
| 889 | wing, |
| 890 | room, |
| 891 | n_results, |
| 892 | max_distance=max_distance, |
| 893 | source_file=source_file, |
| 894 | ) |
| 895 | except UnsupportedCapabilityError: |
| 896 | return [], { |
| 897 | "error": "candidate_strategy='union' requires a backend with lexical_search support", |
| 898 | "unsupported_capability": "supports_lexical_search", |
| 899 | "hint": "Use candidate_strategy='vector' or select a backend that supports lexical search.", |
| 900 | } |
| 901 | |
| 902 | hits = _hybrid_rank(hits, query, metric=_metric_for_collection(drawers_col))[:n_results] |
| 903 | for h in hits: |
| 904 | h.pop("_sort_key", None) |
| 905 | h.pop("_source_file_full", None) |
| 906 | h.pop("_chunk_index", None) |
| 907 | h.pop("_parent_drawer_id", None) |
| 908 | return hits, None |
| 909 | |
| 910 | |
| 911 | def _backend_mismatch_result(error: BackendMismatchError) -> dict: |
no test coverage detected