Add tenant and database configs for Chroma Cloud credentials (#3872)

* Add tenant and database configs for Chroma Cloud credentials

* Lint fix
This commit is contained in:
itaismith
2025-01-20 10:39:00 -08:00
committed by GitHub
parent 320eab65d6
commit 3fc4e79089
5 changed files with 35404 additions and 35404 deletions
@@ -16,6 +16,16 @@ class ChromaApi implements INodeCredential {
label: 'Chroma Api Key', label: 'Chroma Api Key',
name: 'chromaApiKey', name: 'chromaApiKey',
type: 'password' type: 'password'
},
{
label: 'Chroma Tenant',
name: 'chromaTenant',
type: 'string'
},
{
label: 'Chroma Database',
name: 'chromaDatabase',
type: 'string'
} }
] ]
} }
@@ -111,6 +111,8 @@ class Chroma_VectorStores implements INode {
const credentialData = await getCredentialData(nodeData.credential ?? '', options) const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData) const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData)
const chromaTenant = getCredentialParam('chromaTenant', credentialData, nodeData)
const chromaDatabase = getCredentialParam('chromaDatabase', credentialData, nodeData)
const flattenDocs = docs && docs.length ? flatten(docs) : [] const flattenDocs = docs && docs.length ? flatten(docs) : []
const finalDocs = [] const finalDocs = []
@@ -124,9 +126,13 @@ class Chroma_VectorStores implements INode {
collectionName: string collectionName: string
url?: string url?: string
chromaApiKey?: string chromaApiKey?: string
chromaTenant?: string
chromaDatabase?: string
} = { collectionName } } = { collectionName }
if (chromaURL) obj.url = chromaURL if (chromaURL) obj.url = chromaURL
if (chromaApiKey) obj.chromaApiKey = chromaApiKey if (chromaApiKey) obj.chromaApiKey = chromaApiKey
if (chromaTenant) obj.chromaTenant = chromaTenant
if (chromaDatabase) obj.chromaDatabase = chromaDatabase
try { try {
if (recordManager) { if (recordManager) {
@@ -159,14 +165,20 @@ class Chroma_VectorStores implements INode {
const credentialData = await getCredentialData(nodeData.credential ?? '', options) const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData) const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData)
const chromaTenant = getCredentialParam('chromaTenant', credentialData, nodeData)
const chromaDatabase = getCredentialParam('chromaDatabase', credentialData, nodeData)
const obj: { const obj: {
collectionName: string collectionName: string
url?: string url?: string
chromaApiKey?: string chromaApiKey?: string
chromaTenant?: string
chromaDatabase?: string
} = { collectionName } } = { collectionName }
if (chromaURL) obj.url = chromaURL if (chromaURL) obj.url = chromaURL
if (chromaApiKey) obj.chromaApiKey = chromaApiKey if (chromaApiKey) obj.chromaApiKey = chromaApiKey
if (chromaTenant) obj.chromaTenant = chromaTenant
if (chromaDatabase) obj.chromaDatabase = chromaDatabase
try { try {
if (recordManager) { if (recordManager) {
@@ -199,6 +211,8 @@ class Chroma_VectorStores implements INode {
const credentialData = await getCredentialData(nodeData.credential ?? '', options) const credentialData = await getCredentialData(nodeData.credential ?? '', options)
const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData) const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData)
const chromaTenant = getCredentialParam('chromaTenant', credentialData, nodeData)
const chromaDatabase = getCredentialParam('chromaDatabase', credentialData, nodeData)
const chromaMetadataFilter = nodeData.inputs?.chromaMetadataFilter const chromaMetadataFilter = nodeData.inputs?.chromaMetadataFilter
@@ -206,10 +220,14 @@ class Chroma_VectorStores implements INode {
collectionName: string collectionName: string
url?: string url?: string
chromaApiKey?: string chromaApiKey?: string
chromaTenant?: string
chromaDatabase?: string
filter?: object | undefined filter?: object | undefined
} = { collectionName } } = { collectionName }
if (chromaURL) obj.url = chromaURL if (chromaURL) obj.url = chromaURL
if (chromaApiKey) obj.chromaApiKey = chromaApiKey if (chromaApiKey) obj.chromaApiKey = chromaApiKey
if (chromaTenant) obj.chromaTenant = chromaTenant
if (chromaDatabase) obj.chromaDatabase = chromaDatabase
if (chromaMetadataFilter) { if (chromaMetadataFilter) {
const metadatafilter = typeof chromaMetadataFilter === 'object' ? chromaMetadataFilter : JSON.parse(chromaMetadataFilter) const metadatafilter = typeof chromaMetadataFilter === 'object' ? chromaMetadataFilter : JSON.parse(chromaMetadataFilter)
obj.filter = metadatafilter obj.filter = metadatafilter
@@ -9,6 +9,8 @@ interface ChromaAuth {
export class ChromaExtended extends Chroma { export class ChromaExtended extends Chroma {
chromaApiKey?: string chromaApiKey?: string
chromaTenant?: string
chromaDatabase?: string
constructor(embeddings: Embeddings, args: ChromaLibArgs & Partial<ChromaAuth>) { constructor(embeddings: Embeddings, args: ChromaLibArgs & Partial<ChromaAuth>) {
super(embeddings, args) super(embeddings, args)
@@ -34,6 +36,12 @@ export class ChromaExtended extends Chroma {
} }
} }
} }
if (this.chromaTenant) {
obj.tenant = this.chromaTenant
}
if (this.chromaDatabase) {
obj.database = this.chromaDatabase
}
this.index = new ChromaClient(obj) this.index = new ChromaClient(obj)
} }
try { try {
+1 -1
View File
@@ -73,7 +73,7 @@
"assemblyai": "^4.2.2", "assemblyai": "^4.2.2",
"axios": "1.6.2", "axios": "1.6.2",
"cheerio": "^1.0.0-rc.12", "cheerio": "^1.0.0-rc.12",
"chromadb": "^1.5.11", "chromadb": "^1.10.0",
"cohere-ai": "^7.7.5", "cohere-ai": "^7.7.5",
"composio-core": "^0.4.7", "composio-core": "^0.4.7",
"couchbase": "4.4.1", "couchbase": "4.4.1",
+6017 -6053
View File
File diff suppressed because one or more lines are too long