Spaces:
Runtime error
Runtime error
File size: 1,927 Bytes
ba8ab56 | 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 46 47 | # File Objective : CLI for the RAG pipeline β ask a question, receive a cited answer.
# Scope : Dev script β verify end-to-end grounded generation.
# What it does : Calls domain/rag.py answer() and prints the answer + numbered sources.
# What it does not: Call the agent or expose an HTTP endpoint.
from __future__ import annotations
import sys
from vantage_core.adapters.embedder_st import STEmbedder
from vantage_core.adapters.llm_openai import OpenAILLM
from vantage_core.adapters.reranker_cross_encoder import CrossEncoderReranker
from vantage_core.adapters.vector_qdrant import QdrantVectorRepo
from vantage_core.domain.rag import answer
def main() -> None:
question = " ".join(sys.argv[1:]).strip() or input("Question: ").strip()
if not question:
print("No question provided.")
sys.exit(1)
print(f"\nββ Question: {question!r} ββββββββββββββββββββββββββββββββββββββββ")
result = answer(
question = question,
embedder = STEmbedder(),
repo = QdrantVectorRepo(),
reranker = CrossEncoderReranker(),
llm = OpenAILLM(),
)
print(f"\nββ Answer {'(no coverage)' if not result.has_coverage else ''} βββββββββββββββββββββββββββββββββββββββββββββββ")
print(result.answer)
if result.sources:
print(f"\nββ Sources ββββββββββββββββββββββββββββββββββββββββββββββββββββββ")
for i, sc in enumerate(result.sources, start=1):
c = sc.chunk
print(f" [{i}] {c.category} | {c.title}")
print(f" {c.chunk_text[:120]}")
print()
if __name__ == "__main__":
main()
|