mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-02 11:39:18 +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 langchain_core.callbacks import CallbackManagerForRetrieverRun
|
||||
from langchain_core.documents import Document
|
||||
from langchain_core.embeddings import Embeddings
|
||||
from langchain_core.retrievers import BaseRetriever
|
||||
from langchain_core.utils.pydantic import get_fields
|
||||
|
||||
from langchain_community.vectorstores.utils import maximal_marginal_relevance
|
||||
|
||||
@@ -182,7 +183,7 @@ class DocArrayRetriever(BaseRetriever):
|
||||
ValueError: If the document doesn't contain the content field
|
||||
"""
|
||||
|
||||
fields = doc.keys() if isinstance(doc, dict) else doc.__fields__
|
||||
fields = doc.keys() if isinstance(doc, dict) else get_fields(doc)
|
||||
|
||||
if self.content_field not in fields:
|
||||
raise ValueError(
|
||||
|
Reference in New Issue
Block a user