Reference · Snippet · python
Minimal RAG loop
# Pseudocode — swap embed/search for your stack
chunks = ["Annual refunds within 14 days.", "Monthly plans auto-renew."]
index = [(embed(c), c) for c in chunks]
def answer(question: str) -> str:
q = embed(question)
best = max(index, key=lambda pair: cosine(q, pair[0]))
context = best[1]
return llm(f"Context: {context}\nQ: {question}\nA:")