File size: 1,507 Bytes
dcc99a5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File Objective  : CLI for the retrieval pipeline β€” verify hybrid search + rerank.
# Scope           : Dev script β€” accepts a query, prints top-5 chunks with scores.
# What it does    : Calls retrieve() and formats results to stdout.
# What it does not: Call an LLM or return a natural-language answer.

from __future__ import annotations

import sys

from vantage_core.adapters.embedder_st import STEmbedder
from vantage_core.adapters.reranker_cross_encoder import CrossEncoderReranker
from vantage_core.adapters.vector_qdrant import QdrantVectorRepo
from vantage_core.domain.retrieval import retrieve


def main() -> None:
    query = " ".join(sys.argv[1:]).strip() or input("Query: ").strip()
    if not query:
        print("No query provided.")
        sys.exit(1)

    print(f"\n── Search: {query!r} ────────────────────────────────────────")

    results = retrieve(
        query    = query,
        embedder = STEmbedder(),
        repo     = QdrantVectorRepo(),
        reranker = CrossEncoderReranker(),
    )

    if not results:
        print("  No results β€” run scripts/ingest.py first.")
        sys.exit(1)

    for rank, sc in enumerate(results, start=1):
        c = sc.chunk
        print(f"\n  [{rank}] score={sc.score:.4f}  category={c.category}")
        print(f"      title : {c.title}")
        print(f"      text  : {c.chunk_text[:200]}")
    print()


if __name__ == "__main__":
    main()