Skip to content

Commit 55a2f83

Browse files
itaismithJJK801
authored andcommitted
Add tenant and database configs for Chroma Cloud credentials (FlowiseAI#3872)
* Add tenant and database configs for Chroma Cloud credentials * Lint fix
1 parent d4a9f0c commit 55a2f83

File tree

5 files changed

+117
-90
lines changed

5 files changed

+117
-90
lines changed

packages/components/credentials/ChromaApi.credential.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,16 @@ class ChromaApi implements INodeCredential {
1616
label: 'Chroma Api Key',
1717
name: 'chromaApiKey',
1818
type: 'password'
19+
},
20+
{
21+
label: 'Chroma Tenant',
22+
name: 'chromaTenant',
23+
type: 'string'
24+
},
25+
{
26+
label: 'Chroma Database',
27+
name: 'chromaDatabase',
28+
type: 'string'
1929
}
2030
]
2131
}

packages/components/nodes/vectorstores/Chroma/Chroma.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ class Chroma_VectorStores implements INode {
111111

112112
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
113113
const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData)
114+
const chromaTenant = getCredentialParam('chromaTenant', credentialData, nodeData)
115+
const chromaDatabase = getCredentialParam('chromaDatabase', credentialData, nodeData)
114116

115117
const flattenDocs = docs && docs.length ? flatten(docs) : []
116118
const finalDocs = []
@@ -124,9 +126,13 @@ class Chroma_VectorStores implements INode {
124126
collectionName: string
125127
url?: string
126128
chromaApiKey?: string
129+
chromaTenant?: string
130+
chromaDatabase?: string
127131
} = { collectionName }
128132
if (chromaURL) obj.url = chromaURL
129133
if (chromaApiKey) obj.chromaApiKey = chromaApiKey
134+
if (chromaTenant) obj.chromaTenant = chromaTenant
135+
if (chromaDatabase) obj.chromaDatabase = chromaDatabase
130136

131137
try {
132138
if (recordManager) {
@@ -159,14 +165,20 @@ class Chroma_VectorStores implements INode {
159165

160166
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
161167
const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData)
168+
const chromaTenant = getCredentialParam('chromaTenant', credentialData, nodeData)
169+
const chromaDatabase = getCredentialParam('chromaDatabase', credentialData, nodeData)
162170

163171
const obj: {
164172
collectionName: string
165173
url?: string
166174
chromaApiKey?: string
175+
chromaTenant?: string
176+
chromaDatabase?: string
167177
} = { collectionName }
168178
if (chromaURL) obj.url = chromaURL
169179
if (chromaApiKey) obj.chromaApiKey = chromaApiKey
180+
if (chromaTenant) obj.chromaTenant = chromaTenant
181+
if (chromaDatabase) obj.chromaDatabase = chromaDatabase
170182

171183
try {
172184
if (recordManager) {
@@ -199,17 +211,23 @@ class Chroma_VectorStores implements INode {
199211

200212
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
201213
const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData)
214+
const chromaTenant = getCredentialParam('chromaTenant', credentialData, nodeData)
215+
const chromaDatabase = getCredentialParam('chromaDatabase', credentialData, nodeData)
202216

203217
const chromaMetadataFilter = nodeData.inputs?.chromaMetadataFilter
204218

205219
const obj: {
206220
collectionName: string
207221
url?: string
208222
chromaApiKey?: string
223+
chromaTenant?: string
224+
chromaDatabase?: string
209225
filter?: object | undefined
210226
} = { collectionName }
211227
if (chromaURL) obj.url = chromaURL
212228
if (chromaApiKey) obj.chromaApiKey = chromaApiKey
229+
if (chromaTenant) obj.chromaTenant = chromaTenant
230+
if (chromaDatabase) obj.chromaDatabase = chromaDatabase
213231
if (chromaMetadataFilter) {
214232
const metadatafilter = typeof chromaMetadataFilter === 'object' ? chromaMetadataFilter : JSON.parse(chromaMetadataFilter)
215233
obj.filter = metadatafilter

packages/components/nodes/vectorstores/Chroma/core.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ interface ChromaAuth {
99

1010
export class ChromaExtended extends Chroma {
1111
chromaApiKey?: string
12+
chromaTenant?: string
13+
chromaDatabase?: string
1214

1315
constructor(embeddings: Embeddings, args: ChromaLibArgs & Partial<ChromaAuth>) {
1416
super(embeddings, args)
@@ -34,6 +36,12 @@ export class ChromaExtended extends Chroma {
3436
}
3537
}
3638
}
39+
if (this.chromaTenant) {
40+
obj.tenant = this.chromaTenant
41+
}
42+
if (this.chromaDatabase) {
43+
obj.database = this.chromaDatabase
44+
}
3745
this.index = new ChromaClient(obj)
3846
}
3947
try {

packages/components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"assemblyai": "^4.2.2",
7474
"axios": "1.6.2",
7575
"cheerio": "^1.0.0-rc.12",
76-
"chromadb": "^1.5.11",
76+
"chromadb": "^1.10.0",
7777
"cohere-ai": "^7.7.5",
7878
"composio-core": "^0.4.7",
7979
"couchbase": "4.4.1",

0 commit comments

Comments
 (0)