@mastra/chroma 0.11.2 → 0.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,23 +1,4 @@
1
1
 
2
- > @mastra/chroma@0.11.2-alpha.0 build /home/runner/work/mastra/mastra/stores/chroma
3
- > tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
2
+ > @mastra/chroma@0.11.3-alpha.0 build /home/runner/work/mastra/mastra/stores/chroma
3
+ > tsup --silent --config tsup.config.ts
4
4
 
5
- CLI Building entry: src/index.ts
6
- CLI Using tsconfig: tsconfig.json
7
- CLI tsup v8.5.0
8
- TSC Build start
9
- TSC ⚡️ Build success in 11571ms
10
- DTS Build start
11
- CLI Target: es2022
12
- Analysis will use the bundled TypeScript version 5.8.3
13
- Writing package typings: /home/runner/work/mastra/mastra/stores/chroma/dist/_tsup-dts-rollup.d.ts
14
- Analysis will use the bundled TypeScript version 5.8.3
15
- Writing package typings: /home/runner/work/mastra/mastra/stores/chroma/dist/_tsup-dts-rollup.d.cts
16
- DTS ⚡️ Build success in 11519ms
17
- CLI Cleaning output folder
18
- ESM Build start
19
- CJS Build start
20
- ESM dist/index.js 14.87 KB
21
- ESM ⚡️ Build success in 892ms
22
- CJS dist/index.cjs 15.17 KB
23
- CJS ⚡️ Build success in 892ms
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # @mastra/chroma
2
2
 
3
+ ## 0.11.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
8
+ - Updated dependencies [cb36de0]
9
+ - Updated dependencies [d0496e6]
10
+ - Updated dependencies [a82b851]
11
+ - Updated dependencies [ea0c5f2]
12
+ - Updated dependencies [41a0a0e]
13
+ - Updated dependencies [2871020]
14
+ - Updated dependencies [94f4812]
15
+ - Updated dependencies [e202b82]
16
+ - Updated dependencies [e00f6a0]
17
+ - Updated dependencies [4a406ec]
18
+ - Updated dependencies [b0e43c1]
19
+ - Updated dependencies [5d377e5]
20
+ - Updated dependencies [1fb812e]
21
+ - Updated dependencies [35c5798]
22
+ - @mastra/core@0.13.0
23
+
24
+ ## 0.11.3-alpha.0
25
+
26
+ ### Patch Changes
27
+
28
+ - 4a406ec: fixes TypeScript declaration file imports to ensure proper ESM compatibility
29
+ - Updated dependencies [cb36de0]
30
+ - Updated dependencies [a82b851]
31
+ - Updated dependencies [41a0a0e]
32
+ - Updated dependencies [2871020]
33
+ - Updated dependencies [4a406ec]
34
+ - Updated dependencies [5d377e5]
35
+ - @mastra/core@0.13.0-alpha.2
36
+
3
37
  ## 0.11.2
4
38
 
5
39
  ### Patch Changes
package/dist/index.cjs CHANGED
@@ -444,3 +444,5 @@ Example Complex Query:
444
444
 
445
445
  exports.CHROMA_PROMPT = CHROMA_PROMPT;
446
446
  exports.ChromaVector = ChromaVector;
