mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat: make LlmAgent.model optional with a default fallback
LlmAgent now resolves model from ancestors or a system default (gemini-2.5-flash) when unset. Added LlmAgent.set_default_model() to override the default globally Co-authored-by: George Weale <gweale@google.com> PiperOrigin-RevId: 853006116
This commit is contained in:
committed by
Copybara-Service
parent
742c9265a2
commit
b28721508a
@@ -52,11 +52,24 @@ async def _create_readonly_context(
|
||||
return ReadonlyContext(invocation_context)
|
||||
|
||||
|
||||
def test_canonical_model_empty():
|
||||
agent = LlmAgent(name='test_agent')
|
||||
|
||||
with pytest.raises(ValueError):
|
||||
_ = agent.canonical_model
|
||||
@pytest.mark.parametrize(
|
||||
('default_model', 'expected_model_name', 'expected_model_type'),
|
||||
[
|
||||
(LlmAgent.DEFAULT_MODEL, LlmAgent.DEFAULT_MODEL, Gemini),
|
||||
('gemini-2.0-flash', 'gemini-2.0-flash', Gemini),
|
||||
],
|
||||
)
|
||||
def test_canonical_model_default_fallback(
|
||||
default_model, expected_model_name, expected_model_type
|
||||
):
|
||||
original_default = LlmAgent._default_model
|
||||
LlmAgent.set_default_model(default_model)
|
||||
try:
|
||||
agent = LlmAgent(name='test_agent')
|
||||
assert isinstance(agent.canonical_model, expected_model_type)
|
||||
assert agent.canonical_model.model == expected_model_name
|
||||
finally:
|
||||
LlmAgent.set_default_model(original_default)
|
||||
|
||||
|
||||
def test_canonical_model_str():
|
||||
|
||||
Reference in New Issue
Block a user