SourceCitation
Full-card RAG source — shows title, domain, snippet, relevance score, and metadata. The entire card becomes an anchor or button when source.url or onClick is provided.
src/components/ai/source-citation.tsxWeb, document, and code sources
type controls the icon. Works for web pages, internal docs, code snippets, database rows, and video transcripts.
Building RAG with pgvector and OpenAI embeddings
pgvector stores embeddings as a native PostgreSQL column, so semantic search runs inside the same query that filters structured data.
Engineering handbook — retrieval pipeline v3
Chunks are 512 tokens with 64-token overlap. Re-ranked by cohere-rerank-v3 before reaching the model.
src/rag/embed.ts — batchEmbed()
export async function batchEmbed(chunks: string[]) { return openai.embeddings.create({ model: 'text-embedding-3-small', input: chunks }) }
Highlighted (active citation)
Pass highlighted to visually pin a card — useful when the user clicks an inline [n] and the reading pane should scroll to and emphasise the matching source.