diff --git a/tests/pass_through_tests/base_anthropic_messages_test.py b/tests/pass_through_tests/base_anthropic_messages_test.py index c154d9bc196..aed267ac8a1 100644 --- a/tests/pass_through_tests/base_anthropic_messages_test.py +++ b/tests/pass_through_tests/base_anthropic_messages_test.py @@ -2,7 +2,6 @@ from abc import ABC, abstractmethod import anthropic import pytest -from anthropic._exceptions import OverloadedError class BaseAnthropicMessagesTest(ABC): @@ -14,63 +13,42 @@ class BaseAnthropicMessagesTest(ABC): def get_client(self): return anthropic.Anthropic() - @pytest.mark.flaky(retries=3, delay=2) def test_anthropic_basic_completion(self): print("making basic completion request to anthropic passthrough") client = self.get_client() - try: - response = client.messages.create( - model="claude-3-5-sonnet-20241022", - max_tokens=1024, - messages=[{"role": "user", "content": "Say 'hello test' and nothing else"}], - extra_body={ - "litellm_metadata": { - "tags": ["test-tag-1", "test-tag-2"], - } - }, - ) - print(response) - assert response is not None - assert hasattr(response, 'content') - assert len(response.content) > 0 - # Check if the first content block is a text block - first_block = response.content[0] - from anthropic.types import TextBlock - if isinstance(first_block, TextBlock): - assert first_block.text is not None - assert "hello test" in first_block.text.lower() - except OverloadedError as e: - # Anthropic API is overloaded - this is expected and acceptable for CI - print(f"Anthropic API overloaded (expected): {e}") - pytest.skip("Anthropic API is temporarily overloaded - skipping test") + response = client.messages.create( + model="claude-3-5-sonnet-20241022", + max_tokens=1024, + messages=[{"role": "user", "content": "Say 'hello test' and nothing else"}], + extra_body={ + "litellm_metadata": { + "tags": ["test-tag-1", "test-tag-2"], + } + }, + ) + print(response) - @pytest.mark.flaky(retries=3, delay=2) def test_anthropic_streaming(self): print("making streaming request to anthropic passthrough") - try: - collected_output = [] - client = self.get_client() - with client.messages.stream( - max_tokens=10, - messages=[ - {"role": "user", "content": "Say 'hello stream test' and nothing else"} - ], - model="claude-3-5-sonnet-20241022", - extra_body={ - "litellm_metadata": { - "tags": ["test-tag-stream-1", "test-tag-stream-2"], - } - }, - ) as stream: - for text in stream.text_stream: - collected_output.append(text) + collected_output = [] + client = self.get_client() + with client.messages.stream( + max_tokens=10, + messages=[ + {"role": "user", "content": "Say 'hello stream test' and nothing else"} + ], + model="claude-3-5-sonnet-20241022", + extra_body={ + "litellm_metadata": { + "tags": ["test-tag-stream-1", "test-tag-stream-2"], + } + }, + ) as stream: + for text in stream.text_stream: + collected_output.append(text) - full_response = "".join(collected_output) - print(full_response) - except OverloadedError as e: - # Anthropic API is overloaded - this is expected and acceptable for CI - print(f"Anthropic API overloaded (expected): {e}") - pytest.skip("Anthropic API is temporarily overloaded - skipping test") + full_response = "".join(collected_output) + print(full_response) def test_anthropic_messages_with_thinking(self): print("making request to anthropic passthrough with thinking") @@ -87,12 +65,9 @@ class BaseAnthropicMessagesTest(ABC): print(response) # Verify the first content block is a thinking block - first_block = response.content[0] - from anthropic.types import ThinkingBlock - if isinstance(first_block, ThinkingBlock): - response_thinking = first_block.thinking - assert response_thinking is not None - assert len(response_thinking) > 0 + response_thinking = response.content[0].thinking + assert response_thinking is not None + assert len(response_thinking) > 0 def test_anthropic_streaming_with_thinking(self): print("making streaming request to anthropic passthrough with thinking enabled") @@ -138,8 +113,7 @@ class BaseAnthropicMessagesTest(ABC): model="claude-3-5-sonnet-20241022", max_tokens=10, stream=True, - messages=[{"role": "user", "content": "hi"}], - temperature=3.0, # Invalid temperature (> 2.0) + messages=["hi"], ) print(response) assert pytest.fail("Expected BadRequestError") @@ -158,8 +132,7 @@ class BaseAnthropicMessagesTest(ABC): response = client.messages.create( model="claude-3-5-sonnet-20241022", max_tokens=10, - messages=[{"role": "user", "content": "hi"}], - temperature=3.0, # Invalid temperature (> 2.0) + messages=["hi"], ) print(response) assert pytest.fail("Expected BadRequestError") diff --git a/tests/pass_through_tests/test_anthropic_passthrough_basic.py b/tests/pass_through_tests/test_anthropic_passthrough_basic.py index ccfb0f00e69..86d93818249 100644 --- a/tests/pass_through_tests/test_anthropic_passthrough_basic.py +++ b/tests/pass_through_tests/test_anthropic_passthrough_basic.py @@ -21,7 +21,7 @@ class TestAnthropicMessagesEndpoint(BaseAnthropicMessagesTest): def test_anthropic_messages_to_wildcard_model(self): client = self.get_client() response = client.messages.create( - model="claude-3-5-sonnet-20241022", + model="anthropic/claude-3-opus-20240229", messages=[{"role": "user", "content": "Hello, world!"}], max_tokens=100, ) diff --git a/tests/pass_through_unit_tests/test_pass_through_unit_tests.py b/tests/pass_through_unit_tests/test_pass_through_unit_tests.py index 82fc7a5dcc6..dfd71f8ca5c 100644 --- a/tests/pass_through_unit_tests/test_pass_through_unit_tests.py +++ b/tests/pass_through_unit_tests/test_pass_through_unit_tests.py @@ -146,9 +146,6 @@ def test_init_kwargs_for_pass_through_endpoint_basic( "user_api_key_team_alias": None, "user_api_key_end_user_id": "test-user", "user_api_key_request_route": None, - "user_api_key_spend": 0.0, - "user_api_key_max_budget": None, - "user_api_key_budget_reset_at": None, } assert result["litellm_params"]["metadata"] == expected_metadata