DSPy: The framework for programming—not prompting—language models
Python
fix(dspy): updating syntax for Snowflake cos similarity method which will be deprecated at the end of the month
alejandrob0b18a7d7d19
diff --git a/dspy/retrieve/snowflake_rm.py b/dspy/retrieve/snowflake_rm.pyindex d9067bffa..47ee559e1 100644--- a/dspy/retrieve/snowflake_rm.py+++ b/dspy/retrieve/snowflake_rm.py@@ -6,7 +6,7 @@ from dsp.utils import dotdicttry:from snowflake.snowpark import Sessionfrom snowflake.snowpark import functions as snow_fn- from snowflake.snowpark.functions import lit+ from snowflake.snowpark.functions import lit, function, colfrom snowflake.snowpark.types import VectorTypeexcept ImportError:@@ -84,11 +84,13 @@ class SnowflakeRM(dspy.Retrieve):doc_table_key = self.embeddings_text_fielddoc_embeddings = self.client.table(self.snowflake_table_name)+ cosine_similarity = function("vector_cosine_similarity")+top_k = (doc_embeddings.select(doc_table_value,doc_table_key,- vector_cosine_similarity(+ cosine_similarity(doc_embeddings.col(doc_table_value),lit(query_embeddings).cast(VectorType(float, len(query_embeddings))),).as_("dist"),