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:
Eugene Yurtsev
2024-08-08 14:43:09 -04:00
committed by GitHub
parent 663638d6a8
commit 98779797fe
24 changed files with 51 additions and 28 deletions

View File

@@ -49,6 +49,7 @@ from langchain_core.runnables import Runnable, RunnableMap, RunnablePassthrough
from langchain_core.tools import BaseTool
from langchain_core.utils import convert_to_secret_str, get_from_dict_or_env
from langchain_core.utils.function_calling import convert_to_openai_tool
from langchain_core.utils.pydantic import get_fields
logger = logging.getLogger(__name__)
@@ -399,7 +400,7 @@ class MiniMaxChat(BaseChatModel):
default_values = {
name: field.default
for name, field in cls.__fields__.items()
for name, field in get_fields(cls).items()
if field.default is not None
}
default_values.update(values)