mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-05 14:43:08 +00:00
Don't hardcode PGVector distance strategies (#10265)
- Description: Remove hardcoded/duplicated distance strategies in the PGVector store. - Issue: NA - Dependencies: NA - Tag maintainer: for a quicker response, tag the relevant maintainer (see below), - Twitter handle: @archmonkeymojo --------- Co-authored-by: Bagatur <baskaryan@gmail.com>
This commit is contained in:
parent
86cb9da735
commit
4df101cf77
@ -349,16 +349,16 @@ class PGVector(VectorStore):
|
||||
|
||||
@property
|
||||
def distance_strategy(self) -> Any:
|
||||
if self._distance_strategy == "l2":
|
||||
if self._distance_strategy == DistanceStrategy.EUCLIDEAN:
|
||||
return self.EmbeddingStore.embedding.l2_distance
|
||||
elif self._distance_strategy == "cosine":
|
||||
elif self._distance_strategy == DistanceStrategy.COSINE:
|
||||
return self.EmbeddingStore.embedding.cosine_distance
|
||||
elif self._distance_strategy == "inner":
|
||||
elif self._distance_strategy == DistanceStrategy.MAX_INNER_PRODUCT:
|
||||
return self.EmbeddingStore.embedding.max_inner_product
|
||||
else:
|
||||
raise ValueError(
|
||||
f"Got unexpected value for distance: {self._distance_strategy}. "
|
||||
f"Should be one of `l2`, `cosine`, `inner`."
|
||||
f"Should be one of {', '.join([ds.value for ds in DistanceStrategy])}."
|
||||
)
|
||||
|
||||
def similarity_search_with_score_by_vector(
|
||||
|
Loading…
Reference in New Issue
Block a user