import { type EmbeddingProvider, type VectorDocument, type VectorSearchOptions, type VectorSearchResult, type VectorStore } from '../hallucination/retrieval.js'; /** * A Redis client that sends raw commands — what RediSearch's `FT.*` commands need. ioredis provides * `call()`; node-redis provides `sendCommand()`. Either works, and `call()` is used when a client has * both: ioredis has a `sendCommand()` too, which takes its own command object rather than an array. */ export type RedisVectorLikeClient = { /** Sends a command with its arguments, as ioredis does. */ call(command: string, ...args: Array): Promise; } | { /** Sends a command as one array, as node-redis does. */ sendCommand(args: Array): Promise; }; /** Options for the Redis store. */ export interface RedisVectorStoreOptions { /** Width of every vector. Must match the embedding function's output. */ dimensions: number; /** The RediSearch index. Defaults to `nexus:vectors`. */ index?: string; /** The prefix of each chunk's hash key. Defaults to `nexus:vector:`. */ prefix?: string; /** * Metadata fields a search can filter on. RediSearch filters only on fields declared in the index, * so these are indexed as tags, and a filter on any other field is refused. */ filterFields?: readonly string[]; /** `HNSW` for approximate search that scales, or `FLAT` for exact search. Defaults to `HNSW`. */ algorithm?: 'HNSW' | 'FLAT'; /** Embeds chunks that arrive without a vector, and search queries. Defaults to hashed term vectors. */ embed?: EmbeddingProvider; } /** * Retrieval chunks in Redis, searched by RediSearch's vector index (Redis Stack, Redis 8, or Redis * Cloud). * * No Redis package is a dependency: the store sends commands through the client you pass. Each chunk * is a hash holding its text, source, metadata as JSON, and its vector as float32 bytes. Declared * filter fields are copied into tag fields with their type, so a filter matches `3` and `"3"` as the * memory store does — as different values. */ export declare class RedisVectorStore implements VectorStore { private readonly options; private readonly send; private readonly index; private readonly prefix; private readonly fields; private readonly embed; constructor(client: RedisVectorLikeClient, options: RedisVectorStoreOptions); /** Creates the index unless it exists. 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; }