diff --git a/libs/core/langchain_core/messages/utils.py b/libs/core/langchain_core/messages/utils.py index dd78b1e02c..091ebf9439 100644 --- a/libs/core/langchain_core/messages/utils.py +++ b/libs/core/langchain_core/messages/utils.py @@ -1289,7 +1289,7 @@ def trim_messages( messages, max_tokens=45, strategy="last", - token_counter=ChatOpenAI(model="openai:gpt-5.5"), + token_counter=ChatOpenAI(model="gpt-5.5"), # Most chat models expect that chat history starts with either: # (1) a HumanMessage or # (2) a SystemMessage followed by a HumanMessage diff --git a/libs/core/langchain_core/output_parsers/string.py b/libs/core/langchain_core/output_parsers/string.py index bd4c1fae75..4073f78cfa 100644 --- a/libs/core/langchain_core/output_parsers/string.py +++ b/libs/core/langchain_core/output_parsers/string.py @@ -19,7 +19,7 @@ class StrOutputParser(BaseTransformOutputParser[str]): from langchain_core.output_parsers import StrOutputParser from langchain_openai import ChatOpenAI - model = ChatOpenAI(model="openai:gpt-5.5") + model = ChatOpenAI(model="gpt-5.5") parser = StrOutputParser() # Get string output from a model diff --git a/libs/core/langchain_core/prompts/few_shot.py b/libs/core/langchain_core/prompts/few_shot.py index cfe46d84d2..2f5364b56c 100644 --- a/libs/core/langchain_core/prompts/few_shot.py +++ b/libs/core/langchain_core/prompts/few_shot.py @@ -369,9 +369,9 @@ class FewShotChatMessagePromptTemplate( print(final_prompt.format_messages(input="What's 3+3?")) # noqa: T201 # Use within an LLM - from langchain_core.chat_models import ChatAnthropic + from langchain_anthropic import ChatAnthropic - chain = final_prompt | ChatAnthropic(model="claude-3-haiku-20240307") + chain = final_prompt | ChatAnthropic(model="claude-sonnet-5") chain.invoke({"input": "What's 3+3?"}) ``` """ diff --git a/libs/core/langchain_core/rate_limiters.py b/libs/core/langchain_core/rate_limiters.py index 8bc45b6b5b..95e3bffefc 100644 --- a/libs/core/langchain_core/rate_limiters.py +++ b/libs/core/langchain_core/rate_limiters.py @@ -105,9 +105,7 @@ class InMemoryRateLimiter(BaseRateLimiter): from langchain_anthropic import ChatAnthropic - model = ChatAnthropic( - model_name="claude-sonnet-4-5-20250929", rate_limiter=rate_limiter - ) + model = ChatAnthropic(model_name="claude-sonnet-5", rate_limiter=rate_limiter) for _ in range(5): tic = time.time() diff --git a/libs/core/langchain_core/runnables/fallbacks.py b/libs/core/langchain_core/runnables/fallbacks.py index 7e8235a4d4..98da09fbb4 100644 --- a/libs/core/langchain_core/runnables/fallbacks.py +++ b/libs/core/langchain_core/runnables/fallbacks.py @@ -52,10 +52,10 @@ class RunnableWithFallbacks(RunnableSerializable[Input, Output]): Example: ```python - from langchain_core.chat_models.openai import ChatOpenAI - from langchain_core.chat_models.anthropic import ChatAnthropic + from langchain_anthropic import ChatAnthropic + from langchain_openai import ChatOpenAI - model = ChatAnthropic(model="claude-sonnet-4-6").with_fallbacks( + model = ChatAnthropic(model="claude-sonnet-5").with_fallbacks( [ChatOpenAI(model="gpt-5.4-mini")] ) # Will usually use ChatAnthropic, but fallback to ChatOpenAI @@ -604,8 +604,8 @@ class RunnableWithFallbacks(RunnableSerializable[Input, Output]): from langchain_openai import ChatOpenAI from langchain_anthropic import ChatAnthropic - gpt_55 = ChatOpenAI(model="openai:gpt-5.5") - claude_3_sonnet = ChatAnthropic(model="claude-sonnet-4-5-20250929") + gpt_55 = ChatOpenAI(model="gpt-5.5") + claude_3_sonnet = ChatAnthropic(model="claude-sonnet-5") model = gpt_55.with_fallbacks([claude_3_sonnet]) model.model_name diff --git a/libs/core/langchain_core/runnables/history.py b/libs/core/langchain_core/runnables/history.py index d04e3226d9..df2022fd98 100644 --- a/libs/core/langchain_core/runnables/history.py +++ b/libs/core/langchain_core/runnables/history.py @@ -136,7 +136,7 @@ class RunnableWithMessageHistory(RunnableBindingBase[Any, Any]): # type: ignore ] ) - chain = prompt | ChatAnthropic(model="claude-2") + chain = prompt | ChatAnthropic(model="claude-sonnet-5") chain_with_history = RunnableWithMessageHistory( chain, @@ -189,7 +189,7 @@ class RunnableWithMessageHistory(RunnableBindingBase[Any, Any]): # type: ignore ] ) - chain = prompt | ChatAnthropic(model="claude-2") + chain = prompt | ChatAnthropic(model="claude-sonnet-5") with_message_history = RunnableWithMessageHistory( chain, diff --git a/libs/core/langchain_core/runnables/retry.py b/libs/core/langchain_core/runnables/retry.py index 6b9f5fef2d..5e1e721d6c 100644 --- a/libs/core/langchain_core/runnables/retry.py +++ b/libs/core/langchain_core/runnables/retry.py @@ -96,7 +96,7 @@ class RunnableRetry(RunnableBindingBase[Input, Output]): # type: ignore[no-rede Example: ```python - from langchain_core.chat_models import ChatOpenAI + from langchain_openai import ChatOpenAI from langchain_core.prompts import PromptTemplate template = PromptTemplate.from_template("tell me a joke about {topic}.")