447
+ //# sourceMappingURL=index.cjs.map
448
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":["BaseFilterTranslator","MastraVector","ChromaClient","error","MastraError","ErrorDomain","ErrorCategory"],"mappings":";;;;;;;;AAuCO,IAAM,sBAAA,GAAN,cAAqCA,2BAAA,CAAyC;AAAA,EAChE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAGA,2BAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,SAAS,EAAC;AAAA,MACV,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAiD;AACzD,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,e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;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.cjs","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n QueryOperator,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;\n\ntype ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;\n\ntype ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';\n\nexport type ChromaVectorFilter = VectorFilter<\n keyof ChromaOperatorValueMap,\n ChromaOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaBlacklisted\n>;\n\ntype ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;\n\ntype ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;\n\nexport type ChromaVectorDocumentFilter = VectorFilter<\n keyof ChromaDocumentOperatorValueMap,\n ChromaDocumentOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaDocumentBlacklisted\n>;\n\n/**\n * Translator for Chroma filter queries.\n * Maintains MongoDB-compatible syntax while ensuring proper validation\n * and normalization of values.\n */\nexport class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: ChromaVectorFilter): ChromaVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n\n return this.translateNode(filter);\n }\n\n private translateNode(node: ChromaVectorFilter, currentPath: string = ''): any {\n // Handle primitive values and arrays\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Chroma');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value);\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n const multiOperatorConditions: any[] = [];\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check for multiple operators on same field\n const valueEntries = Object.entries(value);\n if (valueEntries.every(([op]) => this.isOperator(op)) && valueEntries.length > 1) {\n valueEntries.forEach(([op, opValue]) => {\n multiOperatorConditions.push({\n [newPath]: { [op]: this.normalizeComparisonValue(opValue) },\n });\n });\n continue;\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n // If we have multiple operators, return them combined with $and\n if (multiOperatorConditions.length > 0) {\n return { $and: multiOperatorConditions };\n }\n\n // Wrap in $and if there are multiple top-level fields\n if (Object.keys(result).length > 1 && !currentPath) {\n return {\n $and: Object.entries(result).map(([key, value]) => ({ [key]: value })),\n };\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any): any {\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { ChromaClient } from 'chromadb';\nimport type { UpdateRecordsParams, Collection } from 'chromadb';\nimport type { ChromaVectorDocumentFilter, ChromaVectorFilter } from './filter';\nimport { ChromaFilterTranslator } from './filter';\n\ninterface ChromaUpsertVectorParams extends UpsertVectorParams {\n documents?: string[];\n}\n\ninterface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {\n documentFilter?: ChromaVectorDocumentFilter;\n}\n\nexport class ChromaVector extends MastraVector<ChromaVectorFilter> {\n private client: ChromaClient;\n private collections: Map<string, any>;\n\n constructor({\n path,\n auth,\n }: {\n path: string;\n auth?: {\n provider: string;\n credentials: string;\n };\n }) {\n super();\n this.client = new ChromaClient({\n path,\n auth,\n });\n this.collections = new Map();\n }\n\n async getCollection(indexName: string, throwIfNotExists: boolean = true) {\n try {\n const collection = await this.client.getCollection({ name: indexName, embeddingFunction: undefined as any });\n this.collections.set(indexName, collection);\n } catch {\n if (throwIfNotExists) {\n throw new Error(`Index ${indexName} does not exist`);\n }\n return null;\n }\n return this.collections.get(indexName);\n }\n\n private validateVectorDimensions(vectors: number[][], dimension: number): void {\n for (let i = 0; i < vectors.length; i++) {\n if (vectors?.[i]?.length !== dimension) {\n throw new Error(\n `Vector at index ${i} has invalid dimension ${vectors?.[i]?.length}. Expected ${dimension} dimensions.`,\n );\n }\n }\n }\n\n async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {\n try {\n const collection = await this.getCollection(indexName);\n\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions(vectors, stats.dimension);\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n const normalizedMetadata = metadata || vectors.map(() => ({}));\n\n await collection.upsert({\n ids: generatedIds,\n embeddings: vectors,\n metadatas: normalizedMetadata,\n documents: documents,\n });\n\n return generatedIds;\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n private HnswSpaceMap = {\n cosine: 'cosine',\n euclidean: 'l2',\n dotproduct: 'ip',\n l2: 'euclidean',\n ip: 'dotproduct',\n };\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_DIMENSION',\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { dimension },\n });\n }\n const hnswSpace = this.HnswSpaceMap[metric];\n if (!hnswSpace || !['cosine', 'l2', 'ip'].includes(hnswSpace)) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC',\n text: `Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { metric },\n });\n }\n try {\n await this.client.createCollection({\n name: indexName,\n metadata: {\n dimension,\n 'hnsw:space': hnswSpace,\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('already exists')) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: ChromaVectorFilter) {\n const translator = new ChromaFilterTranslator();\n return translator.translate(filter);\n }\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n documentFilter,\n }: ChromaQueryVectorParams): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection(indexName, true);\n\n const defaultInclude = ['documents', 'metadatas', 'distances'];\n\n const translatedFilter = this.transformFilter(filter);\n const results = await collection.query({\n queryEmbeddings: [queryVector],\n nResults: topK,\n where: translatedFilter,\n whereDocument: documentFilter,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n\n return (results.ids[0] || []).map((id: string, index: number) => ({\n id,\n score: results.distances?.[0]?.[index] || 0,\n metadata: results.metadatas?.[0]?.[index] || {},\n document: results.documents?.[0]?.[index],\n ...(includeVector && { vector: results.embeddings?.[0]?.[index] || [] }),\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const collections = await this.client.listCollections();\n return collections.map(collection => collection);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const collection = await this.getCollection(indexName);\n const count = await collection.count();\n const metadata = collection.metadata;\n\n const hnswSpace = metadata?.['hnsw:space'] as 'cosine' | 'l2' | 'ip';\n\n return {\n dimension: metadata?.dimension || 0,\n count,\n metric: this.HnswSpaceMap[hnswSpace] as 'cosine' | 'euclidean' | 'dotproduct',\n };\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection({ name: indexName });\n this.collections.delete(indexName);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_NO_PAYLOAD',\n text: 'No updates provided for vector',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName, id },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection(indexName, true);\n\n const updateOptions: UpdateRecordsParams = { ids: [id] };\n\n if (update?.vector) {\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions([update.vector], stats.dimension);\n updateOptions.embeddings = [update.vector];\n }\n\n if (update?.metadata) {\n updateOptions.metadatas = [update.metadata];\n }\n\n return await collection.update(updateOptions);\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPDATE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection: Collection = await this.getCollection(indexName, true);\n await collection.delete({ ids: [id] });\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Chroma Vector.\n */\nexport const CHROMA_PROMPT = `When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { CHROMA_PROMPT } from './_tsup-dts-rollup.js';
2
- export { ChromaVector } from './_tsup-dts-rollup.js';
1
+ export * from './vector/index.js';
2
+ export { CHROMA_PROMPT } from './vector/prompt.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js CHANGED
@@ -441,3 +441,5 @@ Example Complex Query:
441
441
  }`;
442
442
 
443
443
  export { CHROMA_PROMPT, ChromaVector };
444
+ //# sourceMappingURL=index.js.map
445
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vector/filter.ts","../src/vector/index.ts","../src/vector/prompt.ts"],"names":[],"mappings":";;;;;;AAuCO,IAAM,sBAAA,GAAN,cAAqC,oBAAA,CAAyC;AAAA,EAChE,qBAAA,GAAyC;AAC1D,IAAA,OAAO;AAAA,MACL,GAAG,oBAAA,CAAqB,iBAAA;AAAA,MACxB,OAAA,EAAS,CAAC,MAAA,EAAQ,KAAK,CAAA;AAAA,MACvB,KAAA,EAAO,CAAC,KAAA,EAAO,MAAM,CAAA;AAAA,MACrB,SAAS,EAAC;AAAA,MACV,OAAO,EAAC;AAAA,MACR,QAAQ;AAAC,KACX;AAAA,EACF;AAAA,EAEA,UAAU,MAAA,EAAiD;AACzD,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAO,MAAA;AACjC,IAAA,IAAA,CAAK,eAAe,MAAM,CAAA;AAE1B,IAAA,OAAO,IAAA,CAAK,cAAc,MAAM,CAAA;AAAA,EAClC;AAAA,EAEQ,aAAA,CAAc,IAAA,EAA0B,WAAA,GAAsB,EAAA,EAAS;AAE7E,IAAA,IAAI,IAAA,CAAK,OAAA,CAAQ,IAAI,CAAA,EAAG;AACtB,MAAA,MAAM,IAAI,MAAM,kCAAkC,CAAA;AAAA,IACpD;AACA,IAAA,IAAI,KAAK,WAAA,CAAY,IAAI,GAAG,OAAO,IAAA,CAAK,yBAAyB,IAAI,CAAA;AACrE,IAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,IAAI,CAAA,EAAG,OAAO,EAAE,GAAA,EAAK,IAAA,CAAK,oBAAA,C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GAAG,CAAA;AAAA,IACvC,SAAS,KAAA,EAAY;AACnB,MAAA,IAAI,KAAA,YAAiB,aAAa,MAAM,KAAA;AACxC,MAAA,MAAM,IAAI,WAAA;AAAA,QACR;AAAA,UACE,EAAA,EAAI,6BAAA;AAAA,UACJ,QAAQ,WAAA,CAAY,aAAA;AAAA,UACpB,UAAU,aAAA,CAAc,WAAA;AAAA,UACxB,OAAA,EAAS,EAAE,SAAA,EAAW,EAAA;AAAG,SAC3B;AAAA,QACA;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF;;;AC/UO,IAAM,aAAA,GAAgB,CAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA","file":"index.js","sourcesContent":["import { BaseFilterTranslator } from '@mastra/core/vector/filter';\nimport type {\n VectorFilter,\n OperatorSupport,\n QueryOperator,\n OperatorValueMap,\n LogicalOperatorValueMap,\n BlacklistedRootOperators,\n} from '@mastra/core/vector/filter';\n\ntype ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;\n\ntype ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;\n\ntype ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';\n\nexport type ChromaVectorFilter = VectorFilter<\n keyof ChromaOperatorValueMap,\n ChromaOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaBlacklisted\n>;\n\ntype ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;\n\ntype ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;\n\nexport type ChromaVectorDocumentFilter = VectorFilter<\n keyof ChromaDocumentOperatorValueMap,\n ChromaDocumentOperatorValueMap,\n ChromaLogicalOperatorValueMap,\n ChromaDocumentBlacklisted\n>;\n\n/**\n * Translator for Chroma filter queries.\n * Maintains MongoDB-compatible syntax while ensuring proper validation\n * and normalization of values.\n */\nexport class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {\n protected override getSupportedOperators(): OperatorSupport {\n return {\n ...BaseFilterTranslator.DEFAULT_OPERATORS,\n logical: ['$and', '$or'],\n array: ['$in', '$nin'],\n element: [],\n regex: [],\n custom: [],\n };\n }\n\n translate(filter?: ChromaVectorFilter): ChromaVectorFilter {\n if (this.isEmpty(filter)) return filter;\n this.validateFilter(filter);\n\n return this.translateNode(filter);\n }\n\n private translateNode(node: ChromaVectorFilter, currentPath: string = ''): any {\n // Handle primitive values and arrays\n if (this.isRegex(node)) {\n throw new Error('Regex is not supported in Chroma');\n }\n if (this.isPrimitive(node)) return this.normalizeComparisonValue(node);\n if (Array.isArray(node)) return { $in: this.normalizeArrayValues(node) };\n\n const entries = Object.entries(node as Record<string, any>);\n const firstEntry = entries[0];\n // Handle single operator case\n if (entries.length === 1 && firstEntry && this.isOperator(firstEntry[0])) {\n const [operator, value] = firstEntry;\n const translated = this.translateOperator(operator, value);\n return this.isLogicalOperator(operator) ? { [operator]: translated } : translated;\n }\n\n // Process each entry\n const result: Record<string, any> = {};\n const multiOperatorConditions: any[] = [];\n\n for (const [key, value] of entries) {\n const newPath = currentPath ? `${currentPath}.${key}` : key;\n\n if (this.isOperator(key)) {\n result[key] = this.translateOperator(key, value);\n continue;\n }\n\n if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Check for multiple operators on same field\n const valueEntries = Object.entries(value);\n if (valueEntries.every(([op]) => this.isOperator(op)) && valueEntries.length > 1) {\n valueEntries.forEach(([op, opValue]) => {\n multiOperatorConditions.push({\n [newPath]: { [op]: this.normalizeComparisonValue(opValue) },\n });\n });\n continue;\n }\n\n // Check if the nested object contains operators\n if (Object.keys(value).length === 0) {\n result[newPath] = this.translateNode(value);\n } else {\n const hasOperators = Object.keys(value).some(k => this.isOperator(k));\n if (hasOperators) {\n // For objects with operators, normalize each operator value\n const normalizedValue: Record<string, any> = {};\n for (const [op, opValue] of Object.entries(value)) {\n normalizedValue[op] = this.isOperator(op) ? this.translateOperator(op, opValue) : opValue;\n }\n result[newPath] = normalizedValue;\n } else {\n // For objects without operators, flatten them\n Object.assign(result, this.translateNode(value, newPath));\n }\n }\n } else {\n result[newPath] = this.translateNode(value);\n }\n }\n\n // If we have multiple operators, return them combined with $and\n if (multiOperatorConditions.length > 0) {\n return { $and: multiOperatorConditions };\n }\n\n // Wrap in $and if there are multiple top-level fields\n if (Object.keys(result).length > 1 && !currentPath) {\n return {\n $and: Object.entries(result).map(([key, value]) => ({ [key]: value })),\n };\n }\n\n return result;\n }\n\n private translateOperator(operator: QueryOperator, value: any): any {\n // Handle logical operators\n if (this.isLogicalOperator(operator)) {\n return Array.isArray(value) ? value.map(item => this.translateNode(item)) : this.translateNode(value);\n }\n\n // Handle comparison and element operators\n return this.normalizeComparisonValue(value);\n }\n}\n","import { MastraError, ErrorDomain, ErrorCategory } from '@mastra/core/error';\nimport { MastraVector } from '@mastra/core/vector';\nimport type {\n QueryResult,\n IndexStats,\n CreateIndexParams,\n UpsertVectorParams,\n QueryVectorParams,\n DescribeIndexParams,\n DeleteIndexParams,\n DeleteVectorParams,\n UpdateVectorParams,\n} from '@mastra/core/vector';\nimport { ChromaClient } from 'chromadb';\nimport type { UpdateRecordsParams, Collection } from 'chromadb';\nimport type { ChromaVectorDocumentFilter, ChromaVectorFilter } from './filter';\nimport { ChromaFilterTranslator } from './filter';\n\ninterface ChromaUpsertVectorParams extends UpsertVectorParams {\n documents?: string[];\n}\n\ninterface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {\n documentFilter?: ChromaVectorDocumentFilter;\n}\n\nexport class ChromaVector extends MastraVector<ChromaVectorFilter> {\n private client: ChromaClient;\n private collections: Map<string, any>;\n\n constructor({\n path,\n auth,\n }: {\n path: string;\n auth?: {\n provider: string;\n credentials: string;\n };\n }) {\n super();\n this.client = new ChromaClient({\n path,\n auth,\n });\n this.collections = new Map();\n }\n\n async getCollection(indexName: string, throwIfNotExists: boolean = true) {\n try {\n const collection = await this.client.getCollection({ name: indexName, embeddingFunction: undefined as any });\n this.collections.set(indexName, collection);\n } catch {\n if (throwIfNotExists) {\n throw new Error(`Index ${indexName} does not exist`);\n }\n return null;\n }\n return this.collections.get(indexName);\n }\n\n private validateVectorDimensions(vectors: number[][], dimension: number): void {\n for (let i = 0; i < vectors.length; i++) {\n if (vectors?.[i]?.length !== dimension) {\n throw new Error(\n `Vector at index ${i} has invalid dimension ${vectors?.[i]?.length}. Expected ${dimension} dimensions.`,\n );\n }\n }\n }\n\n async upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]> {\n try {\n const collection = await this.getCollection(indexName);\n\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions(vectors, stats.dimension);\n const generatedIds = ids || vectors.map(() => crypto.randomUUID());\n const normalizedMetadata = metadata || vectors.map(() => ({}));\n\n await collection.upsert({\n ids: generatedIds,\n embeddings: vectors,\n metadatas: normalizedMetadata,\n documents: documents,\n });\n\n return generatedIds;\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPSERT_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n private HnswSpaceMap = {\n cosine: 'cosine',\n euclidean: 'l2',\n dotproduct: 'ip',\n l2: 'euclidean',\n ip: 'dotproduct',\n };\n\n async createIndex({ indexName, dimension, metric = 'cosine' }: CreateIndexParams): Promise<void> {\n if (!Number.isInteger(dimension) || dimension <= 0) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_DIMENSION',\n text: 'Dimension must be a positive integer',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { dimension },\n });\n }\n const hnswSpace = this.HnswSpaceMap[metric];\n if (!hnswSpace || !['cosine', 'l2', 'ip'].includes(hnswSpace)) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_CREATE_INDEX_INVALID_METRIC',\n text: `Invalid metric: \"${metric}\". Must be one of: cosine, euclidean, dotproduct`,\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { metric },\n });\n }\n try {\n await this.client.createCollection({\n name: indexName,\n metadata: {\n dimension,\n 'hnsw:space': hnswSpace,\n },\n });\n } catch (error: any) {\n // Check for 'already exists' error\n const message = error?.message || error?.toString();\n if (message && message.toLowerCase().includes('already exists')) {\n // Fetch collection info and check dimension\n await this.validateExistingIndex(indexName, dimension, metric);\n return;\n }\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_CREATE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n transformFilter(filter?: ChromaVectorFilter) {\n const translator = new ChromaFilterTranslator();\n return translator.translate(filter);\n }\n async query({\n indexName,\n queryVector,\n topK = 10,\n filter,\n includeVector = false,\n documentFilter,\n }: ChromaQueryVectorParams): Promise<QueryResult[]> {\n try {\n const collection = await this.getCollection(indexName, true);\n\n const defaultInclude = ['documents', 'metadatas', 'distances'];\n\n const translatedFilter = this.transformFilter(filter);\n const results = await collection.query({\n queryEmbeddings: [queryVector],\n nResults: topK,\n where: translatedFilter,\n whereDocument: documentFilter,\n include: includeVector ? [...defaultInclude, 'embeddings'] : defaultInclude,\n });\n\n return (results.ids[0] || []).map((id: string, index: number) => ({\n id,\n score: results.distances?.[0]?.[index] || 0,\n metadata: results.metadatas?.[0]?.[index] || {},\n document: results.documents?.[0]?.[index],\n ...(includeVector && { vector: results.embeddings?.[0]?.[index] || [] }),\n }));\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_QUERY_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async listIndexes(): Promise<string[]> {\n try {\n const collections = await this.client.listCollections();\n return collections.map(collection => collection);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_LIST_INDEXES_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n },\n error,\n );\n }\n }\n\n /**\n * Retrieves statistics about a vector index.\n *\n * @param {string} indexName - The name of the index to describe\n * @returns A promise that resolves to the index statistics including dimension, count and metric\n */\n async describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats> {\n try {\n const collection = await this.getCollection(indexName);\n const count = await collection.count();\n const metadata = collection.metadata;\n\n const hnswSpace = metadata?.['hnsw:space'] as 'cosine' | 'l2' | 'ip';\n\n return {\n dimension: metadata?.dimension || 0,\n count,\n metric: this.HnswSpaceMap[hnswSpace] as 'cosine' | 'euclidean' | 'dotproduct',\n };\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DESCRIBE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n async deleteIndex({ indexName }: DeleteIndexParams): Promise<void> {\n try {\n await this.client.deleteCollection({ name: indexName });\n this.collections.delete(indexName);\n } catch (error: any) {\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_INDEX_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName },\n },\n error,\n );\n }\n }\n\n /**\n * Updates a vector by its ID with the provided vector and/or metadata.\n * @param indexName - The name of the index containing the vector.\n * @param id - The ID of the vector to update.\n * @param update - An object containing the vector and/or metadata to update.\n * @param update.vector - An optional array of numbers representing the new vector.\n * @param update.metadata - An optional record containing the new metadata.\n * @returns A promise that resolves when the update is complete.\n * @throws Will throw an error if no updates are provided or if the update operation fails.\n */\n async updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void> {\n if (!update.vector && !update.metadata) {\n throw new MastraError({\n id: 'CHROMA_VECTOR_UPDATE_NO_PAYLOAD',\n text: 'No updates provided for vector',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.USER,\n details: { indexName, id },\n });\n }\n\n try {\n const collection: Collection = await this.getCollection(indexName, true);\n\n const updateOptions: UpdateRecordsParams = { ids: [id] };\n\n if (update?.vector) {\n const stats = await this.describeIndex({ indexName });\n this.validateVectorDimensions([update.vector], stats.dimension);\n updateOptions.embeddings = [update.vector];\n }\n\n if (update?.metadata) {\n updateOptions.metadatas = [update.metadata];\n }\n\n return await collection.update(updateOptions);\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_UPDATE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n\n async deleteVector({ indexName, id }: DeleteVectorParams): Promise<void> {\n try {\n const collection: Collection = await this.getCollection(indexName, true);\n await collection.delete({ ids: [id] });\n } catch (error: any) {\n if (error instanceof MastraError) throw error;\n throw new MastraError(\n {\n id: 'CHROMA_VECTOR_DELETE_FAILED',\n domain: ErrorDomain.MASTRA_VECTOR,\n category: ErrorCategory.THIRD_PARTY,\n details: { indexName, id },\n },\n error,\n );\n }\n }\n}\n","/**\n * Vector store specific prompt that details supported operators and examples.\n * This prompt helps users construct valid filters for Chroma Vector.\n */\nexport const CHROMA_PROMPT = `When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}`;\n"]}
@@ -0,0 +1,22 @@
1
+ import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
+ import type { VectorFilter, OperatorSupport, OperatorValueMap, LogicalOperatorValueMap, BlacklistedRootOperators } from '@mastra/core/vector/filter';
3
+ type ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;
4
+ type ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;
5
+ type ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';
6
+ export type ChromaVectorFilter = VectorFilter<keyof ChromaOperatorValueMap, ChromaOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaBlacklisted>;
7
+ type ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;
8
+ type ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;
9
+ export type ChromaVectorDocumentFilter = VectorFilter<keyof ChromaDocumentOperatorValueMap, ChromaDocumentOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaDocumentBlacklisted>;
10
+ /**
11
+ * Translator for Chroma filter queries.
12
+ * Maintains MongoDB-compatible syntax while ensuring proper validation
13
+ * and normalization of values.
14
+ */
15
+ export declare class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {
16
+ protected getSupportedOperators(): OperatorSupport;
17
+ translate(filter?: ChromaVectorFilter): ChromaVectorFilter;
18
+ private translateNode;
19
+ private translateOperator;
20
+ }
21
+ export {};
22
+ //# sourceMappingURL=filter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../src/vector/filter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EACV,YAAY,EACZ,eAAe,EAEf,gBAAgB,EAChB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,4BAA4B,CAAC;AAEpC,KAAK,sBAAsB,GAAG,IAAI,CAAC,gBAAgB,EAAE,SAAS,GAAG,YAAY,GAAG,QAAQ,GAAG,UAAU,CAAC,CAAC;AAEvG,KAAK,6BAA6B,GAAG,IAAI,CAAC,uBAAuB,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;AAEpF,KAAK,iBAAiB,GAAG,wBAAwB,GAAG,MAAM,GAAG,MAAM,CAAC;AAEpE,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAC3C,MAAM,sBAAsB,EAC5B,sBAAsB,EACtB,6BAA6B,EAC7B,iBAAiB,CAClB,CAAC;AAEF,KAAK,8BAA8B,GAAG,sBAAsB,CAAC;AAE7D,KAAK,yBAAyB,GAAG,OAAO,CAAC,iBAAiB,EAAE,WAAW,CAAC,CAAC;AAEzE,MAAM,MAAM,0BAA0B,GAAG,YAAY,CACnD,MAAM,8BAA8B,EACpC,8BAA8B,EAC9B,6BAA6B,EAC7B,yBAAyB,CAC1B,CAAC;AAEF;;;;GAIG;AACH,qBAAa,sBAAuB,SAAQ,oBAAoB,CAAC,kBAAkB,CAAC;cAC/D,qBAAqB,IAAI,eAAe;IAW3D,SAAS,CAAC,MAAM,CAAC,EAAE,kBAAkB,GAAG,kBAAkB;IAO1D,OAAO,CAAC,aAAa;IA8ErB,OAAO,CAAC,iBAAiB;CAS1B"}
@@ -0,0 +1,50 @@
1
+ import { MastraVector } from '@mastra/core/vector';
2
+ import type { QueryResult, IndexStats, CreateIndexParams, UpsertVectorParams, QueryVectorParams, DescribeIndexParams, DeleteIndexParams, DeleteVectorParams, UpdateVectorParams } from '@mastra/core/vector';
3
+ import type { ChromaVectorDocumentFilter, ChromaVectorFilter } from './filter.js';
4
+ interface ChromaUpsertVectorParams extends UpsertVectorParams {
5
+ documents?: string[];
6
+ }
7
+ interface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {
8
+ documentFilter?: ChromaVectorDocumentFilter;
9
+ }
10
+ export declare class ChromaVector extends MastraVector<ChromaVectorFilter> {
11
+ private client;
12
+ private collections;
13
+ constructor({ path, auth, }: {
14
+ path: string;
15
+ auth?: {
16
+ provider: string;
17
+ credentials: string;
18
+ };
19
+ });
20
+ getCollection(indexName: string, throwIfNotExists?: boolean): Promise<any>;
21
+ private validateVectorDimensions;
22
+ upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
23
+ private HnswSpaceMap;
24
+ createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
25
+ transformFilter(filter?: ChromaVectorFilter): ChromaVectorFilter;
26
+ query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
27
+ listIndexes(): Promise<string[]>;
28
+ /**
29
+ * Retrieves statistics about a vector index.
30
+ *
31
+ * @param {string} indexName - The name of the index to describe
32
+ * @returns A promise that resolves to the index statistics including dimension, count and metric
33
+ */
34
+ describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
35
+ deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
36
+ /**
37
+ * Updates a vector by its ID with the provided vector and/or metadata.
38
+ * @param indexName - The name of the index containing the vector.
39
+ * @param id - The ID of the vector to update.
40
+ * @param update - An object containing the vector and/or metadata to update.
41
+ * @param update.vector - An optional array of numbers representing the new vector.
42
+ * @param update.metadata - An optional record containing the new metadata.
43
+ * @returns A promise that resolves when the update is complete.
44
+ * @throws Will throw an error if no updates are provided or if the update operation fails.
45
+ */
46
+ updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
47
+ deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
48
+ }
49
+ export {};
50
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vector/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EACnB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAG/E,UAAU,wBAAyB,SAAQ,kBAAkB;IAC3D,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,UAAU,uBAAwB,SAAQ,iBAAiB,CAAC,kBAAkB,CAAC;IAC7E,cAAc,CAAC,EAAE,0BAA0B,CAAC;CAC7C;AAED,qBAAa,YAAa,SAAQ,YAAY,CAAC,kBAAkB,CAAC;IAChE,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,WAAW,CAAmB;gBAE1B,EACV,IAAI,EACJ,IAAI,GACL,EAAE;QACD,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE;YACL,QAAQ,EAAE,MAAM,CAAC;YACjB,WAAW,EAAE,MAAM,CAAC;SACrB,CAAC;KACH;IASK,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,gBAAgB,GAAE,OAAc;IAavE,OAAO,CAAC,wBAAwB;IAU1B,MAAM,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,wBAAwB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA+B3G,OAAO,CAAC,YAAY,CAMlB;IAEI,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,MAAiB,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAgDhG,eAAe,CAAC,MAAM,CAAC,EAAE,kBAAkB;IAIrC,KAAK,CAAC,EACV,SAAS,EACT,WAAW,EACX,IAAS,EACT,MAAM,EACN,aAAqB,EACrB,cAAc,GACf,EAAE,uBAAuB,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAoC7C,WAAW,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAgBtC;;;;;OAKG;IACG,aAAa,CAAC,EAAE,SAAS,EAAE,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IA2BtE,WAAW,CAAC,EAAE,SAAS,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBlE;;;;;;;;;OASG;IACG,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IAyC1E,YAAY,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBzE"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Vector store specific prompt that details supported operators and examples.
3
+ * This prompt helps users construct valid filters for Chroma Vector.
4
+ */
5
+ export declare const CHROMA_PROMPT = "When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}";
6
+ //# sourceMappingURL=prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt.d.ts","sourceRoot":"","sources":["../../src/vector/prompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,q8FAmExB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/chroma",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "description": "Chroma vector store provider for Mastra",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,7 +12,7 @@
12
12
  "default": "./dist/index.js"
