Skip to content

AI

Knowledge base

Give the assistant your own documents. Text pasted at /ai/documents is chunked and embedded by a background job, then searched by cosine distance, scoped to the caller's own documents.

What you get

  • Fixed-size chunking with overlap
  • Embeddings with text-embedding-3-small
  • pgvector storage in Postgres
  • A searchKnowledgeBase tool for the chat

Turn it on

  • OPENAI_API_KEY
  • Postgres with the vector extension

Where it lives

  • lib/rag/index.ts
  • lib/rag/chunk.ts
  • lib/rag/embeddings.ts