From 9ce07980b79b32dccbb025f11fa75a8678c65cac Mon Sep 17 00:00:00 2001 From: ccurme Date: Mon, 24 Feb 2025 11:11:25 -0500 Subject: [PATCH] core[patch]: pydantic 2.11 compat (#29963) Resolves https://github.com/langchain-ai/langchain/issues/29951 Was able to reproduce the issue with Anthropic installing from pydantic `main` and correct it with the fix recommended in the issue. Thanks very much @Viicos for finding the bug and the detailed writeup! --- libs/core/langchain_core/language_models/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/core/langchain_core/language_models/base.py b/libs/core/langchain_core/language_models/base.py index 12445f2560f..ae2ab439e80 100644 --- a/libs/core/langchain_core/language_models/base.py +++ b/libs/core/langchain_core/language_models/base.py @@ -18,6 +18,8 @@ from pydantic import BaseModel, ConfigDict, Field, field_validator from typing_extensions import TypeAlias, TypedDict, override from langchain_core._api import deprecated +from langchain_core.caches import BaseCache +from langchain_core.callbacks import Callbacks from langchain_core.messages import ( AnyMessage, BaseMessage, @@ -29,8 +31,6 @@ from langchain_core.runnables import Runnable, RunnableSerializable from langchain_core.utils import get_pydantic_field_names if TYPE_CHECKING: - from langchain_core.caches import BaseCache - from langchain_core.callbacks import Callbacks from langchain_core.outputs import LLMResult