Skip to content

Commit 0470b07

Browse files
committed
chore: add docstrings for cli and tracing module
1 parent 37c3702 commit 0470b07

22 files changed

+1540
-19
lines changed

veadk/cli/cli.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@
3232
version=VERSION, prog_name="Volcengine Agent Development Kit (VeADK)"
3333
)
3434
def veadk():
35-
"""Volcengine ADK command line tools"""
35+
"""Volcengine Agent Development Kit (VeADK) command line interface.
36+
37+
This is the main entry point for all VeADK CLI commands. VeADK provides
38+
tools for developing, deploying, and managing AI agents on the Volcengine platform.
39+
"""
3640
pass
3741

3842

veadk/cli/cli_create.py

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@
4646

4747

4848
def _prompt_for_ark_api_key() -> str:
49+
"""Prompt user to enter ARK API key with guidance and options.
50+
51+
Displays instructions for obtaining an ARK API key and provides the user
52+
with two options: enter the key immediately or configure it later in the
53+
generated .env file. Includes helpful documentation links and clear choices.
54+
55+
Returns:
56+
str: The ARK API key entered by the user, or empty string if they
57+
choose to configure it later
58+
"""
4959
click.secho(
5060
"An API key is required to run the agent. See https://www.volcengine.com/docs/82379/1541594 for details.",
5161
fg="green",
@@ -62,6 +72,30 @@ def _prompt_for_ark_api_key() -> str:
6272

6373

6474
def _generate_files(ark_api_key: str, target_dir_path: Path) -> None:
75+
"""Generate agent project files from templates in the target directory.
76+
77+
Creates the essential files for a new VeADK agent project including
78+
environment configuration, Python package initialization, and the main
79+
agent definition file. Uses predefined templates to ensure consistent
80+
project structure and proper configuration.
81+
82+
Args:
83+
ark_api_key: ARK API key to be written to the .env file for
84+
model authentication. Can be empty string if not provided
85+
target_dir_path: Path object pointing to the target directory
86+
where files should be created
87+
88+
Files Created:
89+
- .env: Environment file with ARK API key configuration
90+
- __init__.py: Python package initialization file
91+
- agent.py: Main agent definition with default configuration
92+
93+
Note:
94+
- Creates target directory if it doesn't exist
95+
- Overwrites existing files without warning
96+
- Uses template formatting to inject API key into .env file
97+
- Displays success message with project location after completion
98+
"""
6599
target_dir_path.mkdir(exist_ok=True)
66100
env_path = target_dir_path / ".env"
67101
init_file_path = target_dir_path / "__init__.py"
@@ -82,7 +116,34 @@ def _generate_files(ark_api_key: str, target_dir_path: Path) -> None:
82116
@click.argument("agent_name", required=False)
83117
@click.option("--ark-api-key", help="The ARK API key.")
84118
def create(agent_name: str, ark_api_key: str) -> None:
85-
"""Creates a new agent in the current folder with prepopulated agent template."""
119+
"""Create a new VeADK agent project with prepopulated template files.
120+
121+
This command creates a new agent project directory with all necessary
122+
files to get started with VeADK agent development. It sets up a complete
123+
project structure including environment configuration, agent definition,
124+
and package initialization.
125+
126+
The command handles interactive prompts for missing parameters and provides
127+
safety checks for existing directories to prevent accidental overwrites.
128+
129+
Project Structure Created:
130+
agent_name/
131+
├── .env # Environment configuration with API key
132+
├── __init__.py # Python package initialization
133+
└── agent.py # Main agent definition with default settings
134+
135+
Args:
136+
agent_name: Name of the agent and directory to create. If not provided
137+
as an argument, the user will be prompted to enter it interactively
138+
ark_api_key: ARK API key for model authentication. If not provided,
139+
the user will be prompted with options to enter it or configure later
140+
141+
Note:
142+
- Agent name becomes both the directory name and project identifier
143+
- API key can be configured later by editing the .env file
144+
- Generated agent is immediately runnable with 'veadk web' command
145+
- Template includes comments guiding users to customize model settings
146+
"""
86147
if not agent_name:
87148
agent_name = click.prompt("Enter the agent name")
88149
if not ark_api_key:

veadk/cli/cli_deploy.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,42 @@ def deploy(
6262
use_adk_web: bool,
6363
path: str,
6464
) -> None:
65-
"""Deploy a user project to Volcengine FaaS application."""
65+
"""Deploy a user project to Volcengine FaaS application.
66+
67+
This command deploys a VeADK agent project to Volcengine's Function as a Service (FaaS)
68+
platform. It creates a deployment package from the local project, configures the necessary
69+
cloud resources, and manages the deployment process including template generation,
70+
file copying, and cloud resource provisioning.
71+
72+
The deployment process includes:
73+
1. Creating a temporary deployment package using cookiecutter templates
74+
2. Copying the user's project files to the deployment structure
75+
3. Processing configuration files and requirements
76+
4. Executing the deployment to Volcengine FaaS
77+
5. Cleaning up temporary files
78+
79+
Args:
80+
access_key: Volcengine access key for API authentication. If not provided,
81+
will use VOLCENGINE_ACCESS_KEY environment variable
82+
secret_key: Volcengine secret key for API authentication. If not provided,
83+
will use VOLCENGINE_SECRET_KEY environment variable
84+
vefaas_app_name: Name of the target Volcengine FaaS application where the
85+
project will be deployed
86+
veapig_instance_name: Optional Volcengine API Gateway instance name for
87+
external API access configuration
88+
veapig_service_name: Optional Volcengine API Gateway service name
89+
veapig_upstream_name: Optional Volcengine API Gateway upstream name
90+
short_term_memory_backend: Backend type for short-term memory storage.
91+
Choices are 'local' or 'mysql'
92+
use_adk_web: Flag to enable ADK Web interface for the deployed agent
93+
path: Local directory path containing the VeADK project to deploy
94+
95+
Note:
96+
- The function automatically processes and copies requirements.txt if present in the project
97+
- config.yaml files are excluded from deployment for security reasons
98+
- Temporary files are created in /tmp and cleaned up after deployment
99+
- The deployment uses cookiecutter templates for standardized project structure
100+
"""
66101
import asyncio
67102
import shutil
68103
from pathlib import Path

veadk/cli/cli_eval.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,61 @@ def eval(
6464
volcengine_access_key: str,
6565
volcengine_secret_key: str,
6666
) -> None:
67+
"""Evaluate an agent using specified evaluation datasets and metrics.
68+
69+
This command provides comprehensive agent evaluation capabilities using either Google ADK
70+
or DeepEval frameworks. It supports both local agent evaluation (from source code) and
71+
remote agent evaluation (via A2A deployment URLs), making it flexible for different
72+
development and deployment scenarios.
73+
74+
The evaluation process includes:
75+
1. Loading the target agent from local directory or remote A2A endpoint
76+
2. Configuring the evaluation environment and credentials
77+
3. Setting up the chosen evaluator with appropriate metrics
78+
4. Running evaluation tests against the provided dataset
79+
5. Generating detailed performance reports and scores
80+
81+
Evaluation Modes:
82+
- Local Evaluation: Loads agent code from a local directory containing 'agent.py'
83+
with exported 'root_agent' variable. Suitable for development and testing.
84+
- Remote Evaluation: Connects to a deployed agent via A2A (Agent-to-Agent) URL.
85+
Ideal for evaluating production deployments or distributed agents.
86+
87+
Evaluator Options:
88+
- ADK Evaluator: Uses Google's Agent Development Kit evaluation framework.
89+
Provides standardized metrics and comprehensive evaluation reports.
90+
- DeepEval: Advanced evaluation framework with customizable metrics including
91+
GEval for general performance and ToolCorrectnessMetric for tool usage accuracy.
92+
93+
Args:
94+
agent_dir: Local directory path containing the agent implementation.
95+
Must include an 'agent.py' file with exported 'root_agent' variable.
96+
Defaults to current directory if not specified
97+
agent_a2a_url: Complete URL of the deployed agent in A2A mode.
98+
If provided alongside agent_dir, this URL takes precedence
99+
evalset_file: Path to the evaluation dataset file in Google ADK format.
100+
Should contain test cases with inputs, expected outputs, and metadata
101+
evaluator: Evaluation framework to use. Available options:
102+
- 'adk': Google ADK evaluator with built-in metrics
103+
- 'deepeval': Advanced evaluator with customizable metrics and thresholds
104+
judge_model_name: Name of the language model used for evaluation judgment.
105+
Defaults to 'doubao-1-5-pro-256k-250115'. Only applicable for DeepEval;
106+
ignored when using ADK evaluator
107+
volcengine_access_key: Volcengine platform access key for model authentication.
108+
If not provided, uses VOLCENGINE_ACCESS_KEY environment variable
109+
volcengine_secret_key: Volcengine platform secret key for model authentication.
110+
If not provided, uses VOLCENGINE_SECRET_KEY environment variable
111+
112+
Note:
113+
- At least one of --agent-dir or --agent-a2a-url must be provided
114+
- If both are provided, --agent-a2a-url takes precedence
115+
- Judge model name is ignored when using ADK evaluator
116+
- Evaluation results are logged and may be saved to output files
117+
118+
Raises:
119+
ImportError: If DeepEval dependencies are not installed when using DeepEval evaluator.
120+
ValueError: If neither agent_dir nor agent_a2a_url is provided.
121+
"""
67122
import asyncio
68123
import os
69124
from pathlib import Path

veadk/cli/cli_init.py

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525

2626

2727
def _render_prompts() -> dict[str, Any]:
28+
"""Render interactive prompts to collect user configuration for project initialization.
29+
30+
This function prompts the user for various configuration options including
31+
Volcengine FaaS application name, API Gateway settings, and deployment mode.
32+
33+
Returns:
34+
dict[str, Any]: A dictionary containing all the collected configuration values
35+
"""
2836
vefaas_application_name = click.prompt(
2937
"Volcengine FaaS application name", default="veadk-cloud-agent"
3038
)
@@ -71,9 +79,42 @@ def _render_prompts() -> dict[str, Any]:
7179
def init(
7280
vefaas_template_type: str,
7381
) -> None:
74-
"""Init a veadk project that can be deployed to Volcengine VeFaaS.
75-
76-
`template` is A2A/MCP/Web server template, `web_template` is for web applications (i.e., a simple blog).
82+
"""Initialize a new VeADK project that can be deployed to Volcengine FaaS.
83+
84+
This command creates a new VeADK project from predefined templates using an interactive
85+
setup process. It generates a complete project structure with all necessary files,
86+
configurations, and deployment scripts ready for Volcengine cloud deployment.
87+
88+
The initialization process includes:
89+
1. Interactive prompts for collecting deployment configuration
90+
2. Template selection based on the specified template type
91+
3. Project directory creation with proper structure
92+
4. Configuration file generation with user preferences
93+
5. Ready-to-use deployment scripts and source code structure
94+
95+
Available template types:
96+
- 'template' (default): Creates an A2A/MCP/Web server template with a weather-reporter
97+
example application. Suitable for most agent development scenarios.
98+
- 'web_template': Creates a web application template with a simple-blog example.
99+
Designed for web-based agent applications with UI components.
100+
101+
The generated project structure includes:
102+
- src/ directory containing agent source code
103+
- deploy.py script for cloud deployment
104+
- Configuration files for various deployment scenarios
105+
- Example implementations based on the selected template
106+
107+
Args:
108+
vefaas_template_type: The type of template to use for project initialization.
109+
Defaults to 'template'. Valid options are:
110+
- 'template': Standard agent template (weather-reporter example)
111+
- 'web_template': Web application template (simple-blog example)
112+
113+
Note:
114+
- If the target directory already exists, you will be prompted to confirm overwrite
115+
- The generated project includes example code that can be modified for your use case
116+
- All deployment configurations can be customized after project creation
117+
- The deploy.py script provides automated deployment to Volcengine FaaS platform
77118
"""
78119
import shutil
79120
from pathlib import Path

veadk/cli/cli_kb.py

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,42 @@ def add(
4848
index: str,
4949
path: str,
5050
):
51-
"""Add files to knowledgebase"""
51+
"""Add files to knowledgebase.
52+
53+
This command adds files or directories to a specified knowledgebase backend.
54+
It supports various backend types including local storage, OpenSearch, Viking,
55+
and Redis for storing and indexing knowledge content.
56+
57+
Args:
58+
backend: The knowledgebase backend type to use for storing and indexing documents.
59+
Available options:
60+
- 'local': Local file-based storage using SQLite. Suitable for development
61+
and small-scale deployments. No external dependencies required.
62+
- 'opensearch': Elasticsearch-compatible search engine with advanced
63+
full-text search and vector similarity capabilities. Recommended for
64+
production environments with large document collections.
65+
- 'viking': Volcengine's managed vector database service optimized for
66+
semantic search and RAG applications. Provides high performance and
67+
automatic scaling on Volcengine cloud platform.
68+
- 'redis': In-memory data structure store with vector search capabilities.
69+
Fast retrieval but limited by memory capacity. Good for frequently
70+
accessed, smaller knowledge bases.
71+
app_name: Application identifier for organizing and isolating knowledgebase
72+
data. Used to create logical separation between different applications
73+
or environments. Must be consistent across operations for the same knowledge base.
74+
index: Knowledgebase index identifier within the application namespace.
75+
Acts as a unique name for this specific knowledge collection. Multiple
76+
indexes can exist under the same app_name for different knowledge domains.
77+
Index names should be descriptive and follow naming conventions of the chosen backend.
78+
path: File system path to the knowledge content to be added to the knowledge base.
79+
Supported formats:
80+
- Single file: Path to a specific document (PDF, TXT, MD, DOCX, etc.)
81+
- Directory: Path to a folder containing multiple documents. All supported
82+
files in the directory will be processed recursively.
83+
84+
Raises:
85+
RuntimeError: If the file type is not supported
86+
"""
5287
_path = Path(path)
5388
assert _path.exists(), f"Path {path} not exists. Please check your input."
5489

veadk/cli/cli_pipeline.py

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,18 @@
3737

3838

3939
def _create_cr(volcengine_settings: dict[str, str], cr_settings: dict[str, str]):
40+
"""Create Container Registry (CR) resources including instance, namespace, and repository.
41+
42+
This helper function creates the necessary Container Registry infrastructure
43+
on Volcengine cloud platform for storing Docker images used in the CI/CD pipeline.
44+
45+
Args:
46+
volcengine_settings: Dictionary containing Volcengine credentials and region
47+
cr_settings: Dictionary containing CR instance, namespace, and repo configuration
48+
49+
Raises:
50+
Exception: If any of the CR resource creation operations fail
51+
"""
4052
vecr = VeCR(
4153
access_key=volcengine_settings["volcengine_access_key"],
4254
secret_key=volcengine_settings["volcengine_secret_key"],
@@ -137,7 +149,60 @@ def pipeline(
137149
cr_repo_name: str,
138150
vefaas_function_id: str,
139151
) -> None:
140-
"""Integrate a veadk project to volcengine pipeline for CI/CD"""
152+
"""Integrate a VeADK project with Volcengine pipeline for automated CI/CD deployment.
153+
154+
This command sets up a complete CI/CD pipeline that automatically builds, containerizes,
155+
and deploys your VeADK agent project whenever changes are pushed to the specified GitHub
156+
repository. It creates all necessary cloud infrastructure including Container Registry
157+
resources, FaaS functions, and pipeline configurations.
158+
159+
The pipeline integration process includes:
160+
1. Creating Container Registry (CR) infrastructure (instance, namespace, repository)
161+
2. Setting up or using existing VeFaaS function for deployment target
162+
3. Configuring Volcengine Code Pipeline with GitHub integration
163+
4. Establishing automated build and deployment workflows
164+
5. Linking all components for seamless CI/CD operation
165+
166+
Pipeline Workflow:
167+
- Code changes pushed to GitHub trigger the pipeline
168+
- Source code is automatically pulled from the specified branch
169+
- Docker image is built using the specified VeADK base image
170+
- Built image is pushed to Volcengine Container Registry
171+
- VeFaaS function is updated with the new container image
172+
- Deployment completion notifications are provided
173+
174+
Args:
175+
veadk_version: Base VeADK image version for containerization. Can be:
176+
- 'preview': Latest preview/development version
177+
- 'latest': Latest stable release
178+
- Specific version (e.g., '1.0.0'): Pinned version for consistency
179+
github_url: Complete GitHub repository URL containing your VeADK project.
180+
Must be accessible with the provided GitHub token
181+
github_branch: Target branch to monitor for changes and deploy from.
182+
Typically 'main', 'master', or your preferred deployment branch
183+
github_token: GitHub personal access token with repository access permissions.
184+
Required for pipeline to access and monitor your repository
185+
volcengine_access_key: Volcengine cloud platform access key for authentication.
186+
If not provided, uses VOLCENGINE_ACCESS_KEY environment variable
187+
volcengine_secret_key: Volcengine cloud platform secret key for authentication.
188+
If not provided, uses VOLCENGINE_SECRET_KEY environment variable
189+
region: Volcengine cloud region for all resources (VeFaaS, CR, Pipeline).
190+
Defaults to 'cn-beijing'. Choose region closest to your users
191+
cr_instance_name: Name for the Container Registry instance that will store
192+
your Docker images. Defaults to 'veadk-user-instance'
193+
cr_namespace_name: Namespace within the Container Registry for organizing
194+
repositories. Defaults to 'veadk-user-namespace'
195+
cr_repo_name: Repository name within the Container Registry namespace
196+
for storing your project images. Defaults to 'veadk-user-repo'
197+
vefaas_function_id: Existing VeFaaS function ID to update with new deployments.
198+
If not provided, a new function will be created automatically
199+
200+
Note:
201+
- GitHub token must have appropriate permissions for repository access
202+
- All Volcengine resources will be created in the specified region
203+
- The pipeline will be triggered immediately upon creation for initial deployment
204+
- Subsequent deployments occur automatically when code is pushed to the monitored branch
205+
"""
141206

142207
click.echo(
143208
"Welcome use VeADK to integrate your project to volcengine pipeline for CI/CD."

0 commit comments

Comments
 (0)