From a43abf24e4463104d07b11e1fb37c604fcc37a13 Mon Sep 17 00:00:00 2001 From: volodymyr-memsql <57520563+volodymyr-memsql@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:09:46 +0300 Subject: [PATCH] Fix SingleStoreDB (#10534) After the refactoring #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 --- libs/langchain/langchain/vectorstores/singlestoredb.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/langchain/langchain/vectorstores/singlestoredb.py b/libs/langchain/langchain/vectorstores/singlestoredb.py index 35a955807f873..657f8093cc849 100644 --- a/libs/langchain/langchain/vectorstores/singlestoredb.py +++ b/libs/langchain/langchain/vectorstores/singlestoredb.py @@ -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,