Three live-API tests pinned to claude-4-sonnet-20250514, which is a non-canonical alias of claude-sonnet-4-20250514. Anthropic's main API no longer resolves the legacy form under freshly issued keys, so the tests fail with not_found_error. The token counter test pinned to claude-sonnet-4-20250514 itself (deprecation_date 2026-05-14, two weeks out) was on borrowed time too. Bump all four to claude-haiku-4-5-20251001 — capability superset for what these tests exercise (streaming, parallel tool calling, extended thinking, token counting), no upcoming deprecation, cheaper per-token.
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
"""
|
|
Anthropic Token Counter Tests.
|
|
|
|
Tests for the Anthropic token counter implementation using the base test suite.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
from typing import Any, Dict, List
|
|
|
|
import pytest
|
|
|
|
sys.path.insert(
|
|
0, os.path.abspath("../..")
|
|
) # Adds the parent directory to the system path
|
|
|
|
from litellm.llms.anthropic.count_tokens import AnthropicTokenCounter
|
|
from litellm.llms.base_llm.base_utils import BaseTokenCounter
|
|
from tests.litellm_utils_tests.base_token_counter_test import BaseTokenCounterTest
|
|
|
|
|
|
class TestAnthropicTokenCounter(BaseTokenCounterTest):
|
|
"""Test suite for Anthropic token counter."""
|
|
|
|
def get_token_counter(self) -> BaseTokenCounter:
|
|
return AnthropicTokenCounter()
|
|
|
|
def get_test_model(self) -> str:
|
|
return "claude-haiku-4-5-20251001"
|
|
|
|
def get_test_messages(self) -> List[Dict[str, Any]]:
|
|
return [{"role": "user", "content": "Hello, how are you today?"}]
|
|
|
|
def get_deployment_config(self) -> Dict[str, Any]:
|
|
api_key = os.getenv("ANTHROPIC_API_KEY")
|
|
if not api_key:
|
|
pytest.skip("ANTHROPIC_API_KEY not set")
|
|
return {
|
|
"litellm_params": {
|
|
"api_key": api_key,
|
|
}
|
|
}
|
|
|
|
def get_custom_llm_provider(self) -> str:
|
|
return "anthropic"
|