add multi retrieval qa chain

This commit is contained in:
Henry
2023-05-25 13:50:11 +01:00
parent 2802ee0142
commit 769b4ea567
7 changed files with 1023 additions and 1 deletions
@@ -0,0 +1,61 @@
import { VectorStore } from 'langchain/vectorstores/base'
import { INode, INodeData, INodeParams, VectorStoreRetriever, VectorStoreRetrieverInput } from '../../../src/Interface'
class VectorStoreRetriever_Retrievers implements INode {
label: string
name: string
description: string
type: string
icon: string
category: string
baseClasses: string[]
inputs: INodeParams[]
constructor() {
this.label = 'Vector Store Retriever'
this.name = 'vectorStoreRetriever'
this.type = 'VectorStoreRetriever'
this.icon = 'vectorretriever.svg'
this.category = 'Retrievers'
this.description = 'Store vector store as retriever to be later queried by MultiRetrievalQAChain'
this.baseClasses = [this.type]
this.inputs = [
{
label: 'Vector Store',
name: 'vectorStore',
type: 'VectorStore'
},
{
label: 'Retriever Name',
name: 'name',
type: 'string',
placeholder: 'netflix movies'
},
{
label: 'Retriever Description',
name: 'description',
type: 'string',
rows: 3,
description: 'Description of when to use the vector store retriever',
placeholder: 'Good for answering questions about netflix movies'
}
]
}
async init(nodeData: INodeData): Promise<any> {
const name = nodeData.inputs?.name as string
const description = nodeData.inputs?.description as string
const vectorStore = nodeData.inputs?.vectorStore as VectorStore
const obj = {
name,
description,
vectorStore
} as VectorStoreRetrieverInput
const retriever = new VectorStoreRetriever(obj)
return retriever
}
}
module.exports = { nodeClass: VectorStoreRetriever_Retrievers }
@@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-database-export" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M4 6c0 1.657 3.582 3 8 3s8 -1.343 8 -3s-3.582 -3 -8 -3s-8 1.343 -8 3"></path>
<path d="M4 6v6c0 1.657 3.582 3 8 3c1.118 0 2.183 -.086 3.15 -.241"></path>
<path d="M20 12v-6"></path>
<path d="M4 12v6c0 1.657 3.582 3 8 3c.157 0 .312 -.002 .466 -.005"></path>
<path d="M16 19h6"></path>
<path d="M19 16l3 3l-3 3"></path>
</svg>

After

Width:  |  Height:  |  Size: 647 B