Skip to content

Commit 6c8edb7

Browse files
committed
Work with both Pydantic 1 and 2
Refs replicate#112
1 parent 297125a commit 6c8edb7

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ readme = "README.md"
1010
license = { file = "LICENSE" }
1111
authors = [{ name = "Replicate, Inc." }]
1212
requires-python = ">=3.8"
13-
dependencies = ["packaging", "pydantic>1,<2", "requests>2"]
13+
dependencies = ["packaging", "pydantic>1", "requests>2"]
1414
optional-dependencies = { dev = [
1515
"black",
1616
"mypy",

replicate/base_model.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
from replicate.client import Client
55
from replicate.collection import Collection
66

7-
import pydantic
7+
try:
8+
from pydantic import v1 as pydantic
9+
except ImportError:
10+
import pydantic
811

912

1013
class BaseModel(pydantic.BaseModel):

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ idna==3.4
1212
# via requests
1313
packaging==23.0
1414
# via replicate (pyproject.toml)
15-
pydantic==1.10.7
15+
pydantic>=1.10.7
1616
# via replicate (pyproject.toml)
1717
requests==2.31.0
1818
# via replicate (pyproject.toml)

0 commit comments

Comments
 (0)