Production RAG coordinates document ingestion, embeddings, indexes, query caches, and rollback. Build a new version, run health checks, and switch an explicit pointer instead of mutating the live index in place.
Core concepts
An index manifest should record the source snapshot, chunking rules, embedding model, and build result. Cache keys must include normalized query, tenant, permission summary, and index version.
from dataclasses import dataclass
@dataclass(frozen=True)
class IndexRelease:
version: str
document_count: int
embedding_model: str
status: str
def cache_key(query: str, tenant: str, role_hash: str, index_version: str) -> str:
return '|'.join((tenant, role_hash, index_version, query.strip().lower()))
Steps and use cases
- Freeze a document snapshot and build a new index while the old one serves traffic.
- Check document counts, vector dimensions, sample retrieval, and permission regressions.
- Switch the current pointer once the health checks pass; keep the old pointer for rollback.
- Bind cache keys to index version and permission summary so releases cannot reuse stale results.
This suits continuously updated help centers, policy libraries, and production systems that need quick rollback.
Common questions
In-place updates can be fine for a small experiment, but production generally benefits from versioned builds. A cache without tenant and permission fields can leak evidence and must not be shared across boundaries.
Official references
OpenAI production best practices and OpenAI embeddings.
Last checked: 2026-11-16. Validate new documents with a fixed question set before promotion.
