mirror of
https://github.com/langchain-ai/langchain-postgres.git
synced 2026-07-16 01:33:18 -04:00
kwargs chain is broken in PGVector's search methods
#53
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Voileexperiments on GitHub (Oct 27, 2024).
VectorStoreRetrieversupports passing arbitrary parameters into the underlyingVectorStorethroughsearch_kwargs. Similarly, baseVectorStoremethods passkwargsthrough its inner methods; see this.However, this is not done properly in the
PGVectormethods:similarity_search,similarity_search_with_scoreandmax_marginal_relevance_search_with_score_by_vectorbreaks thekwargschain, hence any additional named parameters are lost upon building the query.As example, please look at
similarity_search_with_scorein baseVectorStoreandPGVector: the former passkwargsinto the inner method as expected, while the latter isn't.This has important impacts as
kwargsis typically used to pass additional params into inner methods to enable customizability. For example, if I want to customize a query to join other tables, I should be able to just inheritPGVector, override__query_collectionand provide my custom query building logic. However, this would not be possible ifkwargsis not passed through the search methods.