Skip to content

Commit

Permalink
fallback to similarity search (#4960)
Browse files Browse the repository at this point in the history
If there are no metadata filters (NO_FILTER), instead of explicitly returning [], it should fallback to a similarity search
  • Loading branch information
guidev authored Apr 6, 2024
1 parent 5d0bd45 commit 82de094
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions langchain/src/retrievers/self_query/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,12 @@ export class SelfQueryRetriever<T extends VectorStore>
myQuery = generatedQuery;
}

if (!filter) {
return [];
} else {
return this.vectorStore.similaritySearch(
myQuery,
this.searchParams?.k,
filter,
runManager?.getChild("vectorstore")
);
}
return this.vectorStore.similaritySearch(
myQuery,
this.searchParams?.k,
filter,
runManager?.getChild("vectorstore")
);
}

/**
Expand Down

0 comments on commit 82de094

Please sign in to comment.