import { type EmbeddingProvider, type VectorDocument, type VectorSearchOptions, type VectorSearchResult, type VectorStore } from '../hallucination/retrieval.js'; import { type PostgresLikeClient } from './client.js'; /** Options for the pgvector store. */ export interface PostgresVectorStoreOptions { /** Width of every vector. Must match the embedding function's output. */ dimensions: number; /** Embeds chunks that arrive without a vector, and search queries. Defaults to hashed term vectors. */ embed?: EmbeddingProvider; /** Table name, optionally schema-qualified. Defaults to `nexus_vectors`. */ table?: string; /** * The approximate index created by `migrate()`. `hnsw` (the default) answers a search without * scanning every row, at the cost of slower writes; `none` scans exactly, which suits a few * thousand chunks. */ index?: 'hnsw' | 'none'; } /** The schema, as statements: the pgvector extension, the table, and its index. */ export declare function vectorStoreMigration(options: Omit): string[]; /** * Retrieval chunks in Postgres with pgvector, ranked by cosine similarity in the database. * * The same contract as `MemoryVectorStore`, checked by the same tests. Only the nearest chunks leave * the database, so a search costs the same whether the table holds a thousand chunks or ten million. * Adding a chunk whose id exists replaces it, and a metadata filter runs in SQL. */ export declare class PostgresVectorStore implements VectorStore { private readonly client; private readonly options; private readonly table; private readonly embed; constructor(client: PostgresLikeClient, options: PostgresVectorStoreOptions); /** Creates the extension, table, and index. Never runs implicitly. */ migrate(): Promise; /** Adds chunks, or replaces those whose id exists, embedding those without a vector in one batch. */ add(documents: VectorDocument[]): Promise; /** The chunks most similar to a query, best first. */ search(query: string, options?: VectorSearchOptions): Promise; /** The chunks most similar to a vector, best first. */ searchVector(vector: number[], options?: VectorSearchOptions): Promise; /** Removes chunks by id. */ delete(ids: readonly string[]): Promise; /** Chunks stored. */ size(): Promise; private assertWidth; }