Skip to content

Instantly share code, notes, and snippets.

@lovemycodesnippets
Created January 19, 2026 20:34
Show Gist options
  • Select an option

  • Save lovemycodesnippets/58763386c2341193e61f44cf4eb45230 to your computer and use it in GitHub Desktop.

Select an option

Save lovemycodesnippets/58763386c2341193e61f44cf4eb45230 to your computer and use it in GitHub Desktop.
How to Build Production-Ready AI Agents with RAG and FastAPI
# cache.py
from hashlib import sha256
CACHE = {}
def cache_key(query: str, doc_ids: list[str]) -> str:
return sha256(("||".join([query] + doc_ids)).encode()).hexdigest()
def get_cache(key: str): return CACHE.get(key)
def set_cache(key: str, val: dict): CACHE[key] = val
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment