chroma installation fix

This commit is contained in:
Henry
2023-09-20 01:22:56 +01:00
parent 79545d0e9b
commit 6484e29132
2 changed files with 5 additions and 4 deletions
@@ -1,6 +1,7 @@
import { Chroma, ChromaLibArgs } from 'langchain/vectorstores/chroma'
import { Embeddings } from 'langchain/embeddings/base'
import type { Collection } from 'chromadb'
import { ChromaClient } from 'chromadb'
interface ChromaAuth {
chromaApiKey?: string
@@ -23,7 +24,6 @@ export class ChromaExtended extends Chroma {
async ensureCollection(): Promise<Collection> {
if (!this.collection) {
if (!this.index) {
const { ChromaClient } = await Chroma.imports()
const obj: any = {
path: this.url
}
@@ -37,8 +37,9 @@ export class ChromaExtended extends Chroma {
this.index = new ChromaClient(obj)
}
try {
this.collection = await this.index.getOrCreateCollection({
name: this.collectionName
this.collection = await this.index!.getOrCreateCollection({
name: this.collectionName,
...(this.collectionMetadata && { metadata: this.collectionMetadata })
})
} catch (err) {
throw new Error(`Chroma getOrCreateCollection error: ${err}`)