import { type EmbeddingProvider, type VectorDocument, type VectorSearchOptions, type VectorSearchResult, type VectorStore } from '../hallucination/retrieval.js'; /** The type of a metadata field a Weaviate collection filters on. */ export type WeaviateFieldType = 'text' | 'number' | 'boolean'; /** Options for the Weaviate store. */ export interface WeaviateVectorStoreOptions { /** The Weaviate server, such as `http://localhost:8080` or a Weaviate Cloud cluster URL. */ url: string; /** The collection (class) chunks are kept in. Must start with a capital letter. Defaults to `NexusChunk`. */ collection?: string; /** Width of every vector. Must match the embedding function's output. */ dimensions: number; /** Sent as a bearer token, for Weaviate Cloud or a server with API-key authentication. */ apiKey?: string; /** Embeds chunks that arrive without a vector, and search queries. Defaults to hashed term vectors. */ embed?: EmbeddingProvider; /** Replaces the global `fetch`, for a proxy, retries, or tests. */ fetch?: typeof globalThis.fetch; /** Headers added to every request. */ headers?: Record; /** Aborts a request that takes longer, in milliseconds. Defaults to 30 seconds. */ timeoutMs?: number; } /** Raised when Weaviate answers with an error, or reports one for an object in a batch. */ export declare class WeaviateError extends Error { /** The HTTP status Weaviate answered with; 200 for an error inside a successful batch or query. */ readonly status: number; /** Weaviate's response body, or the error it reported, as text. */ readonly body?: string | undefined; constructor(message: string, /** The HTTP status Weaviate answered with; 200 for an error inside a successful batch or query. */ status: number, /** Weaviate's response body, or the error it reported, as text. */ body?: string | undefined); } /** * Retrieval chunks in a Weaviate collection, through its REST and GraphQL APIs. * * No Weaviate client is a dependency. The collection brings its own vectors (no vectorizer) and uses * cosine distance; a result's score is one minus that distance. Object ids are stable UUIDs derived * from chunk ids, and the chunk id travels as the `chunkId` property. Top-level string, number, and * boolean metadata fields are copied under `meta_` properties for filtering; declare the ones you * filter on in `migrate()` so they are indexed with the right type. A filter is typed by the * collection's schema, read once when a filter first needs it: a value of another type than its * property matches nothing, as in every other store. */ export declare class WeaviateVectorStore implements VectorStore { private readonly options; private readonly base; private readonly collection; private readonly embed; /** Each property's data type, read from the schema the first time a filter needs it. */ private dataTypes?; constructor(options: WeaviateVectorStoreOptions); /** * Creates the collection unless it exists, then adds a property for each metadata field you filter * on that it does not have yet. A list declares text fields; a map names each field's type. Never * runs implicitly. */ migrate(options?: { filterFields?: readonly string[] | Record; }): 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; private nearVector; private results; /** Removes chunks by id. */ delete(ids: readonly string[]): Promise; /** * A filter as a GraphQL `where` argument, or `undefined` when a value can never match. Weaviate * refuses an operand of another type than the property's, where every other store finds nothing. */ private where; /** The data types of these properties, reading the schema again when one is not in the copy held. */ private dataTypesOf; private readDataTypes; private request; }