File
Blob: src/cloudflare/vectorize.ts
| 1 | // Copyright (c) 2023 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | |
| 5 | /** |
| 6 | * A pre-configured list of known models. |
| 7 | * These can be supplied in place of configuring explicit dimensions. |
| 8 | */ |
| 9 | export const KnownModel = { |
| 10 | 'openai/text-embedding-ada-002': 'openai/text-embedding-ada-002', |
| 11 | 'cohere/embed-multilingual-v2.0': 'cohere/embed-multilingual-v2.0', |
| 12 | '@cf/baai/bge-small-en-v1.5': '@cf/baai/bge-small-en-v1.5', |
| 13 | '@cf/baai/bge-base-en-v1.5': '@cf/baai/bge-base-en-v1.5', |
| 14 | '@cf/baai/bge-large-en-v1.5': '@cf/baai/bge-large-en-v1.5', |
| 15 | } as const; |
| 16 | |
| 17 | /** |
| 18 | * Supported distance metrics for an index. |
| 19 | * Distance metrics determine how other "similar" vectors are determined. |
| 20 | */ |
| 21 | export const DistanceMetric = { |
| 22 | EUCLIDEAN: 'euclidean', |
| 23 | COSINE: 'cosine', |
| 24 | DOT_PRODUCT: 'dot-product', |
| 25 | } as const; |
| 26 | |
| 27 | /** |
| 28 | * Supported metadata return levels for a Vectorize query. |
| 29 | */ |
| 30 | export const MetadataRetrievalLevel = { |
| 31 | /** |
| 32 | * Full metadata for the vector return set, including all fields (including those un-indexed) without truncation. |
| 33 | * |
| 34 | * This is a more expensive retrieval, as it requires additional fetching & reading of un-indexed data. |
| 35 | */ |
| 36 | ALL: 'all', |
| 37 | /** |
| 38 | * Return all metadata fields configured for indexing in the vector return set. |
| 39 | * |
| 40 | * This level of retrieval is "free" in that no additional overhead is incurred returning this data. |
| 41 | * However, note that indexed metadata is subject to truncation (especially for larger strings). |
| 42 | */ |
| 43 | INDEXED: 'indexed', |
| 44 | /** No indexed metadata will be returned. */ |
| 45 | NONE: 'none', |
| 46 | } as const; |