googleapis / googleapis/langchain-google-alloydb-pg-python

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

Open
#273 1 comment 2 reactions 0 assignees View on GitHub
api: alloydb priority: p1 type: feature request
Dominant language
Python
Stars
39
Forks
25
Avg merge
5d 5h
Merged PRs (30d)
6

Description

#### 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](https://github.com/GoogleCloudPlatform/generative-ai/blob/main/gemini/reasoning-engine/tutorial_alloydb_rag_agent.ipynb)
2. Use suggested IAM-based authentication in `similarity_search`
3. Get ValueError

#### Code example

Directly from notebook

```python
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.