experimental[major]: upgrade pydantic (#26228)

This commit is contained in:
ccurme
2024-09-09 14:27:24 -04:00
committed by GitHub
parent 109ba548bd
commit 6c8d626d70
45 changed files with 183 additions and 170 deletions

View File

@@ -7,8 +7,7 @@ from typing import TYPE_CHECKING, Any, List, Optional, cast
from langchain_community.llms.huggingface_pipeline import HuggingFacePipeline
from langchain_community.llms.utils import enforce_stop_tokens
from langchain_core.callbacks.manager import CallbackManagerForLLMRun
from langchain_experimental.pydantic_v1 import Field, root_validator
from pydantic import Field, model_validator
if TYPE_CHECKING:
import rellm
@@ -40,10 +39,9 @@ class RELLM(HuggingFacePipeline):
default=200, description="Maximum number of new tokens to generate."
)
# TODO: move away from `root_validator` since it is deprecated in pydantic v2
# and causes mypy type-checking failures (hence the `type: ignore`)
@root_validator # type: ignore[call-overload]
def check_rellm_installation(cls, values: dict) -> dict:
@model_validator(mode="before")
@classmethod
def check_rellm_installation(cls, values: dict) -> Any:
import_rellm()
return values