mirror of
https://github.com/hwchase17/langchain
synced 2024-11-10 01:10:59 +00:00
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:
parent
b9f65e5038
commit
86355640c3
@ -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(
|
||||
|
Loading…
Reference in New Issue
Block a user