Merge pull request #950 from FlowiseAI/bugfix/ChromaInstall

Bugfix/Chroma installation fix
This commit is contained in:
Henry Heng
2023-09-20 14:26:37 +01:00
committed by GitHub
2 changed files with 5 additions and 4 deletions
@@ -1,6 +1,7 @@
import { Chroma, ChromaLibArgs } from 'langchain/vectorstores/chroma' import { Chroma, ChromaLibArgs } from 'langchain/vectorstores/chroma'
import { Embeddings } from 'langchain/embeddings/base' import { Embeddings } from 'langchain/embeddings/base'
import type { Collection } from 'chromadb' import type { Collection } from 'chromadb'
import { ChromaClient } from 'chromadb'
interface ChromaAuth { interface ChromaAuth {
chromaApiKey?: string chromaApiKey?: string
@@ -23,7 +24,6 @@ export class ChromaExtended extends Chroma {
async ensureCollection(): Promise<Collection> { async ensureCollection(): Promise<Collection> {
if (!this.collection) { if (!this.collection) {
if (!this.index) { if (!this.index) {
const { ChromaClient } = await Chroma.imports()
const obj: any = { const obj: any = {
path: this.url path: this.url
} }
@@ -37,8 +37,9 @@ export class ChromaExtended extends Chroma {
this.index = new ChromaClient(obj) this.index = new ChromaClient(obj)
} }
try { try {
this.collection = await this.index.getOrCreateCollection({ this.collection = await this.index!.getOrCreateCollection({
name: this.collectionName name: this.collectionName,
...(this.collectionMetadata && { metadata: this.collectionMetadata })
}) })
} catch (err) { } catch (err) {
throw new Error(`Chroma getOrCreateCollection error: ${err}`) throw new Error(`Chroma getOrCreateCollection error: ${err}`)
+1 -1
View File
@@ -32,7 +32,7 @@
"apify-client": "^2.7.1", "apify-client": "^2.7.1",
"axios": "^0.27.2", "axios": "^0.27.2",
"cheerio": "^1.0.0-rc.12", "cheerio": "^1.0.0-rc.12",
"chromadb": "^1.5.3", "chromadb": "^1.5.11",
"cohere-ai": "^6.2.0", "cohere-ai": "^6.2.0",
"d3-dsv": "2", "d3-dsv": "2",
"dotenv": "^16.0.0", "dotenv": "^16.0.0",