mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-08 06:23:20 +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:
@@ -1,6 +1,7 @@
|
||||
"""Utils for LLM Tests."""
|
||||
|
||||
from langchain_core.language_models.llms import BaseLLM
|
||||
from langchain_core.utils.pydantic import get_fields
|
||||
|
||||
|
||||
def assert_llm_equality(llm: BaseLLM, loaded_llm: BaseLLM) -> None:
|
||||
@@ -9,7 +10,7 @@ def assert_llm_equality(llm: BaseLLM, loaded_llm: BaseLLM) -> None:
|
||||
assert type(llm) is type(loaded_llm)
|
||||
# Client field can be session based, so hash is different despite
|
||||
# all other values being the same, so just assess all other fields
|
||||
for field in llm.__fields__.keys():
|
||||
for field in get_fields(llm).keys():
|
||||
if field != "client" and field != "pipeline":
|
||||
val = getattr(llm, field)
|
||||
new_val = getattr(loaded_llm, field)
|
||||
|
Reference in New Issue
Block a user