Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/Add url to chroma #151

Merged
merged 1 commit into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ class Chroma_Existing_VectorStores implements INode {
label: 'Collection Name',
name: 'collectionName',
type: 'string'
},
{
label: 'Chroma URL',
name: 'chromaURL',
type: 'string',
optional: true
}
]
this.outputs = [
Expand All @@ -51,11 +57,16 @@ class Chroma_Existing_VectorStores implements INode {
async init(nodeData: INodeData): Promise<any> {
const collectionName = nodeData.inputs?.collectionName as string
const embeddings = nodeData.inputs?.embeddings as Embeddings
const chromaURL = nodeData.inputs?.chromaURL as string
const output = nodeData.outputs?.output as string

const vectorStore = await Chroma.fromExistingCollection(embeddings, {
collectionName
})
const obj: {
collectionName: string
url?: string
} = { collectionName }
if (chromaURL) obj.url = chromaURL

const vectorStore = await Chroma.fromExistingCollection(embeddings, obj)

if (output === 'retriever') {
const retriever = vectorStore.asRetriever()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class ChromaUpsert_VectorStores implements INode {
label: 'Collection Name',
name: 'collectionName',
type: 'string'
},
{
label: 'Chroma URL',
name: 'chromaURL',
type: 'string',
optional: true
}
]
this.outputs = [
Expand All @@ -59,6 +65,7 @@ class ChromaUpsert_VectorStores implements INode {
const collectionName = nodeData.inputs?.collectionName as string
const docs = nodeData.inputs?.document as Document[]
const embeddings = nodeData.inputs?.embeddings as Embeddings
const chromaURL = nodeData.inputs?.chromaURL as string
const output = nodeData.outputs?.output as string

const flattenDocs = docs && docs.length ? docs.flat() : []
Expand All @@ -67,9 +74,13 @@ class ChromaUpsert_VectorStores implements INode {
finalDocs.push(new Document(flattenDocs[i]))
}

const vectorStore = await Chroma.fromDocuments(finalDocs, embeddings, {
collectionName
})
const obj: {
collectionName: string
url?: string
} = { collectionName }
if (chromaURL) obj.url = chromaURL

const vectorStore = await Chroma.fromDocuments(finalDocs, embeddings, obj)

if (output === 'retriever') {
const retriever = vectorStore.asRetriever()
Expand Down