mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-05 21:12:48 +00:00
community[patch]: Use get_fields adapter for pydantic (#25191)
Change all usages of __fields__ with get_fields adapter merged into langchain_core. Code mod generated using the following grit pattern: ``` engine marzano(0.1) language python `$X.__fields__` => `get_fields($X)` where { add_import(source="langchain_core.utils.pydantic", name="get_fields") } ```
This commit is contained in:
@@ -6,6 +6,7 @@ from typing import Any, Union
|
||||
|
||||
import yaml
|
||||
from langchain_core.language_models.llms import BaseLLM
|
||||
from langchain_core.utils.pydantic import get_fields
|
||||
|
||||
from langchain_community.llms import get_type_to_cls_dict
|
||||
|
||||
@@ -26,7 +27,7 @@ def load_llm_from_config(config: dict, **kwargs: Any) -> BaseLLM:
|
||||
llm_cls = type_to_cls_dict[config_type]()
|
||||
|
||||
load_kwargs = {}
|
||||
if _ALLOW_DANGEROUS_DESERIALIZATION_ARG in llm_cls.__fields__:
|
||||
if _ALLOW_DANGEROUS_DESERIALIZATION_ARG in get_fields(llm_cls):
|
||||
load_kwargs[_ALLOW_DANGEROUS_DESERIALIZATION_ARG] = kwargs.get(
|
||||
_ALLOW_DANGEROUS_DESERIALIZATION_ARG, False
|
||||
)
|
||||
|
Reference in New Issue
Block a user