veadk-python 0.2.15__py3-none-any.whl → 0.2.17__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- veadk/a2a/remote_ve_agent.py +56 -1
- veadk/agent.py +118 -26
- veadk/agents/loop_agent.py +22 -9
- veadk/agents/parallel_agent.py +21 -9
- veadk/agents/sequential_agent.py +18 -9
- veadk/auth/veauth/apmplus_veauth.py +32 -39
- veadk/auth/veauth/ark_veauth.py +3 -1
- veadk/auth/veauth/utils.py +12 -0
- veadk/auth/veauth/viking_mem0_veauth.py +91 -0
- veadk/cli/cli.py +5 -1
- veadk/cli/cli_create.py +83 -42
- veadk/cli/cli_deploy.py +36 -1
- veadk/cli/cli_eval.py +55 -0
- veadk/cli/cli_init.py +44 -3
- veadk/cli/cli_kb.py +36 -1
- veadk/cli/cli_pipeline.py +66 -1
- veadk/cli/cli_prompt.py +16 -1
- veadk/cli/cli_uploadevalset.py +15 -1
- veadk/cli/cli_web.py +35 -4
- veadk/cloud/cloud_agent_engine.py +142 -25
- veadk/cloud/cloud_app.py +219 -12
- veadk/config.py +12 -1
- veadk/configs/database_configs.py +4 -0
- veadk/configs/model_configs.py +5 -1
- veadk/configs/tracing_configs.py +2 -2
- veadk/evaluation/adk_evaluator/adk_evaluator.py +77 -17
- veadk/evaluation/base_evaluator.py +219 -3
- veadk/evaluation/deepeval_evaluator/deepeval_evaluator.py +116 -1
- veadk/evaluation/eval_set_file_loader.py +20 -0
- veadk/evaluation/eval_set_recorder.py +54 -0
- veadk/evaluation/types.py +32 -0
- veadk/evaluation/utils/prometheus.py +61 -0
- veadk/knowledgebase/backends/base_backend.py +14 -1
- veadk/knowledgebase/backends/in_memory_backend.py +10 -1
- veadk/knowledgebase/backends/opensearch_backend.py +26 -0
- veadk/knowledgebase/backends/redis_backend.py +29 -2
- veadk/knowledgebase/backends/vikingdb_knowledge_backend.py +43 -5
- veadk/knowledgebase/knowledgebase.py +173 -12
- veadk/memory/long_term_memory.py +148 -4
- veadk/memory/long_term_memory_backends/mem0_backend.py +11 -0
- veadk/memory/short_term_memory.py +119 -5
- veadk/runner.py +412 -1
- veadk/tools/builtin_tools/llm_shield.py +381 -0
- veadk/tools/builtin_tools/mcp_router.py +9 -2
- veadk/tools/builtin_tools/run_code.py +30 -6
- veadk/tools/builtin_tools/web_search.py +38 -154
- veadk/tracing/base_tracer.py +28 -1
- veadk/tracing/telemetry/attributes/extractors/common_attributes_extractors.py +105 -1
- veadk/tracing/telemetry/attributes/extractors/llm_attributes_extractors.py +260 -0
- veadk/tracing/telemetry/attributes/extractors/tool_attributes_extractors.py +69 -0
- veadk/tracing/telemetry/attributes/extractors/types.py +78 -0
- veadk/tracing/telemetry/exporters/apmplus_exporter.py +157 -0
- veadk/tracing/telemetry/exporters/base_exporter.py +8 -0
- veadk/tracing/telemetry/exporters/cozeloop_exporter.py +60 -1
- veadk/tracing/telemetry/exporters/inmemory_exporter.py +118 -1
- veadk/tracing/telemetry/exporters/tls_exporter.py +66 -0
- veadk/tracing/telemetry/opentelemetry_tracer.py +117 -4
- veadk/tracing/telemetry/telemetry.py +118 -2
- veadk/utils/misc.py +7 -0
- veadk/version.py +1 -1
- {veadk_python-0.2.15.dist-info → veadk_python-0.2.17.dist-info}/METADATA +1 -1
- {veadk_python-0.2.15.dist-info → veadk_python-0.2.17.dist-info}/RECORD +66 -64
- {veadk_python-0.2.15.dist-info → veadk_python-0.2.17.dist-info}/WHEEL +0 -0
- {veadk_python-0.2.15.dist-info → veadk_python-0.2.17.dist-info}/entry_points.txt +0 -0
- {veadk_python-0.2.15.dist-info → veadk_python-0.2.17.dist-info}/licenses/LICENSE +0 -0
- {veadk_python-0.2.15.dist-info → veadk_python-0.2.17.dist-info}/top_level.txt +0 -0
veadk/cli/cli_create.py
CHANGED
|
@@ -16,26 +16,8 @@ import click
|
|
|
16
16
|
import shutil
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
agent:
|
|
22
|
-
name: doubao-seed-1-6-251015
|
|
23
|
-
api_key: {ark_api_key}
|
|
24
|
-
video:
|
|
25
|
-
name: doubao-seedance-1-0-pro-250528
|
|
26
|
-
# if you want to use different api_key, just uncomment following line and complete api_key
|
|
27
|
-
# api_key:
|
|
28
|
-
image:
|
|
29
|
-
name: doubao-seedream-4-0-250828
|
|
30
|
-
# if you want to use different api_key, just uncomment following line and complete api_key
|
|
31
|
-
# api_key:
|
|
32
|
-
|
|
33
|
-
logging:
|
|
34
|
-
# ERROR
|
|
35
|
-
# WARNING
|
|
36
|
-
# INFO
|
|
37
|
-
# DEBUG
|
|
38
|
-
level: DEBUG
|
|
19
|
+
_ENV_TEMPLATE = """\
|
|
20
|
+
MODEL_AGENT_API_KEY={ark_api_key}
|
|
39
21
|
"""
|
|
40
22
|
|
|
41
23
|
_INIT_PY_TEMPLATE = """\
|
|
@@ -49,60 +31,119 @@ root_agent = Agent(
|
|
|
49
31
|
name="root_agent",
|
|
50
32
|
description="A helpful assistant for user questions.",
|
|
51
33
|
instruction="Answer user questions to the best of your knowledge",
|
|
34
|
+
model_name="doubao-seed-1-6-251015", # <---- you can change your model here
|
|
52
35
|
)
|
|
53
36
|
"""
|
|
54
37
|
|
|
55
38
|
_SUCCESS_MSG = """\
|
|
56
|
-
Agent
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
39
|
+
Agent created in {agent_folder}:
|
|
40
|
+
- .env
|
|
41
|
+
- __init__.py
|
|
42
|
+
- agent.py
|
|
60
43
|
|
|
61
|
-
You can run the agent by executing:
|
|
44
|
+
You can run the agent by executing: veadk web
|
|
62
45
|
"""
|
|
63
46
|
|
|
64
47
|
|
|
65
48
|
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
|
+
"""
|
|
66
59
|
click.secho(
|
|
67
60
|
"An API key is required to run the agent. See https://www.volcengine.com/docs/82379/1541594 for details.",
|
|
68
61
|
fg="green",
|
|
69
62
|
)
|
|
70
63
|
click.echo("You have two options:")
|
|
71
64
|
click.echo(" 1. Enter the API key now.")
|
|
72
|
-
click.echo(" 2. Configure it later in the generated
|
|
65
|
+
click.echo(" 2. Configure it later in the generated .env file.")
|
|
73
66
|
choice = click.prompt("Please select an option", type=click.Choice(["1", "2"]))
|
|
74
67
|
if choice == "1":
|
|
75
68
|
return click.prompt("Please enter your ARK API key")
|
|
76
69
|
else:
|
|
77
|
-
click.secho(
|
|
78
|
-
"You can set the `api_key` in the config.yaml file later.", fg="yellow"
|
|
79
|
-
)
|
|
70
|
+
click.secho("You can set the `api_key` in the .env file later.", fg="yellow")
|
|
80
71
|
return ""
|
|
81
72
|
|
|
82
73
|
|
|
83
|
-
def _generate_files(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
74
|
+
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
|
+
"""
|
|
99
|
+
target_dir_path.mkdir(exist_ok=True)
|
|
100
|
+
env_path = target_dir_path / ".env"
|
|
101
|
+
init_file_path = target_dir_path / "__init__.py"
|
|
102
|
+
agent_file_path = target_dir_path / "agent.py"
|
|
103
|
+
|
|
104
|
+
env_content = _ENV_TEMPLATE.format(ark_api_key=ark_api_key)
|
|
105
|
+
env_path.write_text(env_content)
|
|
92
106
|
init_file_path.write_text(_INIT_PY_TEMPLATE)
|
|
93
107
|
agent_file_path.write_text(_AGENT_PY_TEMPLATE)
|
|
94
108
|
|
|
95
109
|
click.secho(
|
|
96
|
-
_SUCCESS_MSG.format(
|
|
110
|
+
_SUCCESS_MSG.format(agent_folder=target_dir_path),
|
|
97
111
|
fg="green",
|
|
98
112
|
)
|
|
99
113
|
|
|
100
114
|
|
|
101
115
|
@click.command()
|
|
102
|
-
@click.
|
|
116
|
+
@click.argument("agent_name", required=False)
|
|
103
117
|
@click.option("--ark-api-key", help="The ARK API key.")
|
|
104
118
|
def create(agent_name: str, ark_api_key: str) -> None:
|
|
105
|
-
"""
|
|
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
|
+
"""
|
|
106
147
|
if not agent_name:
|
|
107
148
|
agent_name = click.prompt("Enter the agent name")
|
|
108
149
|
if not ark_api_key:
|
|
@@ -119,4 +160,4 @@ def create(agent_name: str, ark_api_key: str) -> None:
|
|
|
119
160
|
return
|
|
120
161
|
shutil.rmtree(target_dir_path)
|
|
121
162
|
|
|
122
|
-
_generate_files(
|
|
163
|
+
_generate_files(ark_api_key, target_dir_path)
|
veadk/cli/cli_deploy.py
CHANGED
|
@@ -62,7 +62,42 @@ def deploy(
|
|
|
62
62
|
use_adk_web: bool,
|
|
63
63
|
path: str,
|
|
64
64
|
) -> 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
|
+
"""
|
|
66
101
|
import asyncio
|
|
67
102
|
import shutil
|
|
68
103
|
from pathlib import Path
|
veadk/cli/cli_eval.py
CHANGED
|
@@ -64,6 +64,61 @@ def eval(
|
|
|
64
64
|
volcengine_access_key: str,
|
|
65
65
|
volcengine_secret_key: str,
|
|
66
66
|
) -> 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
|
+
"""
|
|
67
122
|
import asyncio
|
|
68
123
|
import os
|
|
69
124
|
from pathlib import Path
|
veadk/cli/cli_init.py
CHANGED
|
@@ -25,6 +25,14 @@ warnings.filterwarnings(
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
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
|
+
"""
|
|
28
36
|
vefaas_application_name = click.prompt(
|
|
29
37
|
"Volcengine FaaS application name", default="veadk-cloud-agent"
|
|
30
38
|
)
|
|
@@ -71,9 +79,42 @@ def _render_prompts() -> dict[str, Any]:
|
|
|
71
79
|
def init(
|
|
72
80
|
vefaas_template_type: str,
|
|
73
81
|
) -> None:
|
|
74
|
-
"""
|
|
75
|
-
|
|
76
|
-
|
|
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
|
|
77
118
|
"""
|
|
78
119
|
import shutil
|
|
79
120
|
from pathlib import Path
|
veadk/cli/cli_kb.py
CHANGED
|
@@ -48,7 +48,42 @@ def add(
|
|
|
48
48
|
index: str,
|
|
49
49
|
path: str,
|
|
50
50
|
):
|
|
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
|
+
"""
|
|
52
87
|
_path = Path(path)
|
|
53
88
|
assert _path.exists(), f"Path {path} not exists. Please check your input."
|
|
54
89
|
|
veadk/cli/cli_pipeline.py
CHANGED
|
@@ -37,6 +37,18 @@ warnings.filterwarnings(
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
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
|
+
"""
|
|
40
52
|
vecr = VeCR(
|
|
41
53
|
access_key=volcengine_settings["volcengine_access_key"],
|
|
42
54
|
secret_key=volcengine_settings["volcengine_secret_key"],
|
|
@@ -137,7 +149,60 @@ def pipeline(
|
|
|
137
149
|
cr_repo_name: str,
|
|
138
150
|
vefaas_function_id: str,
|
|
139
151
|
) -> None:
|
|
140
|
-
"""Integrate a
|
|
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
|
+
"""
|
|
141
206
|
|
|
142
207
|
click.echo(
|
|
143
208
|
"Welcome use VeADK to integrate your project to volcengine pipeline for CI/CD."
|
veadk/cli/cli_prompt.py
CHANGED
|
@@ -30,7 +30,22 @@ import click
|
|
|
30
30
|
def prompt(
|
|
31
31
|
path: str, feedback: str, api_key: str, workspace_id: str, model_name: str
|
|
32
32
|
) -> 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
|
+
"""
|
|
34
49
|
from pathlib import Path
|
|
35
50
|
|
|
36
51
|
from veadk.agent import Agent
|
veadk/cli/cli_uploadevalset.py
CHANGED
|
@@ -37,7 +37,21 @@ def uploadevalset(
|
|
|
37
37
|
cozeloop_evalset_id: str,
|
|
38
38
|
cozeloop_api_key: str,
|
|
39
39
|
) -> 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
|
+
"""
|
|
41
55
|
|
|
42
56
|
if not cozeloop_workspace_id:
|
|
43
57
|
cozeloop_workspace_id = getenv(
|
veadk/cli/cli_web.py
CHANGED
|
@@ -23,7 +23,14 @@ logger = get_logger(__name__)
|
|
|
23
23
|
|
|
24
24
|
def patch_adkwebserver_disable_openapi():
|
|
25
25
|
"""
|
|
26
|
-
Monkey patch AdkWebServer
|
|
26
|
+
Monkey patch AdkWebServer to disable OpenAPI documentation endpoints.
|
|
27
|
+
|
|
28
|
+
This function patches the AdkWebServer.get_fast_api_app method to remove
|
|
29
|
+
OpenAPI-related routes (/openapi.json, /docs, /redoc) from the FastAPI
|
|
30
|
+
application for security and simplicity purposes.
|
|
31
|
+
|
|
32
|
+
The patch is applied by replacing the original method with a wrapped version
|
|
33
|
+
that filters out the unwanted routes after the FastAPI app is created.
|
|
27
34
|
"""
|
|
28
35
|
import google.adk.cli.adk_web_server
|
|
29
36
|
from fastapi.routing import APIRoute
|
|
@@ -52,7 +59,25 @@ def patch_adkwebserver_disable_openapi():
|
|
|
52
59
|
)
|
|
53
60
|
@click.pass_context
|
|
54
61
|
def web(ctx, *args, **kwargs) -> None:
|
|
55
|
-
"""
|
|
62
|
+
"""
|
|
63
|
+
Launch a web server with VeADK agent support and memory integration.
|
|
64
|
+
|
|
65
|
+
This command starts a web server that can serve VeADK agents with both
|
|
66
|
+
short-term and long-term memory capabilities. It automatically detects
|
|
67
|
+
the type of agent being loaded and configures the appropriate memory
|
|
68
|
+
services accordingly.
|
|
69
|
+
|
|
70
|
+
The function patches the ADK web server to integrate VeADK-specific
|
|
71
|
+
functionality, including memory service configuration and workflow
|
|
72
|
+
agent detection.
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
ctx: Click context object containing command line arguments
|
|
76
|
+
|
|
77
|
+
Note:
|
|
78
|
+
For workflow agents (Sequential, Loop, Parallel), individual sub-agent
|
|
79
|
+
memory configurations are not utilized as warned in the logs.
|
|
80
|
+
"""
|
|
56
81
|
from google.adk.cli import adk_web_server
|
|
57
82
|
from google.adk.runners import Runner as ADKRunner
|
|
58
83
|
|
|
@@ -107,6 +132,12 @@ def web(ctx, *args, **kwargs) -> None:
|
|
|
107
132
|
|
|
108
133
|
from google.adk.cli.cli_tools_click import cli_web
|
|
109
134
|
|
|
110
|
-
extra_args = ctx.args
|
|
111
|
-
logger.debug(f"User args: {
|
|
135
|
+
extra_args: list = ctx.args
|
|
136
|
+
logger.debug(f"User args: {extra_args}")
|
|
137
|
+
|
|
138
|
+
# set a default log level to avoid unnecessary outputs
|
|
139
|
+
# from Google ADK and Litellm
|
|
140
|
+
if "--log_level" not in extra_args:
|
|
141
|
+
extra_args.extend(["--log_level", "ERROR"])
|
|
142
|
+
|
|
112
143
|
cli_web.main(args=extra_args, standalone_mode=False)
|