Skip to content

Commit

Permalink
Merge pull request #109 from kdcokenny/main
Browse files Browse the repository at this point in the history
feat: Allow Pydantic V2+
  • Loading branch information
jamescalam authored Jan 18, 2024
2 parents 2fa3eb3 + bc195ad commit c607aed
Show file tree
Hide file tree
Showing 10 changed files with 147 additions and 52 deletions.
179 changes: 137 additions & 42 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ packages = [{include = "semantic_router"}]

[tool.poetry.dependencies]
python = "^3.9"
pydantic = "^1.8.2"
pydantic = "^2.5.3"
openai = "^1.3.9"
cohere = "^4.32"
numpy = "^1.25.2"
Expand Down
2 changes: 1 addition & 1 deletion semantic_router/encoders/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from pydantic import BaseModel, Field
from pydantic.v1 import BaseModel, Field


class BaseEncoder(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion semantic_router/encoders/fastembed.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Any, List, Optional

import numpy as np
from pydantic import PrivateAttr
from pydantic.v1 import PrivateAttr

from semantic_router.encoders import BaseEncoder

Expand Down
2 changes: 1 addition & 1 deletion semantic_router/encoders/huggingface.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Any, List, Optional

from pydantic import PrivateAttr
from pydantic.v1 import PrivateAttr

from semantic_router.encoders import BaseEncoder

Expand Down
2 changes: 1 addition & 1 deletion semantic_router/llms/base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from typing import Any, List, Optional

from pydantic import BaseModel
from pydantic.v1 import BaseModel

from semantic_router.schema import Message
from semantic_router.utils.logger import logger
Expand Down
2 changes: 1 addition & 1 deletion semantic_router/route.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import re
from typing import Any, Callable, Dict, List, Optional, Union

from pydantic import BaseModel
from pydantic.v1 import BaseModel

from semantic_router.llms import BaseLLM
from semantic_router.schema import Message, RouteChoice
Expand Down
4 changes: 2 additions & 2 deletions semantic_router/schema.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from enum import Enum
from typing import Dict, List, Literal, Optional

from pydantic import BaseModel
from pydantic.dataclasses import dataclass
from pydantic.v1 import BaseModel
from pydantic.v1.dataclasses import dataclass

from semantic_router.encoders import (
BaseEncoder,
Expand Down
2 changes: 1 addition & 1 deletion semantic_router/utils/function_call.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import inspect
from typing import Any, Callable, Dict, List, Union

from pydantic import BaseModel
from pydantic.v1 import BaseModel

from semantic_router.llms import BaseLLM
from semantic_router.schema import Message, RouteChoice
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from pydantic import ValidationError
from pydantic.v1 import ValidationError

from semantic_router.schema import (
CohereEncoder,
Expand Down

0 comments on commit c607aed

Please sign in to comment.