Skip to content

Fix vector store filter not work #4065

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

Merged
merged 5 commits into from
Feb 26, 2025
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 @@ -150,6 +150,7 @@ class ExtractMetadataRetriever_Retrievers implements INode {
prompt: dynamicMetadataFilterRetrieverPrompt,
topK: topK ? parseInt(topK, 10) : (vectorStore as any)?.k ?? 4
})
retriever.filter = vectorStore?.lc_kwargs?.filter ?? (vectorStore as any).filter

if (output === 'retriever') return retriever
else if (output === 'document') return await retriever.getRelevantDocuments(finalInputQuery)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ Passage:`
else if (promptKey) obj.promptTemplate = promptKey

const retriever = new HydeRetriever(obj)
retriever.filter = vectorStore?.lc_kwargs?.filter ?? (vectorStore as any).filter

if (output === 'retriever') return retriever
else if (output === 'document') return await retriever.getRelevantDocuments(query ? query : input)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class MultiQueryRetriever_Retrievers implements INode {

const retriever = MultiQueryRetriever.fromLLM({
llm: model,
retriever: vectorStore.asRetriever(),
retriever: vectorStore.asRetriever({ filter: vectorStore?.lc_kwargs?.filter ?? vectorStore?.filter }),
verbose: process.env.DEBUG === 'true',
// @ts-ignore
prompt: PromptTemplate.fromTemplate(prompt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class ReciprocalRankFusion extends BaseDocumentCompressor {
})
const docList: Document<Record<string, any>>[][] = []
for (let i = 0; i < queries.length; i++) {
const resultOne = await this.baseRetriever.vectorStore.similaritySearch(queries[i], 5)
const resultOne = await this.baseRetriever.vectorStore.similaritySearch(queries[i], 5, this.baseRetriever.filter)
const docs: any[] = []
resultOne.forEach((doc) => {
docs.push(doc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ class SimilarityThresholdRetriever_Retrievers implements INode {
maxK: maxK ? parseInt(maxK, 10) : 100,
kIncrement: kIncrement ? parseInt(kIncrement, 10) : 2
})
retriever.filter = vectorStore?.lc_kwargs?.filter ?? (vectorStore as any).filter

if (output === 'retriever') return retriever
else if (output === 'document') return await retriever.getRelevantDocuments(query ? query : input)
Expand Down