mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-28 06:48:50 +00:00
experimental[major]: upgrade pydantic (#26228)
This commit is contained in:
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user