Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

community[patch]: add clientParams option to Chroma vectorstore init args #6308

Merged
merged 4 commits into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/langchain-community/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
15 changes: 13 additions & 2 deletions libs/langchain-community/src/vectorstores/chroma.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
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";
Expand Down Expand Up @@ -59,6 +63,8 @@ export class Chroma extends VectorStore {

numDimensions?: number;

clientParams?: Omit<ChromaClientParams, "path">;

url: string;

filter?: object;
Expand All @@ -67,12 +73,16 @@ export class Chroma extends VectorStore {
return "chroma";
}

constructor(embeddings: EmbeddingsInterface, args: ChromaLibArgs) {
constructor(
embeddings: EmbeddingsInterface,
args: ChromaLibArgs & { clientParams?: Omit<ChromaClientParams, "path"> }
bracesproul marked this conversation as resolved.
Show resolved Hide resolved
) {
super(embeddings, args);
this.numDimensions = args.numDimensions;
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) {
Expand Down Expand Up @@ -109,6 +119,7 @@ export class Chroma extends VectorStore {
if (!this.index) {
const chromaClient = new (await Chroma.imports()).ChromaClient({
path: this.url,
...(this.clientParams ?? {}),
});
this.index = chromaClient;
}
Expand Down
23 changes: 22 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11179,7 +11179,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
Expand Down Expand Up @@ -21917,6 +21917,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"
Expand Down