MyScale hot fix on type check (#10180)

Previous PR #9353 has incomplete type checks and deprecation warnings.
This PR will fix those type check and add deprecation warning to myscale
vectorstore
This commit is contained in:
刘 方瑞 2023-09-04 23:40:58 +08:00 committed by GitHub
parent cb928ed3d5
commit de9e545542
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -147,7 +147,12 @@ class MyScale(VectorStore):
) )
for k in ["id", "vector", "text", "metadata"]: for k in ["id", "vector", "text", "metadata"]:
assert k in self.config.column_map assert k in self.config.column_map
assert self.config.metric in ["ip", "cosine", "l2"] assert self.config.metric.upper() in ["IP", "COSINE", "L2"]
if self.config.metric in ["ip", "cosine", "l2"]:
logger.warning(
"Lower case metric types will be deprecated "
"the future. Please use one of ('IP', 'Cosine', 'L2')"
)
# initialize the schema # initialize the schema
dim = len(embedding.embed_query("try this out")) dim = len(embedding.embed_query("try this out"))
@ -174,7 +179,9 @@ class MyScale(VectorStore):
self.BS = "\\" self.BS = "\\"
self.must_escape = ("\\", "'") self.must_escape = ("\\", "'")
self._embeddings = embedding self._embeddings = embedding
self.dist_order = "ASC" if self.config.metric in ["cosine", "l2"] else "DESC" self.dist_order = (
"ASC" if self.config.metric.upper() in ["COSINE", "L2"] else "DESC"
)
# Create a connection to myscale # Create a connection to myscale
self.client = get_client( self.client = get_client(