13
13
  },
14
14
  "require": {
15
- "types": "./dist/index.d.cts",
15
+ "types": "./dist/index.d.ts",
16
16
  "default": "./dist/index.cjs"
17
17
  }
18
18
  },
@@ -29,15 +29,16 @@
29
29
  "tsup": "^8.5.0",
30
30
  "typescript": "^5.8.3",
31
31
  "vitest": "^3.2.4",
32
- "@mastra/core": "0.12.0",
33
- "@internal/lint": "0.0.24"
32
+ "@internal/lint": "0.0.27",
33
+ "@mastra/core": "0.13.0",
34
+ "@internal/types-builder": "0.0.2"
34
35
  },
35
36
  "peerDependencies": {
36
- "@mastra/core": ">=0.10.7-0 <0.13.0-0"
37
+ "@mastra/core": ">=0.10.7-0 <0.14.0-0"
37
38
  },
38
39
  "scripts": {
39
- "build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
40
- "build:watch": "pnpm build --watch",
40
+ "build": "tsup --silent --config tsup.config.ts",
41
+ "build:watch": "tsup --watch --silent --config tsup.config.ts",
41
42
  "test": "vitest run",
42
43
  "lint": "eslint ."
43
44
  }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": ["./tsconfig.json", "../../tsconfig.build.json"],
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src"
6
+ },
7
+ "include": ["src/**/*"],
8
+ "exclude": ["node_modules", "**/*.test.ts", "src/**/*.mock.ts"]
9
+ }
package/tsconfig.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "extends": "../../tsconfig.node.json",
3
- "include": ["src/**/*"],
3
+ "include": ["src/**/*", "tsup.config.ts"],
4
4
  "exclude": ["node_modules", "**/*.test.ts"]
5
5
  }
package/tsup.config.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { generateTypes } from '@internal/types-builder';
2
+ import { defineConfig } from 'tsup';
3
+
4
+ export default defineConfig({
5
+ entry: ['src/index.ts'],
6
+ format: ['esm', 'cjs'],
7
+ clean: true,
8
+ dts: false,
9
+ splitting: true,
10
+ treeshake: {
11
+ preset: 'smallest',
12
+ },
13
+ sourcemap: true,
14
+ onSuccess: async () => {
15
+ await generateTypes(process.cwd());
16
+ },
17
+ });
@@ -1,102 +0,0 @@
1
- import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
- import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
3
- import type { CreateIndexParams } from '@mastra/core/vector';
4
- import type { DeleteIndexParams } from '@mastra/core/vector';
5
- import type { DeleteVectorParams } from '@mastra/core/vector';
6
- import type { DescribeIndexParams } from '@mastra/core/vector';
7
- import type { IndexStats } from '@mastra/core/vector';
8
- import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
9
- import { MastraVector } from '@mastra/core/vector';
10
- import type { OperatorSupport } from '@mastra/core/vector/filter';
11
- import type { OperatorValueMap } from '@mastra/core/vector/filter';
12
- import type { QueryResult } from '@mastra/core/vector';
13
- import type { QueryVectorParams } from '@mastra/core/vector';
14
- import type { UpdateVectorParams } from '@mastra/core/vector';
15
- import type { UpsertVectorParams } from '@mastra/core/vector';
16
- import type { VectorFilter } from '@mastra/core/vector/filter';
17
-
18
- /**
19
- * Vector store specific prompt that details supported operators and examples.
20
- * This prompt helps users construct valid filters for Chroma Vector.
21
- */
22
- declare const CHROMA_PROMPT = "When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}";
23
- export { CHROMA_PROMPT }
24
- export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
25
-
26
- declare type ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';
27
-
28
- declare type ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;
29
-
30
- declare type ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;
31
-
32
- /**
33
- * Translator for Chroma filter queries.
34
- * Maintains MongoDB-compatible syntax while ensuring proper validation
35
- * and normalization of values.
36
- */
37
- export declare class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {
38
- protected getSupportedOperators(): OperatorSupport;
39
- translate(filter?: ChromaVectorFilter): ChromaVectorFilter;
40
- private translateNode;
41
- private translateOperator;
42
- }
43
-
44
- declare type ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;
45
-
46
- declare type ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;
47
-
48
- declare interface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {
49
- documentFilter?: ChromaVectorDocumentFilter;
50
- }
51
-
52
- declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
53
- documents?: string[];
54
- }
55
-
56
- declare class ChromaVector extends MastraVector<ChromaVectorFilter> {
57
- private client;
58
- private collections;
59
- constructor({ path, auth, }: {
60
- path: string;
61
- auth?: {
62
- provider: string;
63
- credentials: string;
64
- };
65
- });
66
- getCollection(indexName: string, throwIfNotExists?: boolean): Promise<any>;
67
- private validateVectorDimensions;
68
- upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
69
- private HnswSpaceMap;
70
- createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
71
- transformFilter(filter?: ChromaVectorFilter): ChromaVectorFilter;
72
- query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
73
- listIndexes(): Promise<string[]>;
74
- /**
75
- * Retrieves statistics about a vector index.
76
- *
77
- * @param {string} indexName - The name of the index to describe
78
- * @returns A promise that resolves to the index statistics including dimension, count and metric
79
- */
80
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
81
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
82
- /**
83
- * Updates a vector by its ID with the provided vector and/or metadata.
84
- * @param indexName - The name of the index containing the vector.
85
- * @param id - The ID of the vector to update.
86
- * @param update - An object containing the vector and/or metadata to update.
87
- * @param update.vector - An optional array of numbers representing the new vector.
88
- * @param update.metadata - An optional record containing the new metadata.
89
- * @returns A promise that resolves when the update is complete.
90
- * @throws Will throw an error if no updates are provided or if the update operation fails.
91
- */
92
- updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
93
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
94
- }
95
- export { ChromaVector }
96
- export { ChromaVector as ChromaVector_alias_1 }
97
-
98
- export declare type ChromaVectorDocumentFilter = VectorFilter<keyof ChromaDocumentOperatorValueMap, ChromaDocumentOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaDocumentBlacklisted>;
99
-
100
- export declare type ChromaVectorFilter = VectorFilter<keyof ChromaOperatorValueMap, ChromaOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaBlacklisted>;
101
-
102
- export { }
@@ -1,102 +0,0 @@
1
- import { BaseFilterTranslator } from '@mastra/core/vector/filter';
2
- import type { BlacklistedRootOperators } from '@mastra/core/vector/filter';
3
- import type { CreateIndexParams } from '@mastra/core/vector';
4
- import type { DeleteIndexParams } from '@mastra/core/vector';
5
- import type { DeleteVectorParams } from '@mastra/core/vector';
6
- import type { DescribeIndexParams } from '@mastra/core/vector';
7
- import type { IndexStats } from '@mastra/core/vector';
8
- import type { LogicalOperatorValueMap } from '@mastra/core/vector/filter';
9
- import { MastraVector } from '@mastra/core/vector';
10
- import type { OperatorSupport } from '@mastra/core/vector/filter';
11
- import type { OperatorValueMap } from '@mastra/core/vector/filter';
12
- import type { QueryResult } from '@mastra/core/vector';
13
- import type { QueryVectorParams } from '@mastra/core/vector';
14
- import type { UpdateVectorParams } from '@mastra/core/vector';
15
- import type { UpsertVectorParams } from '@mastra/core/vector';
16
- import type { VectorFilter } from '@mastra/core/vector/filter';
17
-
18
- /**
19
- * Vector store specific prompt that details supported operators and examples.
20
- * This prompt helps users construct valid filters for Chroma Vector.
21
- */
22
- declare const CHROMA_PROMPT = "When querying Chroma, you can ONLY use the operators listed below. Any other operators will be rejected.\nImportant: Don't explain how to construct the filter - use the specified operators and fields to search the content and return relevant results.\nIf a user tries to give an explicit operator that is not supported, reject the filter entirely and let them know that the operator is not supported.\n\nBasic Comparison Operators:\n- $eq: Exact match (default when using field: value)\n Example: { \"category\": \"electronics\" }\n- $ne: Not equal\n Example: { \"category\": { \"$ne\": \"electronics\" } }\n- $gt: Greater than\n Example: { \"price\": { \"$gt\": 100 } }\n- $gte: Greater than or equal\n Example: { \"price\": { \"$gte\": 100 } }\n- $lt: Less than\n Example: { \"price\": { \"$lt\": 100 } }\n- $lte: Less than or equal\n Example: { \"price\": { \"$lte\": 100 } }\n\nArray Operators:\n- $in: Match any value in array\n Example: { \"category\": { \"$in\": [\"electronics\", \"books\"] } }\n- $nin: Does not match any value in array\n Example: { \"category\": { \"$nin\": [\"electronics\", \"books\"] } }\n\nLogical Operators:\n- $and: Logical AND\n Example: { \"$and\": [{ \"price\": { \"$gt\": 100 } }, { \"category\": \"electronics\" }] }\n- $or: Logical OR\n Example: { \"$or\": [{ \"price\": { \"$lt\": 50 } }, { \"category\": \"books\" }] }\n\nRestrictions:\n- Regex patterns are not supported\n- Element operators are not supported\n- Only $and and $or logical operators are supported\n- Nested fields are supported using dot notation\n- Multiple conditions on the same field are supported with both implicit and explicit $and\n- Empty arrays in $in/$nin will return no results\n- If multiple top-level fields exist, they're wrapped in $and\n- Only logical operators ($and, $or) can be used at the top level\n- All other operators must be used within a field condition\n Valid: { \"field\": { \"$gt\": 100 } }\n Valid: { \"$and\": [...] }\n Invalid: { \"$gt\": 100 }\n Invalid: { \"$in\": [...] }\n- Logical operators must contain field conditions, not direct operators\n Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n Invalid: { \"$and\": [{ \"$gt\": 100 }] }\n- Logical operators ($and, $or):\n - Can only be used at top level or nested within other logical operators\n - Can not be used on a field level, or be nested inside a field\n - Can not be used inside an operator\n - Valid: { \"$and\": [{ \"field\": { \"$gt\": 100 } }] }\n - Valid: { \"$or\": [{ \"$and\": [{ \"field\": { \"$gt\": 100 } }] }] }\n - Invalid: { \"field\": { \"$and\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$or\": [{ \"$gt\": 100 }] } }\n - Invalid: { \"field\": { \"$gt\": { \"$and\": [{...}] } } }\n\nExample Complex Query:\n{\n \"$and\": [\n { \"category\": { \"$in\": [\"electronics\", \"computers\"] } },\n { \"price\": { \"$gte\": 100, \"$lte\": 1000 } },\n { \"$or\": [\n { \"inStock\": true },\n { \"preorder\": true }\n ]}\n ]\n}";
23
- export { CHROMA_PROMPT }
24
- export { CHROMA_PROMPT as CHROMA_PROMPT_alias_1 }
25
-
26
- declare type ChromaBlacklisted = BlacklistedRootOperators | '$nor' | '$not';
27
-
28
- declare type ChromaDocumentBlacklisted = Exclude<ChromaBlacklisted, '$contains'>;
29
-
30
- declare type ChromaDocumentOperatorValueMap = ChromaOperatorValueMap;
31
-
32
- /**
33
- * Translator for Chroma filter queries.
34
- * Maintains MongoDB-compatible syntax while ensuring proper validation
35
- * and normalization of values.
36
- */
37
- export declare class ChromaFilterTranslator extends BaseFilterTranslator<ChromaVectorFilter> {
38
- protected getSupportedOperators(): OperatorSupport;
39
- translate(filter?: ChromaVectorFilter): ChromaVectorFilter;
40
- private translateNode;
41
- private translateOperator;
42
- }
43
-
44
- declare type ChromaLogicalOperatorValueMap = Omit<LogicalOperatorValueMap, '$nor' | '$not'>;
45
-
46
- declare type ChromaOperatorValueMap = Omit<OperatorValueMap, '$exists' | '$elemMatch' | '$regex' | '$options'>;
47
-
48
- declare interface ChromaQueryVectorParams extends QueryVectorParams<ChromaVectorFilter> {
49
- documentFilter?: ChromaVectorDocumentFilter;
50
- }
51
-
52
- declare interface ChromaUpsertVectorParams extends UpsertVectorParams {
53
- documents?: string[];
54
- }
55
-
56
- declare class ChromaVector extends MastraVector<ChromaVectorFilter> {
57
- private client;
58
- private collections;
59
- constructor({ path, auth, }: {
60
- path: string;
61
- auth?: {
62
- provider: string;
63
- credentials: string;
64
- };
65
- });
66
- getCollection(indexName: string, throwIfNotExists?: boolean): Promise<any>;
67
- private validateVectorDimensions;
68
- upsert({ indexName, vectors, metadata, ids, documents }: ChromaUpsertVectorParams): Promise<string[]>;
69
- private HnswSpaceMap;
70
- createIndex({ indexName, dimension, metric }: CreateIndexParams): Promise<void>;
71
- transformFilter(filter?: ChromaVectorFilter): ChromaVectorFilter;
72
- query({ indexName, queryVector, topK, filter, includeVector, documentFilter, }: ChromaQueryVectorParams): Promise<QueryResult[]>;
73
- listIndexes(): Promise<string[]>;
74
- /**
75
- * Retrieves statistics about a vector index.
76
- *
77
- * @param {string} indexName - The name of the index to describe
78
- * @returns A promise that resolves to the index statistics including dimension, count and metric
79
- */
80
- describeIndex({ indexName }: DescribeIndexParams): Promise<IndexStats>;
81
- deleteIndex({ indexName }: DeleteIndexParams): Promise<void>;
82
- /**
83
- * Updates a vector by its ID with the provided vector and/or metadata.
84
- * @param indexName - The name of the index containing the vector.
85
- * @param id - The ID of the vector to update.
86
- * @param update - An object containing the vector and/or metadata to update.
87
- * @param update.vector - An optional array of numbers representing the new vector.
88
- * @param update.metadata - An optional record containing the new metadata.
89
- * @returns A promise that resolves when the update is complete.
90
- * @throws Will throw an error if no updates are provided or if the update operation fails.
91
- */
92
- updateVector({ indexName, id, update }: UpdateVectorParams): Promise<void>;
93
- deleteVector({ indexName, id }: DeleteVectorParams): Promise<void>;
94
- }
95
- export { ChromaVector }
96
- export { ChromaVector as ChromaVector_alias_1 }
97
-
98
- export declare type ChromaVectorDocumentFilter = VectorFilter<keyof ChromaDocumentOperatorValueMap, ChromaDocumentOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaDocumentBlacklisted>;
99
-
100
- export declare type ChromaVectorFilter = VectorFilter<keyof ChromaOperatorValueMap, ChromaOperatorValueMap, ChromaLogicalOperatorValueMap, ChromaBlacklisted>;
101
-
102
- export { }
package/dist/index.d.cts DELETED
@@ -1,2 +0,0 @@
1
- export { CHROMA_PROMPT } from './_tsup-dts-rollup.cjs';
2
- export { ChromaVector } from './_tsup-dts-rollup.cjs';