Skip to content

pgvector.py has created a dependency on sqlalchemy v2, breaking apps using sqlalchemy v1 #19681

@gibson3659

Description

@gibson3659

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).

Example Code

from langchain.retrievers.multi_query import MultiQueryRetriever

Error Message and Stack Trace (if applicable)

Traceback (most recent call last):
File "", line 1, in
File "/home/ubuntu/miniconda3/envs/nettalk/lib/python3.12/site-packages/langchain/retrievers/init.py", line 33, in
from langchain.retrievers.self_query.base import SelfQueryRetriever
File "/home/ubuntu/miniconda3/envs/nettalk/lib/python3.12/site-packages/langchain/retrievers/self_query/base.py", line 5, in
from langchain_community.vectorstores import (
File "/home/ubuntu/miniconda3/envs/nettalk/lib/python3.12/site-packages/langchain_community/vectorstores/init.py", line 115, in getattr
module = importlib.import_module(_module_lookup[name])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/miniconda3/envs/nettalk/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ubuntu/miniconda3/envs/nettalk/lib/python3.12/site-packages/langchain_community/vectorstores/pgvector.py", line 23, in
from sqlalchemy import SQLColumnExpression, delete, func
ImportError: cannot import name 'SQLColumnExpression' from 'sqlalchemy' (/home/ubuntu/miniconda3/envs/nettalk/lib/python3.12/site-packages/sqlalchemy/init.py)

Description

My app uses sqlalchemy v1 due to my db dialect not supporting v2. The above change breaks MultiQueryRetriever in 0.1.13.

System Info

System Information

OS: Linux
OS Version: #17~22.04.1-Ubuntu SMP Fri Nov 17 21:07:13 UTC 2023
Python Version: 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:50:58) [GCC 12.3.0]

Package Information

langchain_core: 0.1.33
langchain: 0.1.13
langchain_community: 0.0.29
langsmith: 0.1.31
langchain_experimental: 0.0.55
langchain_openai: 0.1.1
langchain_text_splitters: 0.0.1
langgraph: 0.0.25

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

langserve

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions