Summary
I was using the Langchain C* class and noticed that if you accidentally use a string for the setup_mode, you'll get a cryptic error that you may end up debugging for too long 🙃 . I'm guessing it sneaks into the CQL create statement somehow?
repro
import cassio
from typing import Any, List, Optional, Union, Tuple
from langchain_community.vectorstores import Cassandra
from langchain_community.utilities.cassandra import SetupMode
from langchain_openai import OpenAIEmbeddings
database_id = "..."
token = "..."
table_name = "test"
def build():
cassio.init(
database_id=database_id,
token=token,
)
embedding = OpenAIEmbeddings(api_key="...")
table = Cassandra(
embedding=embedding,
table_name=table_name,
keyspace="default_keyspace",
setup_mode="Sync" # Accidentally had this as a string instead of SetupMode
# setup_mode=SetupMode.SYNC, # the correct param
)
res = table.search("random query", search_type="similarity")
print(res)
build()
Run this twice, and you'll see:
cassandra.protocol.SyntaxException: <Error from server: code=2000 [Syntax error in CQL query] message="line 1:107 mismatched input 'None' expecting INTEGER (... TEXT, vector VECTOR<FLOAT,[None]...)">
Versions
langchain 0.1.19
langchain-community 0.0.38
langchain-core 0.1.52
cassio 0.1.7
Python 3.11.2
Summary
I was using the Langchain C* class and noticed that if you accidentally use a string for the
setup_mode, you'll get a cryptic error that you may end up debugging for too long 🙃 . I'm guessing it sneaks into the CQL create statement somehow?repro
Run this twice, and you'll see:
Versions
langchain 0.1.19
langchain-community 0.0.38
langchain-core 0.1.52
cassio 0.1.7
Python 3.11.2