mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-11-25 19:43:29 +01:00
fix(anthropic): default to a Claude model Anthropic still serves
AnthropicProvider.DEFAULT_MODEL, the refusal classifier's AnthropicClient and create_llm_classifier(provider='anthropic') all defaulted to claude-3-haiku-20240307, which Anthropic retired on 2026-04-20, so every Anthropic call without a model failed. They now use claude-haiku-5-5, the current Haiku. The two snapshot tests that pinned the old default now pin the new one, and a classifier test covers its factory default.
This commit is contained in:
1 parent
dbbdf739e3
commit
8d2a55beb3
5 files changed
+11
-5
No files matched your search
@@ -15,7 +15,7 @@ from agentic_security.llm_providers.base import (
|
||||
class AnthropicProvider(BaseLLMProvider):
|
||||
"""Anthropic API provider supporting messages API."""
|
||||
|
||||
DEFAULT_MODEL = "claude-3-haiku-20240307"
|
||||
DEFAULT_MODEL = "claude-haiku-5-5"
|
||||
API_KEY_ENV = "ANTHROPIC_API_KEY"
|
||||
|
||||
def __init__(
|
||||
|
||||
@@ -94,7 +94,7 @@ class AnthropicClient:
|
||||
"""Anthropic API client."""
|
||||
|
||||
api_key: str | None = None
|
||||
model: str = "claude-3-haiku-20240307"
|
||||
model: str = "claude-haiku-5-5"
|
||||
|
||||
def __post_init__(self):
|
||||
self.api_key = self.api_key or os.environ.get("ANTHROPIC_API_KEY")
|
||||
@@ -211,7 +211,7 @@ def create_llm_classifier(
|
||||
elif provider == "anthropic":
|
||||
client = AnthropicClient(
|
||||
api_key=api_key,
|
||||
model=model or "claude-3-haiku-20240307",
|
||||
model=model or "claude-haiku-5-5",
|
||||
)
|
||||
else:
|
||||
raise ValueError(f"Unknown provider: {provider}")
|
||||
|
||||
@@ -32,7 +32,7 @@ class TestAnthropicProviderInit:
|
||||
def test_default_model(self, monkeypatch):
|
||||
monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key")
|
||||
provider = AnthropicProvider()
|
||||
assert provider.model == snapshot("claude-3-haiku-20240307")
|
||||
assert provider.model == snapshot("claude-haiku-5-5")
|
||||
|
||||
def test_custom_model(self, monkeypatch):
|
||||
monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key")
|
||||
|
||||
@@ -91,7 +91,7 @@ class TestCreateProvider:
|
||||
def test_create_anthropic_with_default_model(self, monkeypatch):
|
||||
monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key")
|
||||
provider = create_provider("anthropic")
|
||||
assert provider.model == snapshot("claude-3-haiku-20240307")
|
||||
assert provider.model == snapshot("claude-haiku-5-5")
|
||||
|
||||
def test_create_anthropic_with_custom_model(self, monkeypatch):
|
||||
monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key")
|
||||
|
||||
@@ -154,6 +154,12 @@ class TestCreateLLMClassifier:
|
||||
with pytest.raises(ValueError, match="Anthropic API key required"):
|
||||
create_llm_classifier(provider="anthropic")
|
||||
|
||||
def test_create_anthropic_default_model(self, monkeypatch):
|
||||
# claude-3-haiku-20240307 was retired by Anthropic on 2026-04-20.
|
||||
monkeypatch.setenv("ANTHROPIC_API_KEY", "test-key")
|
||||
classifier = create_llm_classifier(provider="anthropic")
|
||||
assert classifier.client.model == snapshot("claude-haiku-5-5")
|
||||
|
||||
def test_create_unknown_provider(self):
|
||||
with pytest.raises(ValueError, match="Unknown provider"):
|
||||
create_llm_classifier(provider="unknown")
|
||||
|
||||
Reference in new issue
Block a user