vk_hackathon/search/aggregation.py
q e49e3417eb Add logviewer project and fix Docker imports
- Add logviewer/: Dozzle web UI (port 9999) + analyze.py CLI tool
- docker-compose.yml: add json-file logging with rotation and labels for index/search
- Fix Dockerfiles: COPY *.py . so all modules are included in image
- Convert all relative imports to flat absolute imports for Docker flat layout
- Rename index/schemas.py → index/index_schemas.py to avoid module name collision with search/schemas.py in test runner
- Update all tests to add service dir to sys.path and use flat imports

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-18 15:26:11 +03:00

23 lines
605 B
Python

from typing import Any
from config import TOP_K
from retrieval import extract_message_ids
def aggregate_message_ids(
reranked_head: list[Any],
retrieval_tail: list[Any],
) -> list[str]:
"""Deduplicate and collect top-K message_ids, reranked head first."""
seen: set[str] = set()
result: list[str] = []
for point in reranked_head + retrieval_tail:
for mid in extract_message_ids(point):
if mid not in seen:
seen.add(mid)
result.append(mid)
if len(result) >= TOP_K:
return result
return result