diff --git a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/chat_generator.py b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/chat_generator.py index 2d766f813e..26e8ee9111 100644 --- a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/chat_generator.py +++ b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/chat_generator.py @@ -161,7 +161,7 @@ class AnthropicChatGenerator: from haystack_integrations.components.generators.anthropic import AnthropicChatGenerator from haystack.dataclasses import ChatMessage - generator = AnthropicChatGenerator(model="claude-3-5-sonnet-20240620", + generator = AnthropicChatGenerator(model="claude-sonnet-4-20250514", generation_kwargs={ "max_tokens": 1000, "temperature": 0.7, @@ -190,7 +190,7 @@ class AnthropicChatGenerator: def __init__( self, api_key: Secret = Secret.from_env_var("ANTHROPIC_API_KEY"), # noqa: B008 - model: str = "claude-3-5-sonnet-20240620", + model: str = "claude-sonnet-4-20250514", streaming_callback: Optional[StreamingCallbackT] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, diff --git a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/vertex_chat_generator.py b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/vertex_chat_generator.py index 32918b2b60..b750ebfde3 100644 --- a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/vertex_chat_generator.py +++ b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/chat/vertex_chat_generator.py @@ -39,7 +39,7 @@ class AnthropicVertexChatGenerator(AnthropicChatGenerator): messages = [ChatMessage.from_user("What's Natural Language Processing?")] client = AnthropicVertexChatGenerator( - model="claude-3-sonnet@20240229", + model="claude-sonnet-4@20250514", project_id="your-project-id", region="your-region" ) response = client.run(messages) @@ -50,7 +50,7 @@ class AnthropicVertexChatGenerator(AnthropicChatGenerator): >> focuses on enabling computers to understand, interpret, and generate human language. It involves developing >> techniques and algorithms to analyze and process text or speech data, allowing machines to comprehend and >> communicate in natural languages like English, Spanish, or Chinese.")], - >> _name=None, _meta={'model': 'claude-3-sonnet@20240229', 'index': 0, 'finish_reason': 'end_turn', + >> _name=None, _meta={'model': 'claude-sonnet-4@20250514', 'index': 0, 'finish_reason': 'end_turn', >> 'usage': {'input_tokens': 15, 'output_tokens': 64}})]} ``` @@ -63,7 +63,7 @@ def __init__( self, region: str, project_id: str, - model: str = "claude-3-5-sonnet@20240620", + model: str = "claude-sonnet-4@20250514", streaming_callback: Optional[Callable[[StreamingChunk], None]] = None, generation_kwargs: Optional[Dict[str, Any]] = None, ignore_tools_thinking_messages: bool = True, diff --git a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/generator.py b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/generator.py index 576c2dde8e..9534b1156e 100644 --- a/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/generator.py +++ b/integrations/anthropic/src/haystack_integrations/components/generators/anthropic/generator.py @@ -35,7 +35,7 @@ class AnthropicGenerator: ```python from haystack_integrations.components.generators.anthropic import AnthropicGenerator - client = AnthropicGenerator(model="claude-3-sonnet-20240229") + client = AnthropicGenerator(model="claude-sonnet-4-20250514") response = client.run("What's Natural Language Processing? Be brief.") print(response) >>{'replies': ['Natural language processing (NLP) is a branch of artificial intelligence focused on enabling @@ -60,7 +60,7 @@ class AnthropicGenerator: def __init__( self, api_key: Secret = Secret.from_env_var("ANTHROPIC_API_KEY"), # noqa: B008 - model: str = "claude-3-sonnet-20240229", + model: str = "claude-sonnet-4-20250514", streaming_callback: Optional[Callable[[StreamingChunk], None]] = None, system_prompt: Optional[str] = None, generation_kwargs: Optional[Dict[str, Any]] = None, diff --git a/integrations/anthropic/tests/conftest.py b/integrations/anthropic/tests/conftest.py index f134c5df08..26aa44743e 100644 --- a/integrations/anthropic/tests/conftest.py +++ b/integrations/anthropic/tests/conftest.py @@ -13,7 +13,7 @@ def mock_chat_completion(): completion = Message( id="foo", content=[{"type": "text", "text": "Hello, world!"}], - model="claude-3-sonnet-20240229", + model="claude-sonnet-4-20250514", role="assistant", type="message", usage={"input_tokens": 57, "output_tokens": 40}, @@ -35,7 +35,7 @@ def mock_chat_completion_extended_thinking(): {"type": "thinking", "thinking": "This is a thinking part!", "signature": ""}, {"type": "text", "text": "Hello, world!"}, ], - model="claude-3-sonnet-20240229", + model="claude-sonnet-4-20250514", role="assistant", type="message", usage={"input_tokens": 57, "output_tokens": 40}, diff --git a/integrations/anthropic/tests/test_chat_generator.py b/integrations/anthropic/tests/test_chat_generator.py index 75ceb9c4c9..1abb2eb3a3 100644 --- a/integrations/anthropic/tests/test_chat_generator.py +++ b/integrations/anthropic/tests/test_chat_generator.py @@ -70,7 +70,7 @@ def mock_anthropic_completion(): completion = Message( id="foo", type="message", - model="claude-3-5-sonnet-20240620", + model="claude-sonnet-4-20250514", role="assistant", content=[TextBlockParam(type="text", text="Hello! I'm Claude.")], stop_reason="end_turn", @@ -88,7 +88,7 @@ def test_init_default(self, monkeypatch): monkeypatch.setenv("ANTHROPIC_API_KEY", "test-api-key") component = AnthropicChatGenerator() assert component.client.api_key == "test-api-key" - assert component.model == "claude-3-5-sonnet-20240620" + assert component.model == "claude-sonnet-4-20250514" assert component.streaming_callback is None assert not component.generation_kwargs assert component.tools is None @@ -121,13 +121,13 @@ def test_init_with_parameters(self, monkeypatch): monkeypatch.setenv("OPENAI_MAX_RETRIES", "10") component = AnthropicChatGenerator( api_key=Secret.from_token("test-api-key"), - model="claude-3-5-sonnet-20240620", + model="claude-sonnet-4-20250514", streaming_callback=print_streaming_chunk, generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"}, tools=[tool], ) assert component.client.api_key == "test-api-key" - assert component.model == "claude-3-5-sonnet-20240620" + assert component.model == "claude-sonnet-4-20250514" assert component.streaming_callback is print_streaming_chunk assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"} assert component.tools == [tool] @@ -139,13 +139,13 @@ def test_init_with_parameters_and_env_vars(self, monkeypatch): monkeypatch.setenv("OPENAI_TIMEOUT", "100") monkeypatch.setenv("OPENAI_MAX_RETRIES", "10") component = AnthropicChatGenerator( - model="claude-3-5-sonnet-20240620", + model="claude-sonnet-4-20250514", api_key=Secret.from_token("test-api-key"), streaming_callback=print_streaming_chunk, generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"}, ) assert component.client.api_key == "test-api-key" - assert component.model == "claude-3-5-sonnet-20240620" + assert component.model == "claude-sonnet-4-20250514" assert component.streaming_callback is print_streaming_chunk assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"} @@ -160,7 +160,7 @@ def test_to_dict_default(self, monkeypatch): "type": "haystack_integrations.components.generators.anthropic.chat.chat_generator.AnthropicChatGenerator", "init_parameters": { "api_key": {"env_vars": ["ANTHROPIC_API_KEY"], "type": "env_var", "strict": True}, - "model": "claude-3-5-sonnet-20240620", + "model": "claude-sonnet-4-20250514", "streaming_callback": None, "ignore_tools_thinking_messages": True, "generation_kwargs": {}, @@ -179,7 +179,7 @@ def test_to_dict_with_parameters(self, monkeypatch): monkeypatch.setenv("ENV_VAR", "test-api-key") component = AnthropicChatGenerator( api_key=Secret.from_env_var("ENV_VAR"), - model="claude-3-5-sonnet-20240620", + model="claude-sonnet-4-20250514", streaming_callback=print_streaming_chunk, generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"}, tools=[tool], @@ -192,7 +192,7 @@ def test_to_dict_with_parameters(self, monkeypatch): "type": "haystack_integrations.components.generators.anthropic.chat.chat_generator.AnthropicChatGenerator", "init_parameters": { "api_key": {"env_vars": ["ENV_VAR"], "type": "env_var", "strict": True}, - "model": "claude-3-5-sonnet-20240620", + "model": "claude-sonnet-4-20250514", "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", "ignore_tools_thinking_messages": True, "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, @@ -236,7 +236,7 @@ def test_from_dict(self, monkeypatch): "type": "haystack_integrations.components.generators.anthropic.chat.chat_generator.AnthropicChatGenerator", "init_parameters": { "api_key": {"env_vars": ["ANTHROPIC_API_KEY"], "type": "env_var", "strict": True}, - "model": "claude-3-5-sonnet-20240620", + "model": "claude-sonnet-4-20250514", "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, "tools": [ @@ -259,7 +259,7 @@ def test_from_dict(self, monkeypatch): component = AnthropicChatGenerator.from_dict(data) assert isinstance(component, AnthropicChatGenerator) - assert component.model == "claude-3-5-sonnet-20240620" + assert component.model == "claude-sonnet-4-20250514" assert component.streaming_callback is print_streaming_chunk assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"} assert component.api_key == Secret.from_env_var("ANTHROPIC_API_KEY") @@ -276,7 +276,7 @@ def test_from_dict_fail_wo_env_var(self, monkeypatch): "type": "haystack_integrations.components.generators.anthropic.chat.chat_generator.AnthropicChatGenerator", "init_parameters": { "api_key": {"env_vars": ["ANTHROPIC_API_KEY"], "type": "env_var", "strict": True}, - "model": "claude-3-5-sonnet-20240620", + "model": "claude-sonnet-4-20250514", "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, }, @@ -316,7 +316,7 @@ def test_run_with_params(self, chat_messages, mock_anthropic_completion): assert len(response["replies"]) == 1 assert isinstance(response["replies"][0], ChatMessage) assert "Hello! I'm Claude." in response["replies"][0].text - assert response["replies"][0].meta["model"] == "claude-3-5-sonnet-20240620" + assert response["replies"][0].meta["model"] == "claude-sonnet-4-20250514" assert response["replies"][0].meta["finish_reason"] == "end_turn" def test_check_duplicate_tool_names(self, tools): @@ -350,7 +350,7 @@ def test_convert_anthropic_chunk_to_streaming_chunk(self): "type": "message", "role": "assistant", "content": [], - "model": "claude-3-5-sonnet-20240620", + "model": "claude-sonnet-4-20250514", "stop_reason": None, "stop_sequence": None, "usage": {"input_tokens": 25, "output_tokens": 1}, @@ -371,7 +371,7 @@ def test_convert_anthropic_chunk_to_streaming_chunk(self): "type": "message", "role": "assistant", "content": [], - "model": "claude-3-5-sonnet-20240620", + "model": "claude-sonnet-4-20250514", "stop_reason": None, "stop_sequence": None, "usage": { @@ -413,7 +413,7 @@ def test_convert_streaming_chunks_to_chat_message(self): "type": "message", "role": "assistant", "content": [], - "model": "claude-3-sonnet", + "model": "claude-sonnet-4-20250514", "stop_reason": None, "stop_sequence": None, "usage": {"input_tokens": 25, "output_tokens": 0}, @@ -480,7 +480,7 @@ def test_convert_streaming_chunks_to_chat_message(self): ] component = AnthropicChatGenerator(api_key=Secret.from_token("test-api-key")) - message = component._convert_streaming_chunks_to_chat_message(chunks, model="claude-3-sonnet") + message = component._convert_streaming_chunks_to_chat_message(chunks, model="claude-sonnet-4-20250514") # Verify the message content assert message.text == "Let me check the weather" @@ -493,7 +493,7 @@ def test_convert_streaming_chunks_to_chat_message(self): assert tool_call.arguments == {"city": "Paris"} # Verify meta information - assert message._meta["model"] == "claude-3-sonnet" + assert message._meta["model"] == "claude-sonnet-4-20250514" assert message._meta["index"] == 0 assert message._meta["finish_reason"] == "tool_use" assert message._meta["usage"] == {"prompt_tokens": 25, "completion_tokens": 40} @@ -558,7 +558,7 @@ def test_convert_streaming_chunks_to_chat_message_malformed_json(self, caplog): ] component = AnthropicChatGenerator(api_key=Secret.from_token("test-api-key")) - message = component._convert_streaming_chunks_to_chat_message(chunks, model="claude-3-sonnet") + message = component._convert_streaming_chunks_to_chat_message(chunks, model="claude-sonnet-4-20250514") # Verify the message content is preserve assert message.text == "Let me check the weather" @@ -585,7 +585,7 @@ def test_convert_streaming_chunks_to_chat_message_tool_call_with_empty_arguments "type": "message", "role": "assistant", "content": [], - "model": "claude-3-sonnet", + "model": "claude-sonnet-4-20250514", "stop_reason": None, "stop_sequence": None, "usage": {"input_tokens": 50, "output_tokens": 0}, @@ -670,7 +670,7 @@ def test_convert_streaming_chunks_to_chat_message_tool_call_with_empty_arguments ] component = AnthropicChatGenerator(api_key=Secret.from_token("test-api-key")) - message = component._convert_streaming_chunks_to_chat_message(chunks, model="claude-3-sonnet") + message = component._convert_streaming_chunks_to_chat_message(chunks, model="claude-sonnet-4-20250514") # Verify the message content assert message.text == ( @@ -686,7 +686,7 @@ def test_convert_streaming_chunks_to_chat_message_tool_call_with_empty_arguments assert tool_call.arguments == {} # Verify meta information - assert message._meta["model"] == "claude-3-sonnet" + assert message._meta["model"] == "claude-sonnet-4-20250514" assert message._meta["index"] == 0 assert message._meta["finish_reason"] == "tool_use" assert message._meta["usage"] == { @@ -702,7 +702,7 @@ def test_serde_in_pipeline(self): generator = AnthropicChatGenerator( api_key=Secret.from_env_var("ANTHROPIC_API_KEY", strict=False), - model="claude-3-5-sonnet-20240620", + model="claude-sonnet-4-20250514", generation_kwargs={"temperature": 0.6}, tools=[tool], ) @@ -722,7 +722,7 @@ def test_serde_in_pipeline(self): "type": type_, "init_parameters": { "api_key": {"type": "env_var", "env_vars": ["ANTHROPIC_API_KEY"], "strict": False}, - "model": "claude-3-5-sonnet-20240620", + "model": "claude-sonnet-4-20250514", "generation_kwargs": {"temperature": 0.6}, "ignore_tools_thinking_messages": True, "streaming_callback": None, @@ -784,7 +784,7 @@ def test_live_run(self): assert len(results["replies"]) == 1 message: ChatMessage = results["replies"][0] assert "Paris" in message.text - assert "claude-3-5-sonnet-20240620" in message.meta["model"] + assert "claude-sonnet-4-20250514" in message.meta["model"] assert message.meta["finish_reason"] == "end_turn" @pytest.mark.skipif( @@ -824,7 +824,7 @@ def __call__(self, chunk: StreamingChunk) -> None: message: ChatMessage = results["replies"][0] assert "Paris" in message.text - assert "claude-3-5-sonnet-20240620" in message.meta["model"] + assert "claude-sonnet-4-20250514" in message.meta["model"] assert message.meta["finish_reason"] == "end_turn" assert callback.counter > 1 @@ -1317,7 +1317,7 @@ def test_from_dict_with_prompt_caching(self, monkeypatch): "type": "haystack_integrations.components.generators.anthropic.chat.chat_generator.AnthropicChatGenerator", "init_parameters": { "api_key": {"env_vars": ["ANTHROPIC_API_KEY"], "strict": True, "type": "env_var"}, - "model": "claude-3-5-sonnet-20240620", + "model": "claude-sonnet-4-20250514", "generation_kwargs": {"extra_headers": {"anthropic-beta": "prompt-caching-2024-07-31"}}, }, } @@ -1364,7 +1364,7 @@ async def mock_anthropic_completion_async(self): completion = Message( id="foo", type="message", - model="claude-3-5-sonnet-20240620", + model="claude-sonnet-4-20250514", role="assistant", content=[TextBlockParam(type="text", text="Hello! I'm Claude.")], stop_reason="end_turn", @@ -1380,7 +1380,7 @@ async def mock_anthropic_completion_async_with_tool(self): completion = Message( id="foo", type="message", - model="claude-3-5-sonnet-20240620", + model="claude-sonnet-4-20250514", role="assistant", content=[ TextBlockParam(type="text", text="Let me check the weather for you."), @@ -1431,7 +1431,7 @@ async def test_run_async_with_params(self, chat_messages, mock_anthropic_complet assert len(response["replies"]) == 1 assert isinstance(response["replies"][0], ChatMessage) assert "Hello! I'm Claude." in response["replies"][0].text - assert response["replies"][0].meta["model"] == "claude-3-5-sonnet-20240620" + assert response["replies"][0].meta["model"] == "claude-sonnet-4-20250514" assert response["replies"][0].meta["finish_reason"] == "end_turn" @pytest.mark.asyncio @@ -1449,7 +1449,7 @@ async def test_live_run_async(self): assert len(results["replies"]) == 1 message: ChatMessage = results["replies"][0] assert "Paris" in message.text - assert "claude-3-5-sonnet-20240620" in message.meta["model"] + assert "claude-sonnet-4-20250514" in message.meta["model"] assert message.meta["finish_reason"] == "end_turn" @pytest.mark.asyncio @@ -1482,7 +1482,7 @@ async def callback(chunk: StreamingChunk) -> None: assert len(results["replies"]) == 1 message = results["replies"][0] assert "paris" in message.text.lower() - assert "claude-3-5-sonnet-20240620" in message.meta["model"] + assert "claude-sonnet-4-20250514" in message.meta["model"] assert message.meta["finish_reason"] == "end_turn" # Verify streaming behavior diff --git a/integrations/anthropic/tests/test_generator.py b/integrations/anthropic/tests/test_generator.py index b02cf12d86..69775c3fae 100644 --- a/integrations/anthropic/tests/test_generator.py +++ b/integrations/anthropic/tests/test_generator.py @@ -14,7 +14,7 @@ def test_init_default(self, monkeypatch): monkeypatch.setenv("ANTHROPIC_API_KEY", "test-api-key") component = AnthropicGenerator() assert component.client.api_key == "test-api-key" - assert component.model == "claude-3-sonnet-20240229" + assert component.model == "claude-sonnet-4-20250514" assert component.streaming_callback is None assert not component.generation_kwargs @@ -26,12 +26,12 @@ def test_init_fail_wo_api_key(self, monkeypatch): def test_init_with_parameters(self): component = AnthropicGenerator( api_key=Secret.from_token("test-api-key"), - model="claude-3-sonnet-20240229", + model="claude-sonnet-4-20250514", streaming_callback=print_streaming_chunk, generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"}, ) assert component.client.api_key == "test-api-key" - assert component.model == "claude-3-sonnet-20240229" + assert component.model == "claude-sonnet-4-20250514" assert component.streaming_callback is print_streaming_chunk assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"} @@ -43,7 +43,7 @@ def test_to_dict_default(self, monkeypatch): "type": "haystack_integrations.components.generators.anthropic.generator.AnthropicGenerator", "init_parameters": { "api_key": {"env_vars": ["ANTHROPIC_API_KEY"], "strict": True, "type": "env_var"}, - "model": "claude-3-sonnet-20240229", + "model": "claude-sonnet-4-20250514", "streaming_callback": None, "system_prompt": None, "generation_kwargs": {}, @@ -67,7 +67,7 @@ def test_to_dict_with_parameters(self, monkeypatch): "type": "haystack_integrations.components.generators.anthropic.generator.AnthropicGenerator", "init_parameters": { "api_key": {"env_vars": ["ENV_VAR"], "strict": True, "type": "env_var"}, - "model": "claude-3-sonnet-20240229", + "model": "claude-sonnet-4-20250514", "system_prompt": "test-prompt", "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, @@ -82,7 +82,7 @@ def test_from_dict(self, monkeypatch): "type": "haystack_integrations.components.generators.anthropic.generator.AnthropicGenerator", "init_parameters": { "api_key": {"env_vars": ["ANTHROPIC_API_KEY"], "strict": True, "type": "env_var"}, - "model": "claude-3-sonnet-20240229", + "model": "claude-sonnet-4-20250514", "system_prompt": "test-prompt", "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, @@ -91,7 +91,7 @@ def test_from_dict(self, monkeypatch): }, } component = AnthropicGenerator.from_dict(data) - assert component.model == "claude-3-sonnet-20240229" + assert component.model == "claude-sonnet-4-20250514" assert component.streaming_callback is print_streaming_chunk assert component.system_prompt == "test-prompt" assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"} @@ -105,7 +105,7 @@ def test_from_dict_fail_wo_env_var(self, monkeypatch): "type": "haystack_integrations.components.generators.anthropic.generator.AnthropicGenerator", "init_parameters": { "api_key": {"env_vars": ["ANTHROPIC_API_KEY"], "strict": True, "type": "env_var"}, - "model": "claude-3-sonnet-20240229", + "model": "claude-sonnet-4-20250514", "system_prompt": "test-prompt", "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, @@ -242,7 +242,7 @@ def streaming_callback(chunk: StreamingChunk): @pytest.mark.integration def test_extended_thinking_mode(self): client = AnthropicGenerator( - model="claude-3-7-sonnet-20250219", + model="claude-sonnet-4-20250514", generation_kwargs={"thinking": {"type": "enabled", "budget_tokens": 1024}, "max_tokens": 1536}, ) response = client.run("What is the capital of France?") @@ -290,7 +290,7 @@ def streaming_callback(chunk: StreamingChunk): thinking_end_tag_found = "" in chunk.content client = AnthropicGenerator( - model="claude-3-7-sonnet-20250219", + model="claude-sonnet-4-20250514", generation_kwargs={"thinking": {"type": "enabled", "budget_tokens": 1024}, "max_tokens": 1536}, streaming_callback=streaming_callback, ) @@ -336,7 +336,7 @@ def streaming_callback(chunk: StreamingChunk): thinking_end_tag_found = "" in chunk.content client = AnthropicGenerator( - model="claude-3-7-sonnet-20250219", + model="claude-sonnet-4-20250514", generation_kwargs={ "thinking": {"type": "enabled", "budget_tokens": 1024}, "max_tokens": 1536, diff --git a/integrations/anthropic/tests/test_vertex_chat_generator.py b/integrations/anthropic/tests/test_vertex_chat_generator.py index cb50f29846..e90459d540 100644 --- a/integrations/anthropic/tests/test_vertex_chat_generator.py +++ b/integrations/anthropic/tests/test_vertex_chat_generator.py @@ -21,7 +21,7 @@ def test_init_default(self): component = AnthropicVertexChatGenerator(region="us-central1", project_id="test-project-id") assert component.region == "us-central1" assert component.project_id == "test-project-id" - assert component.model == "claude-3-5-sonnet@20240620" + assert component.model == "claude-sonnet-4@20250514" assert component.streaming_callback is None assert not component.generation_kwargs assert component.ignore_tools_thinking_messages @@ -30,14 +30,14 @@ def test_init_with_parameters(self): component = AnthropicVertexChatGenerator( region="us-central1", project_id="test-project-id", - model="claude-3-5-sonnet@20240620", + model="claude-sonnet-4@20250514", streaming_callback=print_streaming_chunk, generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"}, ignore_tools_thinking_messages=False, ) assert component.region == "us-central1" assert component.project_id == "test-project-id" - assert component.model == "claude-3-5-sonnet@20240620" + assert component.model == "claude-sonnet-4@20250514" assert component.streaming_callback is print_streaming_chunk assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"} assert component.ignore_tools_thinking_messages is False @@ -53,7 +53,7 @@ def test_to_dict_default(self): "init_parameters": { "region": "us-central1", "project_id": "test-project-id", - "model": "claude-3-5-sonnet@20240620", + "model": "claude-sonnet-4@20250514", "streaming_callback": None, "generation_kwargs": {}, "ignore_tools_thinking_messages": True, @@ -82,7 +82,7 @@ def test_to_dict_with_parameters(self): "init_parameters": { "region": "us-central1", "project_id": "test-project-id", - "model": "claude-3-5-sonnet@20240620", + "model": "claude-sonnet-4@20250514", "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, "ignore_tools_thinking_messages": False, @@ -101,7 +101,7 @@ def test_from_dict(self): "init_parameters": { "region": "us-central1", "project_id": "test-project-id", - "model": "claude-3-5-sonnet@20240620", + "model": "claude-sonnet-4@20250514", "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk", "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"}, "ignore_tools_thinking_messages": True, @@ -111,7 +111,7 @@ def test_from_dict(self): }, } component = AnthropicVertexChatGenerator.from_dict(data) - assert component.model == "claude-3-5-sonnet@20240620" + assert component.model == "claude-sonnet-4@20250514" assert component.region == "us-central1" assert component.project_id == "test-project-id" assert component.streaming_callback is print_streaming_chunk @@ -168,7 +168,7 @@ def test_live_run_wrong_model(self, chat_messages): @pytest.mark.integration def test_default_inference_params(self, chat_messages): client = AnthropicVertexChatGenerator( - region=os.environ.get("REGION"), project_id=os.environ.get("PROJECT_ID"), model="claude-3-sonnet@20240229" + region=os.environ.get("REGION"), project_id=os.environ.get("PROJECT_ID"), model="claude-sonnet-4@20250514" ) response = client.run(chat_messages) @@ -202,13 +202,13 @@ async def test_live_run_async(self): component = AnthropicVertexChatGenerator( region=os.environ.get("REGION"), project_id=os.environ.get("PROJECT_ID"), - model="claude-3-5-sonnet@20240620", + model="claude-sonnet-4@20250514", ) results = await component.run_async(messages=[ChatMessage.from_user("What's the capital of France?")]) assert len(results["replies"]) == 1 message: ChatMessage = results["replies"][0] assert "Paris" in message.text - assert "claude-3-5-sonnet-20240620" in message.meta["model"] + assert "claude-sonnet-4-20250514" in message.meta["model"] assert message.meta["finish_reason"] == "end_turn" # Anthropic messages API is similar for AnthropicVertex and Anthropic endpoint,