Skip to content

Commit

Permalink
Fix SingleStoreDB (langchain-ai#10534)
Browse files Browse the repository at this point in the history
After the refactoring langchain-ai#6570, the DistanceStrategy class was moved to
another module and this introduced a bug into the SingleStoreDB vector
store, as the `DistanceStrategy.EUCLEDIAN_DISTANCE` started to convert
into the 'DistanceStrategy.EUCLEDIAN_DISTANCE' string, instead of just
'EUCLEDIAN_DISTANCE' (same for 'DOT_PRODUCT').

In this change, I check the type of the parameter and use `.name`
attribute to get the correct object's name.

---------

Co-authored-by: Volodymyr Tkachuk <[email protected]>
  • Loading branch information
volodymyr-memsql and volodymyr-memsql authored Sep 13, 2023
1 parent f9636b6 commit a43abf2
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libs/langchain/langchain/vectorstores/singlestoredb.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ def build_where_clause(
FROM {} {} ORDER BY __score {} LIMIT %s""".format(
self.content_field,
self.metadata_field,
self.distance_strategy,
self.distance_strategy.name
if isinstance(self.distance_strategy, DistanceStrategy)
else self.distance_strategy,
self.vector_field,
self.table_name,
where_clause,
Expand Down

0 comments on commit a43abf2

Please sign in to comment.