-
Notifications
You must be signed in to change notification settings - Fork 471
feat: refactor validators and fields to support pydantic v2 #967
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,7 +22,7 @@ | |
|
||
from langchain.callbacks.manager import CallbackManagerForLLMRun | ||
from langchain_core.language_models.llms import BaseLLM | ||
from pydantic.v1 import Field, root_validator | ||
from pydantic import Field, model_validator | ||
|
||
from nemoguardrails.llm.providers.trtllm.client import TritonClient | ||
|
||
|
@@ -61,12 +61,12 @@ class TRTLLM(BaseLLM): | |
client: Any | ||
streaming: Optional[bool] = True | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be @classmethod
def validate_environment(cls, self) -> "TRTLLM":
"""Validate that python package exists in environment."""
try:
# instantiate and attach the client
self.client = TritonClient(self.server_url)
except ImportError as err:
raise ImportError(
"Could not import triton client python package. "
"Please install it with `pip install tritonclient[all]`."
) from err
return self |
||
@root_validator(allow_reuse=True) | ||
@model_validator(mode="after") | ||
@classmethod | ||
def validate_environment(cls, values: Dict[str, Any]) -> Dict[str, Any]: | ||
def validate_environment(cls, values: "TRTLLM") -> "TRTLLM": | ||
"""Validate that python package exists in environment.""" | ||
try: | ||
values["client"] = TritonClient(values["server_url"]) | ||
values.client = TritonClient(values.server_url) | ||
|
||
except ImportError as err: | ||
raise ImportError( | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ langchain-community = ">=0.0.16,<0.4.0" | |
lark = ">=1.1.7" | ||
nest-asyncio = ">=1.5.6," | ||
prompt-toolkit = ">=3.0" | ||
pydantic = ">=1.10" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should relax it a bit, probably And I still need to see the reasons we were still supporting Pydantic 1.0, I'll get back to this later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed the extra log.text and hidden file, changed the version to >= 2.0, and signed the commit, thanks... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and <3.0 |
||
pydantic = ">=2.0" | ||
pyyaml = ">=6.0" | ||
rich = ">=13.5.2" | ||
simpleeval = ">=0.9.13," | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be