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

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

Open
5 tasks done
gibson3659 opened this issue Mar 27, 2024 · 4 comments · May be fixed by #22546
Open
5 tasks done

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

gibson3659 opened this issue Mar 27, 2024 · 4 comments · May be fixed by #22546
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: postgres Related to postgres integrations Ɑ: retriever Related to retriever module

Comments

@gibson3659
Copy link

gibson3659 commented Mar 27, 2024

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

@dosubot dosubot bot added Ɑ: retriever Related to retriever module 🔌: postgres Related to postgres integrations 🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature labels Mar 27, 2024
@shelpuk
Copy link

shelpuk commented Mar 30, 2024

Please suggest a workaround or a proper langchain downgrade version. This is really critical.

@gibson3659
Copy link
Author

Please suggest a workaround or a proper langchain downgrade version. This is really critical.

The following works:
langchain - 0.1.12
langchain-community - 0.0.28

gibson3659 referenced this issue Apr 18, 2024
This PR makes the following updates in the pgvector database:

1. Use JSONB field for metadata instead of JSON
2. Update operator syntax to include required `$` prefix before the
operators (otherwise there will be name collisions with fields)
3. The change is non-breaking, old functionality is still the default,
but it will emit a deprecation warning
4. Previous functionality has bugs associated with comparisons due to
casting to text (so lexical ordering is used incorrectly for numeric
fields)
5. Adds an a GIN index on the JSONB field for more efficient querying
@gibson3659
Copy link
Author

gibson3659 commented Apr 18, 2024

Any update? The commit that added the dependency is 6cdca43.

@marcsalesgrid
Copy link

Please suggest a workaround or a proper langchain downgrade version. This is really critical.

The following works: langchain - 0.1.12 langchain-community - 0.0.28

This still is not resolved in langchain 0.1.20. I downgraded as described above, but that didn't resolve the issue either:
langchain==0.1.12
langchain-community==0.0.28
langchain-core==0.1.52
langchain-text-splitters==0.0.1
langsmith==0.1.57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🤖:bug Related to a bug, vulnerability, unexpected error with an existing feature 🔌: postgres Related to postgres integrations Ɑ: retriever Related to retriever module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants