diff --git a/libs/langchain-community/package.json b/libs/langchain-community/package.json index f1f4833fb4ae..81c1327aa7bf 100644 --- a/libs/langchain-community/package.json +++ b/libs/langchain-community/package.json @@ -138,7 +138,7 @@ "cassandra-driver": "^4.7.2", "cborg": "^4.1.1", "cheerio": "^1.0.0-rc.12", - "chromadb": "^1.5.3", + "chromadb": "^1.9.1", "closevector-common": "0.1.3", "closevector-node": "0.1.6", "closevector-web": "0.1.6", diff --git a/libs/langchain-community/src/vectorstores/chroma.ts b/libs/langchain-community/src/vectorstores/chroma.ts index b8db6da5d125..db92acd960c1 100644 --- a/libs/langchain-community/src/vectorstores/chroma.ts +++ b/libs/langchain-community/src/vectorstores/chroma.ts @@ -1,11 +1,23 @@ import * as uuid from "uuid"; -import type { ChromaClient as ChromaClientT, Collection } from "chromadb"; +import type { + ChromaClient as ChromaClientT, + Collection, + ChromaClientParams, +} from "chromadb"; import type { CollectionMetadata, Where } from "chromadb/dist/main/types.js"; import type { EmbeddingsInterface } from "@langchain/core/embeddings"; import { VectorStore } from "@langchain/core/vectorstores"; import { Document } from "@langchain/core/documents"; +type SharedChromaLibArgs = { + numDimensions?: number; + collectionName?: string; + filter?: object; + collectionMetadata?: CollectionMetadata; + clientParams?: Omit; +}; + /** * Defines the arguments that can be passed to the `Chroma` class * constructor. It can either contain a `url` for the Chroma database, the @@ -16,20 +28,12 @@ import { Document } from "@langchain/core/documents"; * `filter`. */ export type ChromaLibArgs = - | { + | ({ url?: string; - numDimensions?: number; - collectionName?: string; - filter?: object; - collectionMetadata?: CollectionMetadata; - } - | { + } & SharedChromaLibArgs) + | ({ index?: ChromaClientT; - numDimensions?: number; - collectionName?: string; - filter?: object; - collectionMetadata?: CollectionMetadata; - }; + } & SharedChromaLibArgs); /** * Defines the parameters for the `delete` method in the `Chroma` class. @@ -59,6 +63,8 @@ export class Chroma extends VectorStore { numDimensions?: number; + clientParams?: Omit; + url: string; filter?: object; @@ -73,6 +79,7 @@ export class Chroma extends VectorStore { this.embeddings = embeddings; this.collectionName = ensureCollectionName(args.collectionName); this.collectionMetadata = args.collectionMetadata; + this.clientParams = args.clientParams; if ("index" in args) { this.index = args.index; } else if ("url" in args) { @@ -109,6 +116,7 @@ export class Chroma extends VectorStore { if (!this.index) { const chromaClient = new (await Chroma.imports()).ChromaClient({ path: this.url, + ...(this.clientParams ?? {}), }); this.index = chromaClient; } diff --git a/yarn.lock b/yarn.lock index 131b835c6732..5eff4c3c057f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11178,7 +11178,7 @@ __metadata: cassandra-driver: ^4.7.2 cborg: ^4.1.1 cheerio: ^1.0.0-rc.12 - chromadb: ^1.5.3 + chromadb: ^1.9.1 closevector-common: 0.1.3 closevector-node: 0.1.6 closevector-web: 0.1.6 @@ -21924,6 +21924,27 @@ __metadata: languageName: node linkType: hard +"chromadb@npm:^1.9.1": + version: 1.9.1 + resolution: "chromadb@npm:1.9.1" + dependencies: + cliui: ^8.0.1 + isomorphic-fetch: ^3.0.0 + peerDependencies: + "@google/generative-ai": ^0.1.1 + cohere-ai: ^5.0.0 || ^6.0.0 || ^7.0.0 + openai: ^3.0.0 || ^4.0.0 + peerDependenciesMeta: + "@google/generative-ai": + optional: true + cohere-ai: + optional: true + openai: + optional: true + checksum: 9903891ee5811ec5a50d9c94057ea54d8f09d528749478f6ce1cbed4831544788f96d2c1301f7c3453f4ac5a2dd38380f1383686003d80a09e4e7dbc0d8b11f5 + languageName: node + linkType: hard + "chrome-trace-event@npm:^1.0.2": version: 1.0.3 resolution: "chrome-trace-event@npm:1.0.3"