issues while running quickstart for pgvector #72

Closed
opened 2026-02-16 05:16:26 -05:00 by yindo · 4 comments
Owner

Originally created by @eyurtsev on GitHub (Apr 7, 2025).

  1. initialization

the line that initializes the table uses the wrong variable (engine instead of pg_engine) and uses a public method, but the method is actually private

await pg_engine._ainit_vectorstore_table(
    table_name=TABLE_NAME,
    vector_size=VECTOR_SIZE,
)
  1. initializing twice raises an exception (should we have create if not exists semantics as well?) Users may want to have the code live in their app lifespan for simplicity (instead of doing some logic on server deployment)

  2. cohere embeddings fails due to cohere model not being specified.

  3. using pgvectorstore create fails w/ an exception (
    AttributeError: 'AsyncEngine' object has no attribute '_run_as_async')

store = await PGVectorStore.create(
    engine=engine,
    table_name=TABLE_NAME,
    # schema_name=SCHEMA_NAME,
    embedding_service=embedding,
)

got stuck at this stage

Originally created by @eyurtsev on GitHub (Apr 7, 2025). 1. initialization the line that initializes the table uses the wrong variable (engine instead of pg_engine) and uses a public method, but the method is actually private ```python await pg_engine._ainit_vectorstore_table( table_name=TABLE_NAME, vector_size=VECTOR_SIZE, ) ``` 2. initializing twice raises an exception (should we have create if not exists semantics as well?) Users may want to have the code live in their app lifespan for simplicity (instead of doing some logic on server deployment) 3. cohere embeddings fails due to cohere model not being specified. 4. using pgvectorstore create fails w/ an exception ( AttributeError: 'AsyncEngine' object has no attribute '_run_as_async') ```python store = await PGVectorStore.create( engine=engine, table_name=TABLE_NAME, # schema_name=SCHEMA_NAME, embedding_service=embedding, ) ``` --- got stuck at this stage
yindo closed this issue 2026-02-16 05:16:26 -05:00
Author
Owner

@averikitsch commented on GitHub (Apr 7, 2025):

  1. Use the public method, see here https://github.com/langchain-ai/langchain-postgres/blob/22f4f474acf24bc909696c7346b9a561b384a882/langchain_postgres/v2/engine.py#L251. We can use the double underscore to remove access to the semi private method. The semi private should only be used by Async experts.
  2. This is a bad practice to keep this in application code. Users can wrap the error if they want to ignore the best practice. Users can also use overwrite in the init call. We want this to be enterprise quality by enforcing this.
  3. We will fix this.
  4. What engine did you pass in? I’ll need to reproduce.
@averikitsch commented on GitHub (Apr 7, 2025): 1. Use the public method, see here https://github.com/langchain-ai/langchain-postgres/blob/22f4f474acf24bc909696c7346b9a561b384a882/langchain_postgres/v2/engine.py#L251. We can use the double underscore to remove access to the semi private method. The semi private should only be used by Async experts. 2. This is a bad practice to keep this in application code. Users can wrap the error if they want to ignore the best practice. Users can also use overwrite in the init call. We want this to be enterprise quality by enforcing this. 3. We will fix this. 4. What engine did you pass in? I’ll need to reproduce.
Author
Owner

@eyurtsev commented on GitHub (Apr 7, 2025):

  1. ainit_vectorstore_table

yep confirmed was an issue just b/c of engine vs. pg_engine

  1. This is a bad practice to keep this in application code. Users can wrap the error if they want to ignore the best practice. Users can also use overwrite in the init call. We want this to be enterprise quality by enforcing this.

OK skipping

  1. What engine did you pass in? I’ll need to reproduce.

not sure can try again, i running through the cells one by one

@eyurtsev commented on GitHub (Apr 7, 2025): > 1. ainit_vectorstore_table yep confirmed was an issue just b/c of engine vs. pg_engine > 2. This is a bad practice to keep this in application code. Users can wrap the error if they want to ignore the best practice. Users can also use overwrite in the init call. We want this to be enterprise quality by enforcing this. OK skipping 4. What engine did you pass in? I’ll need to reproduce. not sure can try again, i running through the cells one by one
Author
Owner

@dishaprakash commented on GitHub (Apr 7, 2025):

  1. & 4. Are being caused by the use of variable engine instead of pg_engine.

  2. The PGVector example notebook mentioned this way of initializing the cohere embedding so I left that in. I'll update it to mention the model name.

Sorry about the oversight. I'll make the changes

@dishaprakash commented on GitHub (Apr 7, 2025): 1. & 4. Are being caused by the use of variable engine instead of pg_engine. 3. The PGVector example notebook mentioned this way of initializing the cohere embedding so I left that in. I'll update it to mention the model name. Sorry about the oversight. I'll make the changes
Author
Owner

@dishaprakash commented on GitHub (Apr 7, 2025):

The above changes are being made in https://github.com/langchain-ai/langchain-postgres/pull/183

@dishaprakash commented on GitHub (Apr 7, 2025): The above changes are being made in https://github.com/langchain-ai/langchain-postgres/pull/183
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#72