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

Auth issues present as "ValueError: Id column, langchain_id, does not exist." #273

Open
glasnt opened this issue Nov 11, 2024 · 1 comment
Assignees
Labels
api: alloydb Issues related to the googleapis/langchain-google-alloydb-pg-python API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@glasnt
Copy link

glasnt commented Nov 11, 2024

Environment details

  • OS type and version: Colab Enterprise
  • Python version: py-310 (from reasoning-engine image)
  • pip version: pip --version Unsure
  • langchain-google-alloydb-pg version: pip show langchain-google-alloydb-pg
    • both langchain-google-alloydb-pg-0.8.0 and langchain-google-alloydb-pg-0.7.0

Steps to reproduce

  1. Try running Deploying a RAG Application with AlloyDB to LangChain on Vertex AI
  2. Use suggested IAM-based authentication in similarity_search
  3. Get ValueError

Code example

Directly from notebook

def similarity_search(query: str) -> list[Document]:

    engine = AlloyDBEngine.from_instance(
        PROJECT_ID,
        REGION,
        CLUSTER,
        INSTANCE,
        DATABASE,
        # Uncomment to use built-in authentication instead of IAM authentication
        # user="postgres",
        # password=PASSWORD,
    )
    )

    vector_store = AlloyDBVectorStore.create_sync(
        engine,
        table_name=TABLE_NAME,
        embedding_service=VertexAIEmbeddings(
            model_name="textembedding-gecko@latest", project=PROJECT_ID
        ),
    )
    retriever = vector_store.as_retriever()
    return retriever.invoke(query)


vertexai.init(project=PROJECT_ID, location="us-central1", staging_bucket=STAGING_BUCKET)

remote_app = reasoning_engines.ReasoningEngine.create(
    reasoning_engines.LangchainAgent(
        model="gemini-pro",
        tools=[similarity_search],
        model_kwargs={
            "temperature": 0.1,
        },
    ),
    requirements=[
        "google-cloud-aiplatform[reasoningengine,langchain]",
        "langchain-google-alloydb-pg",
        "langchain-google-vertexai",
    ],
    display_name="PrebuiltAgent",
)

response = remote_app.query(input="Find movies about engineers")
print(response["output"])

Stack trace

...
File "/usr/local/lib/python3.10/concurrent/futures/_base.py", line 403, in __get_result
raise self._exception
File "/usr/local/lib/python3.10/site-packages/langchain_google_alloydb_pg/async_vectorstore.py", line 168, in create
raise ValueError(f"Id column, {id_column}, does not exist.")
ValueError: Id column, langchain_id, does not exist.

Debugging

Example schema from movies.csv uses id, wasn't sure if I should have been renaming this (it wasn't it).

But after finding the code in this package, I saw that it could be a case of the columns var in async_vectorstore.py's create() (via AlloyDBVectorStore.create_sync) is empty, hence the error.

If I changed the authentication from IAM built-in to the username password, the functionality worked.

Possible fix: before the # Check columns maybe check if there are any columns, and return an authentication error. This would at least present the actual issue rather than a schema issue.

b/356000377

@product-auto-label product-auto-label bot added the api: alloydb Issues related to the googleapis/langchain-google-alloydb-pg-python API. label Nov 11, 2024
@averikitsch averikitsch added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p0 Highest priority. Critical issue. P0 implies highest priority. labels Nov 12, 2024
@averikitsch
Copy link
Collaborator

Thank you so much @glasnt for the detailed bug!

@averikitsch averikitsch added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. and removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p0 Highest priority. Critical issue. P0 implies highest priority. labels Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: alloydb Issues related to the googleapis/langchain-google-alloydb-pg-python API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

3 participants