Examples · Private RAG
Private RAG
Combine Search and Contents to build a retrieval-augmented generation pipeline that never ships your prompts to a third-party LLM provider.
Pipeline
1. Search the open web. 2. Pull cleaned page text via Contents. 3. Stuff into a local LLM.
Python
from youdotcom import You
with You("<API_KEY>") as you:
hits = you.search.unified(query=question, num_web_results=5).results.web or []
pages = [you.contents.fetch(url=h.url).markdown for h in hits]
context = "\n\n".join(pages)
prompt = f"Answer using only the context.\n\nContext:\n{context}\n\nQ: {question}"
# pass prompt to your local LLM