8000 fix minor typos · DyProgrammerDy/adk-python@2ee1c65 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ee1c65

Browse files
fix minor typos
2 parents d057f2d + b8514f2 commit 2ee1c65

File tree

101 files changed

+2131
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+2131
-266
lines changed

.github/workflows/python-unit-tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ jobs:
2929
run: |
3030
uv venv .venv
3131
source .venv/bin/activate
32-
uv sync --extra test
32+
uv sync --extra test --extra eval
3333
3434
- name: Run unit tests with pytest
3535
run: |
3636
source .venv/bin/activate
3737
pytest tests/unittests \
3838
--ignore=tests/unittests/tools/google_api_tool/test_googleapi_to_openapi_converter.py \
39-
--ignore=tests/unittests/artifacts/test_artifact_service.py
39+
--ignore=tests/unittests/artifacts/test_artifact_service.py

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
1241
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## 0.1.0
44

55
### Features
6+
67
* Initial release of the Agent Development Kit (ADK).
78
* Multi-agent, agent-as-workflow, and custom agent support
89
* Tool authentication support

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
[![r/agentdevelopmentkit](https://img.shields.io/badge/Reddit-r%2Fagentdevelopmentkit-FF4500?style=flat&logo=reddit&logoColor=white)](https://www.reddit.com/r/agentdevelopmentkit/)
66

77
<html>
8-
<h1 align="center">
9-
<img src="assets/agent-development-kit.png" width="256"/>
10-
</h1>
8+
<h2 align="center">
9+
<img src="https://raw.githubusercontent.com/google/adk-python/main/assets/agent-development-kit.png" width="256"/>
10+
</h2>
1111
<h3 align="center">
1212
An open-source, code-first Python toolkit for building, evaluating, and deploying sophisticated AI agents with flexibility and control.
1313
</h3>
@@ -50,6 +50,7 @@ You can install the ADK using `pip`:
5050
```bash
5151
pip install google-adk
5252
```
53+
5354
## 📚 Documentation
5455

5556
Explore the full documentation for detailed guides on building, evaluating, and
@@ -60,6 +61,7 @@ deploying agents:
6061
## 🏁 Feature Highlight
6162

6263
### Define a single agent:
64+
6365
```python
6466
from google.adk.agents import Agent
6567
from google.adk.tools import google_search
@@ -74,7 +76,9 @@ root_agent = Agent(
7476
```
7577

7678
### Define a multi-agent system:
79+
7780
Define a multi-agent system with coordinator agent, greeter agent, and task execution agent. Then ADK engine and the model will guide the agents works together to accomplish the task.
81+
7882
```python
7983
from google.adk.agents import LlmAgent, BaseAgent
8084

@@ -92,14 +96,13 @@ coordinator = LlmAgent(
9296
task_executor
9397
]
9498
)
95-
9699
```
97100

98101
### Development UI
99102

100103
A built-in development UI to help you test, evaluate, debug, and showcase your agent(s).
101104

102-
<img src="assets/adk-web-dev-ui-function-call.png"/>
105+
<img src="https://raw.githubusercontent.com/google/adk-python/main/assets/adk-web-dev-ui-function-call.png"/>
103106

104107
### Evaluate Agents
105108

src/google/adk/cli/browser/index.html

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/google/adk/cli/browser/main-SLIAU2JL.js renamed to src/google/adk/cli/browser/main-ZBO76GRM.js

Lines changed: 65 additions & 81 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/google/adk/cli/cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ async def run_interactively(
8282
)
8383
while True:
8484
query = input('user: ')
85+
if not query or not query.strip():
86+
continue
8587
if query == 'exit':
8688
break
8789
async for event in runner.run_async(

src/google/adk/cli/cli_create.py

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import os
16+
import subprocess
17+
from typing import Optional
18+
from typing import Tuple
19+
20+
import click
21+
22+
_INIT_PY_TEMPLATE = """\
23+
from . import agent
24+
"""
25+
26+
_AGENT_PY_TEMPLATE = """\
27+
from google.adk.agents import Agent
28+
29+
root_agent = Agent(
30+
model='{model_name}',
31+
name='root_agent',
32+
description='A helpful assistant for user questions.',
33+
instruction='Answer user questions to the best of your knowledge',
34+
)
35+
"""
36+
37+
38+
_GOOGLE_API_MSG = """
39+
Don't have API Key? Create one in AI Studio: https://aistudio.google.com/apikey
40+
"""
41+
42+
_GOOGLE_CLOUD_SETUP_MSG = """
43+
You need an existing Google Cloud account and project, check out this link for details:
44+
https://google.github.io/adk-docs/get-started/quickstart/#gemini---google-cloud-vertex-ai
45+
"""
46+
47+
_OTHER_MODEL_MSG = """
48+
Please see below guide to configure other models:
49+
https://google.github.io/adk-docs/agents/models
50+
"""
51+
52+
_SUCCESS_MSG = """
53+
Agent created in {agent_folder}:
54+
- .env
55+
- __init__.py
56+
- agent.py
57+
"""
58+
59+
60+
def _get_gcp_project_from_gcloud() -> str:
61+
"""Uses gcloud to get default project."""
62+
try:
63+
result = subprocess.run(
64+
["gcloud", "config", "get-value", "project"],
65+
capture_output=True,
66+
text=True,
67+
check=True,
68+
)
69+
return result.stdout.strip()
70+
except (subprocess.CalledProcessError, FileNotFoundError):
71+
return ""
72+
73+
74+
def _get_gcp_region_from_gcloud() -> str:
75+
"""Uses gcloud to get default region."""
76+
try:
77+
result = subprocess.run(
78+
["gcloud", "config", "get-value", "compute/region"],
79+
capture_output=True,
80+
text=True,
81+
check=True,
82+
)
83+
return result.stdout.strip()
84+
except (subprocess.CalledProcessError, FileNotFoundError):
85+
return ""
86+
87+
88+
def _prompt_str(
89+
prompt_prefix: str,
90+
*,
91+
prior_msg: Optional[str] = None,
92+
default_value: Optional[str] = None,
93+
) -> str:
94+
if prior_msg:
95+
click.secho(prior_msg, fg="green")
96+
while True:
97+
value: str = click.prompt(
98+
prompt_prefix, default=default_value or None, type=str
99+
)
100+
if value and value.strip():
101+
return value.strip()
102+
103+
104+
def _prompt_for_google_cloud(
105+
google_cloud_project: Optional[str],
106+
) -> str:
107+
"""Prompts user for Google Cloud project ID."""
108+
google_cloud_project = (
109+
google_cloud_project
110+
or os.environ.get("GOOGLE_CLOUD_PROJECT", None)
111+
or _get_gcp_project_from_gcloud()
112+
)
113+
114+
google_cloud_project = _prompt_str(
115+
"Enter Google Cloud project ID", default_value=google_cloud_project
116+
)
117+
118+
return google_cloud_project
119+
120+
121+
def _prompt_for_google_cloud_region(
122+
google_cloud_region: Optional[str],
123+
) -> str:
124+
"""Prompts user for Google Cloud region."""
125+
google_cloud_region = (
126+
google_cloud_region
127+
or os.environ.get("GOOGLE_CLOUD_LOCATION", None)
128+
or _get_gcp_region_from_gcloud()
129+
)
130+
131+
google_cloud_region = _prompt_str(
132+
"Enter Google Cloud region",
133+
default_value=google_cloud_region or "us-central1",
134+
)
135+
return google_cloud_region
136+
137+
138+
def _prompt_for_google_api_key(
139+
google_api_key: Optional[str],
140+
) -> str:
141+
"""Prompts user for Google API key."""
142+
google_api_key = google_api_key or os.environ.get("GOOGLE_API_KEY", None)
143+
144+
google_api_key = _prompt_str(
145+
"Enter Google API key",
146+
prior_msg=_GOOGLE_API_MSG,
147+
default_value=google_api_key,
148+
)
149+
return google_api_key
150+
151+
152+
def _generate_files(
153+
agent_folder: str,
154+
*,
155+
google_api_key: Optional[str] = None,
156+
google_cloud_project: Optional[str] = None,
157+
google_cloud_region: Optional[str] = None,
158+
model: Optional[str] = None,
159+
):
160+
"""Generates a folder name for the agent."""
161+
os.makedirs(agent_folder, exist_ok=True)
162+
163+
dotenv_file_path = os.path.join(agent_folder, ".env")
164+
init_file_path = os.path.join(agent_folder, "__init__.py")
165+
agent_file_path = os.path.join(agent_folder, "agent.py")
166+
167+
with open(dotenv_file_path, "w", encoding="utf-8") as f:
168+
lines = []
169+
if google_api_key:
170+
lines.append("GOOGLE_GENAI_USE_VERTEXAI=0")
171+
elif google_cloud_project and google_cloud_region:
172+
lines.append("GOOGLE_GENAI_USE_VERTEXAI=1")
173+
if google_api_key:
174+
lines.append(f"GOOGLE_API_KEY={google_api_key}")
175+
if google_cloud_project:
176+
lines.append(f"GOOGLE_CLOUD_PROJECT={google_cloud_project}")
177+
if google_cloud_region:
178+
lines.append(f"GOOGLE_CLOUD_LOCATION={google_cloud_region}")
179+
f.write("\n".join(lines))
180+
181+
with open(init_file_path, "w", encoding="utf-8") as f:
182+
f.write(_INIT_PY_TEMPLATE)
183+
184+
with open(agent_file_path, "w", encoding="utf-8") as f:
185+
f.write(_AGENT_PY_TEMPLATE.format(model_name=model))
186+
187+
click.secho(
188+
_SUCCESS_MSG.format(agent_folder=agent_folder),
189+
fg="green",
190+
)
191+
192+
193+
def _prompt_for_model() -> str:
194+
model_choice = click.prompt(
195+
"""\
196+
Choose a model for the root agent:
197+
1. gemini-2.0-flash-001
198+
2. Other models (fill later)
199+
Choose model""",
200+
type=click.Choice(["1", "2"]),
201+
)
202+
if model_choice == "1":
203+
return "gemini-2.0-flash-001"
204+
else:
205+
click.secho(_OTHER_MODEL_MSG, fg="green")
206+
return "<FILL_IN_MODEL>"
207+
208+
209+
def _prompt_to_choose_backend(
210+
google_api_key: Optional[str],
211+
google_cloud_project: Optional[str],
212+
google_cloud_region: Optional[str],
213+
) -> Tuple[Optional[str], Optional[str], Optional[str]]:
214+
"""Prompts user to choose backend.
215+
216+
Returns:
217+
A tuple of (google_api_key, google_cloud_project, google_cloud_region).
218+
"""
219+
backend_choice = click.prompt(
220+
"1. Google AI\n2. Vertex AI\nChoose a backend",
221+
type=click.Choice(["1", "2"]),
222+
)
223+
if backend_choice == "1":
224+
google_api_key = _prompt_for_google_api_key(google_api_key)
225+
elif backend_choice == "2":
226+
click.secho(_GOOGLE_CLOUD_SETUP_MSG, fg="green")
227+
google_cloud_project = _prompt_for_google_cloud(google_cloud_project)
228+
google_cloud_region = _prompt_for_google_cloud_region(google_cloud_region)
229+
return google_api_key, google_cloud_project, google_cloud_region
230+
231+
232+
def run_cmd(
233+
agent_name: str,
234+
*,
235+
model: Optional[str],
236+
google_api_key: Optional[str],
237+
google_cloud_project: Optional[str],
238+
google_cloud_region: Optional[str],
239+
):
240+
"""Runs `adk create` command to create agent template.
241+
242+
Args:
243+
agent_name: str, The name of the agent.
244+
google_api_key: Optional[str], The Google API key for using Google AI as
245+
backend.
246+
google_cloud_project: Optional[str], The Google Cloud project for using
247+
VertexAI as backend.
248+
google_cloud_region: Optional[str], The Google Cloud region for using
249+
VertexAI as backend.
250+
"""
251+
agent_folder = os.path.join(os.getcwd(), agent_name)
252+
# check folder doesn't exist or it's empty. Otherwise, throw
253+
if os.path.exists(agent_folder) and os.listdir(agent_folder):
254+
# Prompt user whether to override existing files using click
255+
if not click.confirm(
256+
f"Non-empty folder already exist: '{agent_folder}'\n"
257+
"Override existing content?",
258+
default=False,
259+
):
260+
raise click.Abort()
261+
262+
if not model:
263+
model = _prompt_for_model()
264+
265+
if not google_api_key and not (google_cloud_project and google_cloud_region):
266+
if model.startswith("gemini"):
267+
google_api_key, google_cloud_project, google_cloud_region = (
268+
_prompt_to_choose_backend(
269+
google_api_key, google_cloud_project, google_cloud_region
270+
)
271+
)
272+
273+
_generate_files(
274+
agent_folder,
275+
google_api_key=google_api_key,
276+
google_cloud_project=google_cloud_project,
277+
google_cloud_region=google_cloud_region,
278+
model=model,
279+
)

0 commit comments

Comments
 (0)
0