Skip to content

Commit

Permalink
[community]fix: #6296 add clientParams for chromadb.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeasonnow committed Aug 1, 2024
1 parent e09b66f commit 4191f80
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
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
8 changes: 6 additions & 2 deletions libs/langchain-community/src/vectorstores/chroma.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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 +59,8 @@ export class Chroma extends VectorStore {

numDimensions?: number;

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

url: string;

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

constructor(embeddings: EmbeddingsInterface, args: ChromaLibArgs) {
constructor(embeddings: EmbeddingsInterface, args: ChromaLibArgs & {clientParams?: Omit<ChromaClientParams, 'path'>}) {
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 +112,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

0 comments on commit 4191f80

Please sign in to comment.