mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
feat(config): add --type flag to adk create to allow starting with config
Updated the `adk create` default model version to gemini-2.5-flash. PiperOrigin-RevId: 788589859
This commit is contained in:
committed by
Copybara-Service
parent
2f73cfde18
commit
bcac9ba44c
@@ -147,9 +147,53 @@ def test_run_cmd_overwrite_reject(
|
||||
google_api_key=None,
|
||||
google_cloud_project=None,
|
||||
google_cloud_region=None,
|
||||
type=cli_create.Type.CODE,
|
||||
)
|
||||
|
||||
|
||||
def test_run_cmd_with_type_config(
|
||||
monkeypatch: pytest.MonkeyPatch, tmp_path: Path
|
||||
) -> None:
|
||||
"""run_cmd with --type=config should generate YAML config file."""
|
||||
agent_name = "test_agent"
|
||||
|
||||
monkeypatch.setattr(os, "getcwd", lambda: str(tmp_path))
|
||||
monkeypatch.setattr(os.path, "exists", lambda _p: False)
|
||||
|
||||
cli_create.run_cmd(
|
||||
agent_name,
|
||||
model="gemini-2.0-flash-001",
|
||||
google_api_key="test-key",
|
||||
google_cloud_project=None,
|
||||
google_cloud_region=None,
|
||||
type=cli_create.Type.CONFIG,
|
||||
)
|
||||
|
||||
agent_dir = tmp_path / agent_name
|
||||
assert agent_dir.exists()
|
||||
|
||||
# Should create root_agent.yaml instead of agent.py
|
||||
yaml_file = agent_dir / "root_agent.yaml"
|
||||
assert yaml_file.exists()
|
||||
assert not (agent_dir / "agent.py").exists()
|
||||
|
||||
# Check YAML content
|
||||
yaml_content = yaml_file.read_text()
|
||||
assert "name: root_agent" in yaml_content
|
||||
assert "model: gemini-2.0-flash-001" in yaml_content
|
||||
assert "description: A helpful assistant for user questions." in yaml_content
|
||||
|
||||
# Should create empty __init__.py
|
||||
init_file = agent_dir / "__init__.py"
|
||||
assert init_file.exists()
|
||||
assert init_file.read_text().strip() == ""
|
||||
|
||||
# Should still create .env file
|
||||
env_file = agent_dir / ".env"
|
||||
assert env_file.exists()
|
||||
assert "GOOGLE_API_KEY=test-key" in env_file.read_text()
|
||||
|
||||
|
||||
# Prompt helpers
|
||||
def test_prompt_for_google_cloud(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Prompt should return the project input."""
|
||||
@@ -174,7 +218,7 @@ def test_prompt_for_google_api_key(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
def test_prompt_for_model_gemini(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
"""Selecting option '1' should return the default Gemini model string."""
|
||||
monkeypatch.setattr(click, "prompt", lambda *a, **k: "1")
|
||||
assert cli_create._prompt_for_model() == "gemini-2.0-flash-001"
|
||||
assert cli_create._prompt_for_model() == "gemini-2.5-flash"
|
||||
|
||||
|
||||
def test_prompt_for_model_other(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
|
||||
Reference in New Issue
Block a user