@ragfoundry/adapter-vector-pgvector
v0.1.2
Published
Postgres pgvector vector store adapter for RAGFoundry.
Maintainers
Readme
@ragfoundry/adapter-vector-pgvector
🗄️ pgvector vector store adapter. Store and search embeddings in Postgres you already run, via the pgvector extension.
A VectorStore adapter for RAGFoundry — typed retrieval-augmented generation for TypeScript.
💡 New to RAGFoundry? This page is for adding one specific provider to an app you're already building. Starting a project from scratch is faster with the scaffolder — it asks a few questions and wires everything (including this adapter, if you pick it) for you:
npm create @ragfoundry my-app
📦 Install
npm install @ragfoundry/core @ragfoundry/adapter-vector-pgvector🚀 Usage
Works with both import and require — this package ships both builds.
ESM:
import { createRAG } from "@ragfoundry/core"
import "@ragfoundry/adapter-vector-pgvector"
const rag = createRAG({
vectorStore: {
provider: "pgvector",
connectionString: process.env.DATABASE_URL!,
tableName: "documents",
},
// ...the rest of your config
})CommonJS:
const { createRAG } = require("@ragfoundry/core")
require("@ragfoundry/adapter-vector-pgvector")
const rag = createRAG({
vectorStore: {
provider: "pgvector",
connectionString: process.env.DATABASE_URL,
tableName: "documents",
},
// ...the rest of your config
})⚠️ The import/require is what registers "pgvector" at runtime — remove
it and createRAG throws Unknown adapter "pgvector", even though the
provider name is still typed correctly. In TypeScript it's also what makes the
vectorStore block above autocomplete and type-check.
⚙️ Options
| Option | Type | Required | Default |
|---|---|---|---|
| connectionString | string | yes | — |
| tableName | string | yes | — |
Schema
The table must exist, with a width matching your embedding model:
CREATE EXTENSION IF NOT EXISTS vector;
CREATE TABLE documents (
id text PRIMARY KEY,
embedding vector(1536),
content text,
metadata jsonb
);Metadata filters use jsonb containment, so filter: { lang: "en" } becomes
metadata @> '{"lang":"en"}'. Upserts run in one transaction, so a partial
failure leaves nothing behind. close() releases the connection pool.
🔗 See also
@ragfoundry/core— the pipelines, types, and every export explained@ragfoundry/create—npm create @ragfoundry, scaffold a whole project
📄 License
MIT
