Documentation
¶
Overview ¶
Azure OpenAI RAG (retrieval-augmented generation) example for Chronos.
This example shows an end-to-end RAG flow on Azure OpenAI:
- Build a small self-contained in-memory VectorStore (cosine similarity). Chronos ships production vector adapters (e.g. Qdrant), but there is no built-in in-memory store — so this file doubles as a reference for how to implement the storage.VectorStore interface.
- Wrap it in a knowledge.VectorKnowledge that embeds documents with an Azure OpenAI embeddings deployment (model.NewAzureOpenAIEmbeddings...).
- Load a few sample documents.
- Answer a question by retrieving the most relevant documents and feeding them as grounding context into an Azure chat completion.
Prerequisites:
- An Azure OpenAI resource with BOTH a chat deployment (e.g. gpt-4o-mini) and an embeddings deployment (e.g. text-embedding-3-small)
- Go 1.24+
Set the following environment variables before running:
export AZURE_OPENAI_API_KEY=<your-azure-api-key> export AZURE_OPENAI_ENDPOINT=https://<your-resource>.openai.azure.com export AZURE_OPENAI_DEPLOYMENT=<your-chat-deployment> # chat export AZURE_OPENAI_EMBED_DEPLOYMENT=<your-embeddings-deployment> # embeddings export AZURE_OPENAI_API_VERSION=2024-10-21
Run:
go run ./examples/azure_rag/main.go
If AZURE_OPENAI_API_KEY is not set the example prints the required variables and exits cleanly (0) without making any network call. The in-memory VectorStore itself is exercised offline by main_test.go.
Click to show internal directories.
Click to hide internal directories.