experimental[patch]: Use get_fields adapter (#25193)

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 15:10:11 -04:00 committed by GitHub
parent b9f65e5038
commit 86355640c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@ from typing import Any, Dict, List
from langchain.pydantic_v1 import BaseModel, root_validator
from langchain_core.embeddings import Embeddings
from langchain_core.utils.pydantic import get_fields
class OpenCLIPEmbeddings(BaseModel, Embeddings):
@ -21,8 +22,8 @@ class OpenCLIPEmbeddings(BaseModel, Embeddings):
import open_clip
# Fall back to class defaults if not provided
model_name = values.get("model_name", cls.__fields__["model_name"].default)
checkpoint = values.get("checkpoint", cls.__fields__["checkpoint"].default)
model_name = values.get("model_name", get_fields(cls)["model_name"].default)
checkpoint = values.get("checkpoint", get_fields(cls)["checkpoint"].default)
# Load model
model, _, preprocess = open_clip.create_model_and_transforms(