LangChain.js supports Convex as a vector store, and supports the standard similarity search.

Setup

Create project

Get a working Convex project set up, for example by using:
npm create convex@latest

Add database accessors

Add query and mutation helpers to convex/langchain/db.ts:
convex/langchain/db.ts
export * from "@langchain/community/utils/convex";

Configure your schema

Set up your schema (for vector indexing):
convex/schema.ts
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";

export default defineSchema({
  documents: defineTable({
    embedding: v.array(v.number()),
    text: v.string(),
    metadata: v.any(),
  }).vectorIndex("byEmbedding", {
    vectorField: "embedding",
    dimensions: 1536,
  }),
});

Usage

npm
npm install @langchain/openai @langchain/community @langchain/core

Ingestion