'PGVector' has no attribute 'acreate' #62

Open
opened 2026-02-16 05:16:23 -05:00 by yindo · 1 comment
Owner

Originally created by @bfigueir on GitHub (Jan 21, 2025).

Hi all,

im running a simple FastAPI endpoint with the code:

from langchain_postgres import PGVector
from langchain_postgres.vectorstores import PGVector

connection = "postgresql+psycopg://*****:******@localhost:5432/db"

@router.get(
    "/test_pgvector_2",
)
async def test_pgvector_2():
    vector_store = await PGVector.acreate(
        embeddings=get_embeddings(),
        collection_name="vector_store",
        connection=connection,
        use_jsonb=True,
    )

    retriever = vector_store.as_retriever()
    docs = retriever.invoke("prompt engineering")
    return docs

Based on the documentation that states "Initialize the PGVector store. For an async version, use PGVector.acreate() instead." it should work, but I'm getting the error AttributeError: type object 'PGVector' has no attribute 'acreate'

This is what I have on the pyproject.toml for the dependencies:

[tool.poetry.dependencies]
python = "^3.12.3"
uvicorn = "^0.34.0"
fastapi = "^0.115.6"
dapr = "^1.14.0"
python-dotenv = "^1.0.1"
structlog = "^24.4.0"
pydantic = "^2.0.0"
pydantic-settings = "^2.7.1"
sqlalchemy = "^2.0.36"
psycopg2-binary = "^2.9.10"
alembic = "^1.14.0"
langchain = "^0.3.7"
langchain-openai = "^0.2.8"
langchain-core = "^0.3.19"
onnxruntime = "1.19.2"
langchain-chroma = "^0.1.4"
bs4 = "^0.0.2"
langchain-community = "^0.3.7"
langgraph = "^0.2.50"
langchain-groq = "^0.2.1"
numexpr = "^2.10.1"
pyowm = "^3.3.0"
python-multipart = "^0.0.17"
setuptools = "^75.8.0"
cachetools = "^5.5.0"
async-lru = "^2.0.4"
langchain-postgres = "^0.0.12"

Any thoughts? thanks

Originally created by @bfigueir on GitHub (Jan 21, 2025). Hi all, im running a simple FastAPI endpoint with the code: ```python from langchain_postgres import PGVector from langchain_postgres.vectorstores import PGVector connection = "postgresql+psycopg://*****:******@localhost:5432/db" @router.get( "/test_pgvector_2", ) async def test_pgvector_2(): vector_store = await PGVector.acreate( embeddings=get_embeddings(), collection_name="vector_store", connection=connection, use_jsonb=True, ) retriever = vector_store.as_retriever() docs = retriever.invoke("prompt engineering") return docs ``` Based on the [documentation ](https://python.langchain.com/api_reference/postgres/vectorstores/langchain_postgres.vectorstores.PGVector.html#langchain_postgres.vectorstores.PGVector.as_retriever) that states "Initialize the PGVector store. For an async version, use PGVector.acreate() instead." it should work, but I'm getting the error `AttributeError: type object 'PGVector' has no attribute 'acreate'` This is what I have on the `pyproject.toml` for the dependencies: ```yaml [tool.poetry.dependencies] python = "^3.12.3" uvicorn = "^0.34.0" fastapi = "^0.115.6" dapr = "^1.14.0" python-dotenv = "^1.0.1" structlog = "^24.4.0" pydantic = "^2.0.0" pydantic-settings = "^2.7.1" sqlalchemy = "^2.0.36" psycopg2-binary = "^2.9.10" alembic = "^1.14.0" langchain = "^0.3.7" langchain-openai = "^0.2.8" langchain-core = "^0.3.19" onnxruntime = "1.19.2" langchain-chroma = "^0.1.4" bs4 = "^0.0.2" langchain-community = "^0.3.7" langgraph = "^0.2.50" langchain-groq = "^0.2.1" numexpr = "^2.10.1" pyowm = "^3.3.0" python-multipart = "^0.0.17" setuptools = "^75.8.0" cachetools = "^5.5.0" async-lru = "^2.0.4" langchain-postgres = "^0.0.12" ``` Any thoughts? thanks
Author
Owner

@stoyan-atanasov-beye commented on GitHub (Nov 26, 2025):

I get the same.

@stoyan-atanasov-beye commented on GitHub (Nov 26, 2025): I get the same.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langchain-postgres#62