Skip to content

The agent engineering platform.

Make project compatible with SQLAlchemy 1.3.* (#3862)

Hristo Stoychev109927cdb29b
diff --git a/langchain/vectorstores/analyticdb.py b/langchain/vectorstores/analyticdb.py
index 6ed8e5b0b5..6ec5fbade1 100644
--- a/langchain/vectorstores/analyticdb.py
+++ b/langchain/vectorstores/analyticdb.py
@@ -8,7 +8,7 @@ from typing import Any, Dict, Iterable, List, Optional, Tuple
import sqlalchemy
from sqlalchemy import REAL, Index
from sqlalchemy.dialects.postgresql import ARRAY, JSON, UUID
-from sqlalchemy.orm import Mapped, Session, declarative_base, relationship
+from sqlalchemy.orm import Session, declarative_base, relationship
from sqlalchemy.sql.expression import func
from langchain.docstore.document import Document
@@ -70,7 +70,7 @@ class CollectionStore(BaseModel):
class EmbeddingStore(BaseModel):
__tablename__ = "langchain_pg_embedding"
- collection_id: Mapped[UUID] = sqlalchemy.Column(
+ collection_id = sqlalchemy.Column(
UUID(as_uuid=True),
sqlalchemy.ForeignKey(
f"{CollectionStore.__tablename__}.uuid",
diff --git a/langchain/vectorstores/pgvector.py b/langchain/vectorstores/pgvector.py
index d0101771ac..a128241d51 100644
--- a/langchain/vectorstores/pgvector.py
+++ b/langchain/vectorstores/pgvector.py
@@ -9,7 +9,7 @@ from typing import Any, Dict, Iterable, List, Optional, Tuple, Type
import sqlalchemy
from pgvector.sqlalchemy import Vector
from sqlalchemy.dialects.postgresql import JSON, UUID
-from sqlalchemy.orm import Mapped, Session, declarative_base, relationship
+from sqlalchemy.orm import Session, declarative_base, relationship
from langchain.docstore.document import Document
from langchain.embeddings.base import Embeddings
@@ -70,7 +70,7 @@ class CollectionStore(BaseModel):
class EmbeddingStore(BaseModel):
__tablename__ = "langchain_pg_embedding"
- collection_id: Mapped[UUID] = sqlalchemy.Column(
+ collection_id = sqlalchemy.Column(
UUID(as_uuid=True),
sqlalchemy.ForeignKey(
f"{CollectionStore.__tablename__}.uuid",
diff --git a/pyproject.toml b/pyproject.toml
index 5606e649d7..29e7be5af4 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -13,7 +13,7 @@ langchain-server = "langchain.server:main"
[tool.poetry.dependencies]
python = ">=3.8.1,<4.0"
pydantic = "^1"
-SQLAlchemy = ">1.4,<3"
+SQLAlchemy = ">=1.3,<3"
requests = "^2"
PyYAML = ">=5.4.1"
numpy = "^1"