Skip to content

Commit 09ab58b

Browse files
committed
chore: add docstrings for cli and tracing module
1 parent 8eed1be commit 09ab58b

21 files changed

+1512
-19
lines changed

veadk/cli/cli.py

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

3741

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."

veadk/cli/cli_prompt.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,22 @@
3030
def prompt(
3131
path: str, feedback: str, api_key: str, workspace_id: str, model_name: str
3232
) -> None:
33-
"""Optimize agent system prompt from a local file."""
33+
"""Optimize agent system prompt from a local file.
34+
35+
This command uses Volcengine PromptPilot service to optimize agent system prompts
36+
based on feedback and best practices. It loads agents from a specified file and
37+
applies intelligent prompt optimization using the specified model.
38+
39+
Args:
40+
path: Path to the agent file containing global variable `agent=...`
41+
feedback: User feedback and suggestions for prompt optimization
42+
api_key: API key for accessing PromptPilot service
43+
workspace_id: Workspace ID in PromptPilot for organizing prompts
44+
model_name: Name of the model to use for prompt optimization
45+
46+
Raises:
47+
ValueError: If workspace_id is not provided when required
48+
"""
3449
from pathlib import Path
3550

3651
from veadk.agent import Agent

veadk/cli/cli_uploadevalset.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,21 @@ def uploadevalset(
3737
cozeloop_evalset_id: str,
3838
cozeloop_api_key: str,
3939
) -> None:
40-
"""Upload dataset items to CozeLoop evaluation set."""
40+
"""Upload dataset items to CozeLoop evaluation set.
41+
42+
This command uploads evaluation dataset items from a JSON file to the CozeLoop
43+
platform for agent evaluation and testing. It processes Google ADK formatted
44+
evaluation cases and converts them to CozeLoop's expected format.
45+
46+
Args:
47+
file: Path to the JSON file containing dataset items in Google ADK format.
48+
cozeloop_workspace_id: CozeLoop workspace identifier for organizing evaluation sets.
49+
If not provided, uses OBSERVABILITY_OPENTELEMETRY_COZELOOP_SERVICE_NAME environment variable.
50+
cozeloop_evalset_id: Specific evaluation set ID where items will be uploaded.
51+
If not provided, uses OBSERVABILITY_OPENTELEMETRY_COZELOOP_EVALSET_ID environment variable.
52+
cozeloop_api_key: API key for authenticating with CozeLoop services.
53+
If not provided, uses OBSERVABILITY_OPENTELEMETRY_COZELOOP_API_KEY environment variable.
54+
"""
4155

4256
if not cozeloop_workspace_id:
4357
cozeloop_workspace_id = getenv(

0 commit comments

Comments
 (0)