Skip to content

Allow for use of Pydantic v1 as well as v2. #147

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion llm/default_plugins/openai_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import click
import datetime
import openai
from pydantic import field_validator, Field

try:
from pydantic import field_validator, Field
except ImportError:
from pydantic.fields import Field
from pydantic.class_validators import validator as field_validator # type: ignore [no-redef]
import requests
from typing import List, Optional, Union
import json
Expand Down
7 changes: 5 additions & 2 deletions llm/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from abc import ABC, abstractmethod
import os
import json
from pydantic import ConfigDict, BaseModel
from pydantic import BaseModel
from ulid import ULID

CONVERSATION_NAME_LENGTH = 32
Expand Down Expand Up @@ -200,7 +200,10 @@ def __repr__(self):


class Options(BaseModel):
model_config = ConfigDict(extra="forbid")
# Note: using pydantic v1 style Configs,
# these are also compatible with pydantic v2
class Config:
extra = "forbid"


_Options = Options
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_long_description():
"openai",
"click-default-group-wheel",
"sqlite-utils",
"pydantic>=2.0.0",
"pydantic>=1.10.2",
"PyYAML",
"pluggy",
"python-ulid",
Expand Down