Skip to content

Commit

Permalink
feat: [ref #58] support Pydantic v2 (#60)
Browse files Browse the repository at this point in the history
* support for either pydantic 1 or 2 using pydantic.v1 compat
  • Loading branch information
danielchalef authored Aug 22, 2023
1 parent 811c558 commit 7987d8a
Show file tree
Hide file tree
Showing 8 changed files with 348 additions and 129 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

env:
POETRY_VERSION: "1.4.2"
POETRY_VERSION: "1.6.1"

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- 'pyproject.toml'

env:
POETRY_VERSION: "1.4.2"
POETRY_VERSION: "1.6.1"

jobs:
if_release:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
pull_request:

env:
POETRY_VERSION: "1.4.2"
POETRY_VERSION: "1.6.1"

jobs:
build:
Expand Down
434 changes: 317 additions & 117 deletions poetry.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[tool.poetry]
name = "zep-python"
version = "1.0.2"
version = "1.1.0a0"
description = "Zep stores, manages, enriches, indexes, and searches long-term memory for conversational AI applications. This is the Python client for the Zep service."
authors = ["Daniel Chalef <[email protected]>"]
readme = "README.md"

[tool.poetry.dependencies]
python = ">=3.8.1,<4"
httpx = "^0.24.0"
pydantic = "^1.10.7"
pydantic = ">=1.10.7"

[tool.poetry.group.test.dependencies]
pytest = "^7.3.1"
Expand Down
11 changes: 9 additions & 2 deletions zep_python/document/collections.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import warnings
from typing import Any, Dict, List, Optional, Tuple
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple

import httpx
from pydantic import PrivateAttr

if TYPE_CHECKING:
from pydantic import PrivateAttr
else:
try:
from pydantic.v1 import PrivateAttr
except ImportError:
from pydantic import PrivateAttr

from zep_python.exceptions import handle_response
from zep_python.utils import filter_dict
Expand Down
10 changes: 8 additions & 2 deletions zep_python/document/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from __future__ import annotations

from datetime import datetime
from typing import Any, Dict, List, Optional
from typing import TYPE_CHECKING, Any, Dict, List, Optional

from pydantic import BaseModel, Extra, Field
if TYPE_CHECKING:
from pydantic import BaseModel, Extra, Field
else:
try:
from pydantic.v1 import BaseModel, Extra, Field
except ImportError:
from pydantic import BaseModel, Extra, Field


class Document(BaseModel):
Expand Down
12 changes: 9 additions & 3 deletions zep_python/memory/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from __future__ import annotations

from typing import Any, Dict, List, Optional

from pydantic import BaseModel, Field
from typing import TYPE_CHECKING, Any, Dict, List, Optional

if TYPE_CHECKING:
from pydantic import BaseModel, Field
else:
try:
from pydantic.v1 import BaseModel, Field
except ImportError:
from pydantic import BaseModel, Field


class Session(BaseModel):
Expand Down

0 comments on commit 7987d8a

Please sign in to comment.