Import of declarative_base when SQLAlchemy <1.4 (#883)

In
[pyproject.toml](https://github.com/hwchase17/langchain/blob/master/pyproject.toml),
the expectation is `SQLAlchemy = "^1"`. But, the way `declarative_base`
is imported in
[cache.py](https://github.com/hwchase17/langchain/blob/master/langchain/cache.py)
will only work with SQLAlchemy >=1.4. This PR makes sure Langchain can
be run in environments with SQLAlchemy <1.4
This commit is contained in:
Shahriar Tajbakhsh
2023-02-11 02:33:47 +00:00
committed by GitHub
parent 2e96704d59
commit b7747017d7
2 changed files with 11 additions and 2 deletions

View File

@@ -1,6 +1,10 @@
"""Test base LLM functionality."""
from sqlalchemy import Column, Integer, Sequence, String, create_engine
from sqlalchemy.orm import declarative_base
try:
from sqlalchemy.orm import declarative_base
except ImportError:
from sqlalchemy.ext.declarative import declarative_base
import langchain
from langchain.cache import InMemoryCache, SQLAlchemyCache