1515from google .adk import models
1616from google .adk .models .anthropic_llm import Claude
1717from google .adk .models .google_llm import Gemini
18- from google .adk .models .registry import LLMRegistry
18+ from google .adk .models .lite_llm import LiteLlm
1919import pytest
2020
2121
3434 ],
3535)
3636def test_match_gemini_family (model_name ):
37+ """Test that Gemini models are resolved correctly."""
3738 assert models .LLMRegistry .resolve (model_name ) is Gemini
3839
3940
@@ -51,12 +52,63 @@ def test_match_gemini_family(model_name):
5152 ],
5253)
5354def test_match_claude_family (model_name ):
54- LLMRegistry .register (Claude )
55-
55+ """Test that Claude models are resolved correctly."""
5656 assert models .LLMRegistry .resolve (model_name ) is Claude
5757
5858
59+ @pytest .mark .parametrize (
60+ 'model_name' ,
61+ [
62+ 'openai/gpt-4o' ,
63+ 'openai/gpt-4o-mini' ,
64+ 'groq/llama3-70b-8192' ,
65+ 'groq/mixtral-8x7b-32768' ,
66+ 'anthropic/claude-3-opus-20240229' ,
67+ 'anthropic/claude-3-5-sonnet-20241022' ,
68+ ],
69+ )
70+ def test_match_litellm_family (model_name ):
71+ """Test that LiteLLM models are resolved correctly."""
72+ assert models .LLMRegistry .resolve (model_name ) is LiteLlm
73+
74+
5975def test_non_exist_model ():
6076 with pytest .raises (ValueError ) as e_info :
6177 models .LLMRegistry .resolve ('non-exist-model' )
6278 assert 'Model non-exist-model not found.' in str (e_info .value )
79+
80+
81+ def test_helpful_error_for_claude_without_extensions ():
82+ """Test that missing Claude models show helpful install instructions.
83+
84+ Note: This test may pass even when anthropic IS installed, because it
85+ only checks the error message format when a model is not found.
86+ """
87+ # Use a non-existent Claude model variant to trigger error
88+ with pytest .raises (ValueError ) as e_info :
89+ models .LLMRegistry .resolve ('claude-nonexistent-model-xyz' )
90+
91+ error_msg = str (e_info .value )
92+ # The error should mention anthropic package and installation instructions
93+ # These checks work whether or not anthropic is actually installed
94+ assert 'Model claude-nonexistent-model-xyz not found' in error_msg
95+ assert 'anthropic package' in error_msg
96+ assert 'pip install' in error_msg
97+
98+
99+ def test_helpful_error_for_litellm_without_extensions ():
100+ """Test that missing LiteLLM models show helpful install instructions.
101+
102+ Note: This test may pass even when litellm IS installed, because it
103+ only checks the error message format when a model is not found.
104+ """
105+ # Use a non-existent provider to trigger error
106+ with pytest .raises (ValueError ) as e_info :
107+ models .LLMRegistry .resolve ('unknown-provider/gpt-4o' )
108+
109+ error_msg = str (e_info .value )
110+ # The error should mention litellm package for provider-style models
111+ assert 'Model unknown-provider/gpt-4o not found' in error_msg
112+ assert 'litellm package' in error_msg
113+ assert 'pip install' in error_msg
114+ assert 'Provider-style models' in error_msg
0 commit comments