mirror of
https://github.com/farcasclaudiu/Flowise.git
synced 2026-06-28 21:00:58 +03:00
@@ -10,11 +10,16 @@ export const resolveVectorStoreOrRetriever = (
|
|||||||
const searchType = nodeData.outputs?.searchType as string
|
const searchType = nodeData.outputs?.searchType as string
|
||||||
const topK = nodeData.inputs?.topK as string
|
const topK = nodeData.inputs?.topK as string
|
||||||
const k = topK ? parseFloat(topK) : 4
|
const k = topK ? parseFloat(topK) : 4
|
||||||
|
const alpha = nodeData.inputs?.alpha
|
||||||
|
|
||||||
// If it is already pre-defined in lc_kwargs, then don't pass it again
|
// If it is already pre-defined in lc_kwargs, then don't pass it again
|
||||||
const filter = vectorStore?.lc_kwargs?.filter ? undefined : metadataFilter
|
const filter = vectorStore?.lc_kwargs?.filter ? undefined : metadataFilter
|
||||||
|
|
||||||
if (output === 'retriever') {
|
if (output === 'retriever') {
|
||||||
|
const searchKwargs: Record<string, any> = {}
|
||||||
|
if (alpha !== undefined) {
|
||||||
|
searchKwargs.alpha = parseFloat(alpha)
|
||||||
|
}
|
||||||
if ('mmr' === searchType) {
|
if ('mmr' === searchType) {
|
||||||
const fetchK = nodeData.inputs?.fetchK as string
|
const fetchK = nodeData.inputs?.fetchK as string
|
||||||
const lambda = nodeData.inputs?.lambda as string
|
const lambda = nodeData.inputs?.lambda as string
|
||||||
@@ -25,13 +30,18 @@ export const resolveVectorStoreOrRetriever = (
|
|||||||
k: k,
|
k: k,
|
||||||
filter,
|
filter,
|
||||||
searchKwargs: {
|
searchKwargs: {
|
||||||
|
//...searchKwargs,
|
||||||
fetchK: f,
|
fetchK: f,
|
||||||
lambda: l
|
lambda: l
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// "searchType" is "similarity"
|
// "searchType" is "similarity"
|
||||||
return vectorStore.asRetriever(k, filter)
|
return vectorStore.asRetriever({
|
||||||
|
k: k,
|
||||||
|
filter: filter,
|
||||||
|
searchKwargs: Object.keys(searchKwargs).length > 0 ? searchKwargs : undefined
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else if (output === 'vectorStore') {
|
} else if (output === 'vectorStore') {
|
||||||
;(vectorStore as any).k = k
|
;(vectorStore as any).k = k
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class Weaviate_VectorStores implements INode {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this.label = 'Weaviate'
|
this.label = 'Weaviate'
|
||||||
this.name = 'weaviate'
|
this.name = 'weaviate'
|
||||||
this.version = 3.0
|
this.version = 4.0
|
||||||
this.type = 'Weaviate'
|
this.type = 'Weaviate'
|
||||||
this.icon = 'weaviate.png'
|
this.icon = 'weaviate.png'
|
||||||
this.category = 'Vector Stores'
|
this.category = 'Vector Stores'
|
||||||
@@ -124,6 +124,16 @@ class Weaviate_VectorStores implements INode {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
addMMRInputParams(this.inputs)
|
addMMRInputParams(this.inputs)
|
||||||
|
this.inputs.push({
|
||||||
|
label: 'Alpha (for Hybrid Search)',
|
||||||
|
name: 'alpha',
|
||||||
|
description:
|
||||||
|
'Number between 0 and 1 that determines the weighting of keyword (BM25) portion of the hybrid search. A value of 1 is a pure vector search, while 0 is a pure keyword search.',
|
||||||
|
placeholder: '1',
|
||||||
|
type: 'number',
|
||||||
|
additionalParams: true,
|
||||||
|
optional: true
|
||||||
|
})
|
||||||
this.outputs = [
|
this.outputs = [
|
||||||
{
|
{
|
||||||
label: 'Weaviate Retriever',
|
label: 'Weaviate Retriever',
|
||||||
|
|||||||
Reference in New Issue
Block a user