fix: resolve Claude 5 model names to the Claude LLM class

Co-authored-by: George Weale <gweale@google.com>
PiperOrigin-RevId: 960059516
This commit is contained in:
George Weale
2026-08-05 22:02:54 -07:00
committed by Copybara-Service
parent cebfd74afc
commit e300ae7aa6
4 changed files with 9 additions and 3 deletions
+4 -1
View File
@@ -67,7 +67,10 @@ _LAZY_PROVIDERS: dict[str, tuple[list[str], str]] = {
# Gemma 3 only (function-calling workarounds). Gemma 4+ resolves to Gemini.
'Gemma': ([r'gemma-.*'], 'gemma_llm'),
'ApigeeLlm': ([r'apigee\/.*'], 'apigee_llm'),
'Claude': ([r'claude-3-.*', r'claude-.*-4.*'], 'anthropic_llm'),
'Claude': (
[r'claude-3-.*', r'claude-.*-4.*', r'claude-.*-5.*'],
'anthropic_llm',
),
'Gemma3Ollama': ([r'ollama/gemma3.*'], 'gemma_llm'),
'OpenAILlm': (
[r'gpt-.*', r'o\d+-.*'],
+1 -1
View File
@@ -735,7 +735,7 @@ class AnthropicLlm(BaseLlm):
@classmethod
@override
def supported_models(cls) -> list[str]:
return [r"claude-3-.*", r"claude-.*-4.*"]
return [r"claude-3-.*", r"claude-.*-4.*", r"claude-.*-5.*"]
def _resolve_model_name(self, model: Optional[str]) -> str:
if not model:
+2 -1
View File
@@ -142,9 +142,10 @@ def test_claude_anthropic_client_creation_with_full_resource_name():
def test_supported_models():
models = Claude.supported_models()
assert len(models) == 2
assert len(models) == 3
assert models[0] == r"claude-3-.*"
assert models[1] == r"claude-.*-4.*"
assert models[2] == r"claude-.*-5.*"
function_declaration_test_cases = [
+2
View File
@@ -48,6 +48,8 @@ def test_match_gemini_family(model_name):
'claude-3-sonnet@20240229',
'claude-sonnet-4@20250514',
'claude-opus-4@20250514',
'claude-opus-5@default',
'claude-sonnet-5@default',
],
)
def test_match_claude_family(model_name):