Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cryptic error message when setup_mode of cassandra table is set to incorrect type #162

Open
jordanrfrazier opened this issue Jun 3, 2024 · 0 comments

Comments

@jordanrfrazier
Copy link

jordanrfrazier commented Jun 3, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant