@upstash/vector
Version:
An HTTP/REST based Vector DB client built on top of Upstash REST API.
68 lines (65 loc) • 2.37 kB
TypeScript
import { H as HttpClientConfig, R as RequesterConfig, D as Dict, I as Index$1 } from './vector-7jBuY6ad.js';
export { d as FetchResult, F as FusionAlgorithm, f as InfoResult, Q as QueryMode, e as QueryResult, c as RangeResult, a as Requester, S as SparseVector, U as UpstashRequest, b as UpstashResponse, V as Vector, W as WeightingStrategy } from './vector-7jBuY6ad.js';
/**
* Connection credentials for upstash vector.
* Get them from https://console.upstash.com/vector/<uuid>
*/
type IndexConfig = {
/**
* UPSTASH_VECTOR_REST_URL
*/
url?: string;
/**
* UPSTASH_VECTOR_REST_TOKEN
*/
token?: string;
/**
* The signal will allow aborting requests on the fly.
* For more check: https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
*/
signal?: HttpClientConfig["signal"];
/**
* Enable telemetry to help us improve the SDK.
* The sdk will send the sdk version, platform and node version as telemetry headers.
*
* @default true
*/
enableTelemetry?: boolean;
} & RequesterConfig;
/**
* Serverless vector client for upstash.
*/
declare class Index<TIndexMetadata extends Dict = Dict> extends Index$1<TIndexMetadata> {
/**
* Create a new vector client by providing the url and token
*
* @example
* ```typescript
* const index = new Index({
* url: "<UPSTASH_VECTOR_REST_URL>",
* token: "<UPSTASH_VECTOR_REST_TOKEN>",
* });
* ```
* OR
* This will automatically get environment variables from .env file
* ```typescript
* const index = new Index();
* ```
*/
constructor(config?: IndexConfig);
/**
* Create a new Upstash Vector instance from environment variables.
*
* Use this to automatically load connection secrets from your environment
* variables. For instance when using the Vercel integration.
*
* When used on the Cloudflare Workers, you can just pass the "env" context provided by Cloudflare.
* Else, this tries to load `UPSTASH_VECTOR_REST_URL` and `UPSTASH_VECTOR_REST_TOKEN` from
* your environment using `process.env`.
*/
static fromEnv(env?: {
UPSTASH_VECTOR_REST_URL: string;
UPSTASH_VECTOR_REST_TOKEN: string;
}, config?: Omit<IndexConfig, "url" | "token">): Index;
}
export { Index, type IndexConfig };