mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 15:00:57 +03:00
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:
@@ -111,6 +111,8 @@ class Chroma_VectorStores implements INode {
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
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 finalDocs = []
|
||||
@@ -124,9 +126,13 @@ class Chroma_VectorStores implements INode {
|
||||
collectionName: string
|
||||
url?: string
|
||||
chromaApiKey?: string
|
||||
chromaTenant?: string
|
||||
chromaDatabase?: string
|
||||
} = { collectionName }
|
||||
if (chromaURL) obj.url = chromaURL
|
||||
if (chromaApiKey) obj.chromaApiKey = chromaApiKey
|
||||
if (chromaTenant) obj.chromaTenant = chromaTenant
|
||||
if (chromaDatabase) obj.chromaDatabase = chromaDatabase
|
||||
|
||||
try {
|
||||
if (recordManager) {
|
||||
@@ -159,14 +165,20 @@ class Chroma_VectorStores implements INode {
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData)
|
||||
const chromaTenant = getCredentialParam('chromaTenant', credentialData, nodeData)
|
||||
const chromaDatabase = getCredentialParam('chromaDatabase', credentialData, nodeData)
|
||||
|
||||
const obj: {
|
||||
collectionName: string
|
||||
url?: string
|
||||
chromaApiKey?: string
|
||||
chromaTenant?: string
|
||||
chromaDatabase?: string
|
||||
} = { collectionName }
|
||||
if (chromaURL) obj.url = chromaURL
|
||||
if (chromaApiKey) obj.chromaApiKey = chromaApiKey
|
||||
if (chromaTenant) obj.chromaTenant = chromaTenant
|
||||
if (chromaDatabase) obj.chromaDatabase = chromaDatabase
|
||||
|
||||
try {
|
||||
if (recordManager) {
|
||||
@@ -199,6 +211,8 @@ class Chroma_VectorStores implements INode {
|
||||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const chromaApiKey = getCredentialParam('chromaApiKey', credentialData, nodeData)
|
||||
const chromaTenant = getCredentialParam('chromaTenant', credentialData, nodeData)
|
||||
const chromaDatabase = getCredentialParam('chromaDatabase', credentialData, nodeData)
|
||||
|
||||
const chromaMetadataFilter = nodeData.inputs?.chromaMetadataFilter
|
||||
|
||||
@@ -206,10 +220,14 @@ class Chroma_VectorStores implements INode {
|
||||
collectionName: string
|
||||
url?: string
|
||||
chromaApiKey?: string
|
||||
chromaTenant?: string
|
||||
chromaDatabase?: string
|
||||
filter?: object | undefined
|
||||
} = { collectionName }
|
||||
if (chromaURL) obj.url = chromaURL
|
||||
if (chromaApiKey) obj.chromaApiKey = chromaApiKey
|
||||
if (chromaTenant) obj.chromaTenant = chromaTenant
|
||||
if (chromaDatabase) obj.chromaDatabase = chromaDatabase
|
||||
if (chromaMetadataFilter) {
|
||||
const metadatafilter = typeof chromaMetadataFilter === 'object' ? chromaMetadataFilter : JSON.parse(chromaMetadataFilter)
|
||||
obj.filter = metadatafilter
|
||||
|
||||
@@ -9,6 +9,8 @@ interface ChromaAuth {
|
||||
|
||||
export class ChromaExtended extends Chroma {
|
||||
chromaApiKey?: string
|
||||
chromaTenant?: string
|
||||
chromaDatabase?: string
|
||||
|
||||
constructor(embeddings: Embeddings, args: ChromaLibArgs & Partial<ChromaAuth>) {
|
||||
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)
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user