UNPKG

genkitx-cloud-sql-pg

Version:

Genkit AI framework plugin for Cloud SQL for PostgreSQL.

132 lines (130 loc) 4.54 kB
/** * Copyright 2025 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ declare class StrategyMixin { operator: string; searchFunction: string; indexFunction: string; constructor(operator: string, searchFunction: string, indexFunction: string); } /** * Enumerator of the Distance strategies. */ declare class DistanceStrategy extends StrategyMixin { static EUCLIDEAN: StrategyMixin; static COSINE_DISTANCE: StrategyMixin; static INNER_PRODUCT: StrategyMixin; } /** * The default distance strategy used for vector comparisons. * @type {DistanceStrategy} */ declare const DEFAULT_DISTANCE_STRATEGY: StrategyMixin; /** * The default suffix appended to index names. * @type {string} */ declare const DEFAULT_INDEX_NAME_SUFFIX: string; /** * Defines the base arguments for configuring a vector index. */ interface BaseIndexArgs { name?: string; distanceStrategy?: DistanceStrategy; partialIndexes?: string[]; } /** * Abstract base class for defining vector indexes. */ declare abstract class BaseIndex { name?: string; indexType: string; distanceStrategy: DistanceStrategy; partialIndexes?: string[]; /** * Constructs a new BaseIndex instance. * @param {string} [name] - The optional name of the index. * @param {string} [indexType='base'] - The type of the index. Defaults to 'base'. * @param {DistanceStrategy} [distanceStrategy=DistanceStrategy.COSINE_DISTANCE] - The distance strategy. Defaults to COSINE_DISTANCE. * @param {string[]} [partialIndexes] - Optional array of partial index definitions. */ constructor(name?: string, indexType?: string, distanceStrategy?: DistanceStrategy, partialIndexes?: string[]); /** * Set index query options for vector store initialization. */ abstract indexOptions(): string; } /** * Represents an Exact Nearest Neighbor (ENN) index. * This index type typically performs a brute-force search. */ declare class ExactNearestNeighbor extends BaseIndex { constructor(baseArgs?: BaseIndexArgs); indexOptions(): string; } /** * Represents a Hierarchical Navigable Small World (HNSW) index. * HNSW is an approximate nearest neighbor (ANN) algorithm. */ declare class HNSWIndex extends BaseIndex { m: number; efConstruction: number; /** * Constructs a new HNSWIndex instance. * @param {BaseIndexArgs} [baseArgs] - Optional base arguments for the index. * @param {number} [m=16] - The 'm' parameter for HNSW. Defaults to 16. * @param {number} [efConstruction=64] - The 'ef_construction' parameter for HNSW. Defaults to 64. */ constructor(baseArgs?: BaseIndexArgs, m?: number, efConstruction?: number); indexOptions(): string; } /** * Represents an Inverted File Index (IVFFlat) index. * IVFFlat is an approximate nearest neighbor (ANN) algorithm. */ declare class IVFFlatIndex extends BaseIndex { lists: number; /** * Constructs a new IVFFlatIndex instance. * @param {BaseIndexArgs} baseArgs - Base arguments for the index. * @param {number} [lists=100] - The number of lists for IVF-Flat. Defaults to 100. */ constructor(baseArgs: BaseIndexArgs, lists?: number); indexOptions(): string; } /** * Convert index attributes to string. * Must be implemented by subclasses. */ declare abstract class QueryOptions { abstract to_string(): string; } /** * Represents query options for an HNSW index. */ declare class HNSWQueryOptions extends QueryOptions { efSearch: number; constructor(efSearch?: number); to_string(): string; } /** * Represents query options for an IVF-Flat index. */ declare class IVFFlatQueryOptions extends QueryOptions { readonly probes: number; constructor(probes?: number); to_string(): string; } export { BaseIndex, type BaseIndexArgs, DEFAULT_DISTANCE_STRATEGY, DEFAULT_INDEX_NAME_SUFFIX, DistanceStrategy, ExactNearestNeighbor, HNSWIndex, HNSWQueryOptions, IVFFlatIndex, IVFFlatQueryOptions, QueryOptions };