mirror of
https://github.com/hwchase17/langchain.git
synced 2026-06-09 10:17:00 +00:00
style(anthropic): use aliases for model names (#33590)
This commit is contained in:
@@ -18,10 +18,7 @@ from langchain_core.callbacks import (
|
||||
)
|
||||
from langchain_core.exceptions import OutputParserException
|
||||
from langchain_core.language_models import LanguageModelInput
|
||||
from langchain_core.language_models.chat_models import (
|
||||
BaseChatModel,
|
||||
LangSmithParams,
|
||||
)
|
||||
from langchain_core.language_models.chat_models import BaseChatModel, LangSmithParams
|
||||
from langchain_core.messages import (
|
||||
AIMessage,
|
||||
AIMessageChunk,
|
||||
@@ -1271,7 +1268,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
|
||||
model = ChatAnthropic(
|
||||
model="claude-sonnet-4-5-20250929",
|
||||
model="claude-sonnet-4-5",
|
||||
betas=["context-management-2025-06-27"],
|
||||
context_management={"edits": [{"type": "clear_tool_uses_20250919"}]},
|
||||
)
|
||||
@@ -1399,7 +1396,7 @@ class ChatAnthropic(BaseChatModel):
|
||||
from langchain_anthropic import ChatAnthropic
|
||||
|
||||
model = ChatAnthropic(
|
||||
model="claude-sonnet-4-5-20250929",
|
||||
model="claude-sonnet-4-5",
|
||||
betas=["context-management-2025-06-27"],
|
||||
)
|
||||
model_with_tools = model.bind_tools([{"type": "memory_20250818", "name": "memory"}])
|
||||
|
||||
@@ -1810,7 +1810,7 @@ def test_search_result_top_level() -> None:
|
||||
|
||||
def test_memory_tool() -> None:
|
||||
llm = ChatAnthropic(
|
||||
model="claude-sonnet-4-5-20250929", # type: ignore[call-arg]
|
||||
model="claude-sonnet-4-5", # type: ignore[call-arg]
|
||||
betas=["context-management-2025-06-27"],
|
||||
)
|
||||
llm_with_tools = llm.bind_tools([{"type": "memory_20250818", "name": "memory"}])
|
||||
@@ -1824,7 +1824,7 @@ def test_memory_tool() -> None:
|
||||
def test_context_management() -> None:
|
||||
# TODO: update example to trigger action
|
||||
llm = ChatAnthropic(
|
||||
model="claude-sonnet-4-5-20250929", # type: ignore[call-arg]
|
||||
model="claude-sonnet-4-5", # type: ignore[call-arg]
|
||||
betas=["context-management-2025-06-27"],
|
||||
context_management={
|
||||
"edits": [
|
||||
|
||||
@@ -1325,7 +1325,7 @@ def test_get_num_tokens_from_messages_passes_kwargs() -> None:
|
||||
assert _client.return_value.messages.count_tokens.call_args.kwargs["foo"] == "bar"
|
||||
|
||||
llm = ChatAnthropic(
|
||||
model="claude-sonnet-4-5-20250929",
|
||||
model="claude-sonnet-4-5",
|
||||
betas=["context-management-2025-06-27"],
|
||||
context_management={"edits": [{"type": "clear_tool_uses_20250919"}]},
|
||||
)
|
||||
@@ -1488,7 +1488,7 @@ def test_cache_control_kwarg() -> None:
|
||||
|
||||
def test_context_management_in_payload() -> None:
|
||||
llm = ChatAnthropic(
|
||||
model="claude-sonnet-4-5-20250929", # type: ignore[call-arg]
|
||||
model="claude-sonnet-4-5", # type: ignore[call-arg]
|
||||
betas=["context-management-2025-06-27"],
|
||||
context_management={"edits": [{"type": "clear_tool_uses_20250919"}]},
|
||||
)
|
||||
@@ -1514,8 +1514,8 @@ def test_anthropic_model_params() -> None:
|
||||
"ls_temperature": None,
|
||||
}
|
||||
|
||||
ls_params = llm._get_ls_params(model="claude-opus-4-1-20250805")
|
||||
assert ls_params.get("ls_model_name") == "claude-opus-4-1-20250805"
|
||||
ls_params = llm._get_ls_params(model="claude-opus-4-1")
|
||||
assert ls_params.get("ls_model_name") == "claude-opus-4-1"
|
||||
|
||||
|
||||
def test_streaming_cache_token_reporting() -> None:
|
||||
|
||||
Reference in New Issue
Block a user