veadk-python 0.2.27__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/__init__.py +37 -0
- veadk/a2a/__init__.py +13 -0
- veadk/a2a/agent_card.py +45 -0
- veadk/a2a/remote_ve_agent.py +390 -0
- veadk/a2a/utils/__init__.py +13 -0
- veadk/a2a/utils/agent_to_a2a.py +170 -0
- veadk/a2a/ve_a2a_server.py +93 -0
- veadk/a2a/ve_agent_executor.py +78 -0
- veadk/a2a/ve_middlewares.py +313 -0
- veadk/a2a/ve_task_store.py +37 -0
- veadk/agent.py +402 -0
- veadk/agent_builder.py +93 -0
- veadk/agents/loop_agent.py +68 -0
- veadk/agents/parallel_agent.py +72 -0
- veadk/agents/sequential_agent.py +64 -0
- veadk/auth/__init__.py +13 -0
- veadk/auth/base_auth.py +22 -0
- veadk/auth/ve_credential_service.py +203 -0
- veadk/auth/veauth/__init__.py +13 -0
- veadk/auth/veauth/apmplus_veauth.py +58 -0
- veadk/auth/veauth/ark_veauth.py +75 -0
- veadk/auth/veauth/base_veauth.py +50 -0
- veadk/auth/veauth/cozeloop_veauth.py +13 -0
- veadk/auth/veauth/opensearch_veauth.py +75 -0
- veadk/auth/veauth/postgresql_veauth.py +75 -0
- veadk/auth/veauth/prompt_pilot_veauth.py +60 -0
- veadk/auth/veauth/speech_veauth.py +54 -0
- veadk/auth/veauth/utils.py +69 -0
- veadk/auth/veauth/vesearch_veauth.py +62 -0
- veadk/auth/veauth/viking_mem0_veauth.py +91 -0
- veadk/cli/__init__.py +13 -0
- veadk/cli/cli.py +58 -0
- veadk/cli/cli_clean.py +87 -0
- veadk/cli/cli_create.py +163 -0
- veadk/cli/cli_deploy.py +233 -0
- veadk/cli/cli_eval.py +215 -0
- veadk/cli/cli_init.py +214 -0
- veadk/cli/cli_kb.py +110 -0
- veadk/cli/cli_pipeline.py +285 -0
- veadk/cli/cli_prompt.py +86 -0
- veadk/cli/cli_update.py +106 -0
- veadk/cli/cli_uploadevalset.py +139 -0
- veadk/cli/cli_web.py +143 -0
- veadk/cloud/__init__.py +13 -0
- veadk/cloud/cloud_agent_engine.py +485 -0
- veadk/cloud/cloud_app.py +475 -0
- veadk/config.py +115 -0
- veadk/configs/__init__.py +13 -0
- veadk/configs/auth_configs.py +133 -0
- veadk/configs/database_configs.py +132 -0
- veadk/configs/model_configs.py +78 -0
- veadk/configs/tool_configs.py +54 -0
- veadk/configs/tracing_configs.py +110 -0
- veadk/consts.py +74 -0
- veadk/evaluation/__init__.py +17 -0
- veadk/evaluation/adk_evaluator/__init__.py +17 -0
- veadk/evaluation/adk_evaluator/adk_evaluator.py +302 -0
- veadk/evaluation/base_evaluator.py +642 -0
- veadk/evaluation/deepeval_evaluator/__init__.py +17 -0
- veadk/evaluation/deepeval_evaluator/deepeval_evaluator.py +339 -0
- veadk/evaluation/eval_set_file_loader.py +48 -0
- veadk/evaluation/eval_set_recorder.py +146 -0
- veadk/evaluation/types.py +65 -0
- veadk/evaluation/utils/prometheus.py +196 -0
- veadk/integrations/__init__.py +13 -0
- veadk/integrations/ve_apig/__init__.py +13 -0
- veadk/integrations/ve_apig/ve_apig.py +349 -0
- veadk/integrations/ve_apig/ve_apig_utils.py +332 -0
- veadk/integrations/ve_code_pipeline/__init__.py +13 -0
- veadk/integrations/ve_code_pipeline/ve_code_pipeline.py +431 -0
- veadk/integrations/ve_cozeloop/__init__.py +13 -0
- veadk/integrations/ve_cozeloop/ve_cozeloop.py +96 -0
- veadk/integrations/ve_cr/__init__.py +13 -0
- veadk/integrations/ve_cr/ve_cr.py +220 -0
- veadk/integrations/ve_faas/__init__.py +13 -0
- veadk/integrations/ve_faas/template/cookiecutter.json +15 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/__init__.py +13 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/clean.py +23 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/config.yaml.example +6 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/deploy.py +106 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/__init__.py +13 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/agent.py +25 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py +202 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/requirements.txt +3 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/run.sh +49 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{ cookiecutter.app_name }}/__init__.py +14 -0
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{ cookiecutter.app_name }}/agent.py +27 -0
- veadk/integrations/ve_faas/ve_faas.py +754 -0
- veadk/integrations/ve_faas/ve_faas_utils.py +408 -0
- veadk/integrations/ve_faas/web_template/cookiecutter.json +20 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/__init__.py +13 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/clean.py +23 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/config.yaml.example +2 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/deploy.py +44 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/Dockerfile +23 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/app.py +123 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/init_db.py +46 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/models.py +36 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/requirements.txt +4 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/run.sh +21 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/static/css/style.css +368 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/static/js/admin.js +0 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/dashboard.html +21 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/edit_post.html +24 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/login.html +21 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/posts.html +53 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/base.html +45 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/index.html +29 -0
- veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/post.html +14 -0
- veadk/integrations/ve_identity/__init__.py +110 -0
- veadk/integrations/ve_identity/auth_config.py +261 -0
- veadk/integrations/ve_identity/auth_mixins.py +650 -0
- veadk/integrations/ve_identity/auth_processor.py +385 -0
- veadk/integrations/ve_identity/function_tool.py +158 -0
- veadk/integrations/ve_identity/identity_client.py +864 -0
- veadk/integrations/ve_identity/mcp_tool.py +181 -0
- veadk/integrations/ve_identity/mcp_toolset.py +431 -0
- veadk/integrations/ve_identity/models.py +228 -0
- veadk/integrations/ve_identity/token_manager.py +188 -0
- veadk/integrations/ve_identity/utils.py +151 -0
- veadk/integrations/ve_prompt_pilot/__init__.py +13 -0
- veadk/integrations/ve_prompt_pilot/ve_prompt_pilot.py +85 -0
- veadk/integrations/ve_tls/__init__.py +13 -0
- veadk/integrations/ve_tls/utils.py +116 -0
- veadk/integrations/ve_tls/ve_tls.py +212 -0
- veadk/integrations/ve_tos/ve_tos.py +710 -0
- veadk/integrations/ve_viking_db_memory/__init__.py +13 -0
- veadk/integrations/ve_viking_db_memory/ve_viking_db_memory.py +308 -0
- veadk/knowledgebase/__init__.py +17 -0
- veadk/knowledgebase/backends/__init__.py +13 -0
- veadk/knowledgebase/backends/base_backend.py +72 -0
- veadk/knowledgebase/backends/in_memory_backend.py +91 -0
- veadk/knowledgebase/backends/opensearch_backend.py +162 -0
- veadk/knowledgebase/backends/redis_backend.py +172 -0
- veadk/knowledgebase/backends/utils.py +92 -0
- veadk/knowledgebase/backends/vikingdb_knowledge_backend.py +608 -0
- veadk/knowledgebase/entry.py +25 -0
- veadk/knowledgebase/knowledgebase.py +307 -0
- veadk/memory/__init__.py +35 -0
- veadk/memory/long_term_memory.py +365 -0
- veadk/memory/long_term_memory_backends/__init__.py +13 -0
- veadk/memory/long_term_memory_backends/base_backend.py +35 -0
- veadk/memory/long_term_memory_backends/in_memory_backend.py +67 -0
- veadk/memory/long_term_memory_backends/mem0_backend.py +155 -0
- veadk/memory/long_term_memory_backends/opensearch_backend.py +124 -0
- veadk/memory/long_term_memory_backends/redis_backend.py +140 -0
- veadk/memory/long_term_memory_backends/vikingdb_memory_backend.py +189 -0
- veadk/memory/short_term_memory.py +252 -0
- veadk/memory/short_term_memory_backends/__init__.py +13 -0
- veadk/memory/short_term_memory_backends/base_backend.py +31 -0
- veadk/memory/short_term_memory_backends/mysql_backend.py +49 -0
- veadk/memory/short_term_memory_backends/postgresql_backend.py +49 -0
- veadk/memory/short_term_memory_backends/sqlite_backend.py +55 -0
- veadk/memory/short_term_memory_processor.py +100 -0
- veadk/processors/__init__.py +26 -0
- veadk/processors/base_run_processor.py +120 -0
- veadk/prompts/__init__.py +13 -0
- veadk/prompts/agent_default_prompt.py +30 -0
- veadk/prompts/prompt_evaluator.py +20 -0
- veadk/prompts/prompt_memory_processor.py +55 -0
- veadk/prompts/prompt_optimization.py +150 -0
- veadk/runner.py +732 -0
- veadk/tools/__init__.py +13 -0
- veadk/tools/builtin_tools/__init__.py +13 -0
- veadk/tools/builtin_tools/agent_authorization.py +94 -0
- veadk/tools/builtin_tools/generate_image.py +23 -0
- veadk/tools/builtin_tools/image_edit.py +300 -0
- veadk/tools/builtin_tools/image_generate.py +446 -0
- veadk/tools/builtin_tools/lark.py +67 -0
- veadk/tools/builtin_tools/las.py +24 -0
- veadk/tools/builtin_tools/link_reader.py +66 -0
- veadk/tools/builtin_tools/llm_shield.py +381 -0
- veadk/tools/builtin_tools/load_knowledgebase.py +97 -0
- veadk/tools/builtin_tools/mcp_router.py +29 -0
- veadk/tools/builtin_tools/run_code.py +113 -0
- veadk/tools/builtin_tools/tts.py +253 -0
- veadk/tools/builtin_tools/vesearch.py +49 -0
- veadk/tools/builtin_tools/video_generate.py +363 -0
- veadk/tools/builtin_tools/web_scraper.py +76 -0
- veadk/tools/builtin_tools/web_search.py +83 -0
- veadk/tools/demo_tools.py +58 -0
- veadk/tools/load_knowledgebase_tool.py +149 -0
- veadk/tools/sandbox/__init__.py +13 -0
- veadk/tools/sandbox/browser_sandbox.py +37 -0
- veadk/tools/sandbox/code_sandbox.py +40 -0
- veadk/tools/sandbox/computer_sandbox.py +34 -0
- veadk/tracing/__init__.py +13 -0
- veadk/tracing/base_tracer.py +58 -0
- veadk/tracing/telemetry/__init__.py +13 -0
- veadk/tracing/telemetry/attributes/attributes.py +29 -0
- veadk/tracing/telemetry/attributes/extractors/common_attributes_extractors.py +180 -0
- veadk/tracing/telemetry/attributes/extractors/llm_attributes_extractors.py +858 -0
- veadk/tracing/telemetry/attributes/extractors/tool_attributes_extractors.py +152 -0
- veadk/tracing/telemetry/attributes/extractors/types.py +164 -0
- veadk/tracing/telemetry/exporters/__init__.py +13 -0
- veadk/tracing/telemetry/exporters/apmplus_exporter.py +558 -0
- veadk/tracing/telemetry/exporters/base_exporter.py +39 -0
- veadk/tracing/telemetry/exporters/cozeloop_exporter.py +129 -0
- veadk/tracing/telemetry/exporters/inmemory_exporter.py +248 -0
- veadk/tracing/telemetry/exporters/tls_exporter.py +139 -0
- veadk/tracing/telemetry/opentelemetry_tracer.py +320 -0
- veadk/tracing/telemetry/telemetry.py +411 -0
- veadk/types.py +47 -0
- veadk/utils/__init__.py +13 -0
- veadk/utils/audio_manager.py +95 -0
- veadk/utils/auth.py +294 -0
- veadk/utils/logger.py +59 -0
- veadk/utils/mcp_utils.py +44 -0
- veadk/utils/misc.py +184 -0
- veadk/utils/patches.py +101 -0
- veadk/utils/volcengine_sign.py +205 -0
- veadk/version.py +15 -0
- veadk_python-0.2.27.dist-info/METADATA +373 -0
- veadk_python-0.2.27.dist-info/RECORD +218 -0
- veadk_python-0.2.27.dist-info/WHEEL +5 -0
- veadk_python-0.2.27.dist-info/entry_points.txt +2 -0
- veadk_python-0.2.27.dist-info/licenses/LICENSE +201 -0
- veadk_python-0.2.27.dist-info/top_level.txt +1 -0
veadk/cli/cli_deploy.py
ADDED
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
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
|
+
|
|
16
|
+
import click
|
|
17
|
+
|
|
18
|
+
from veadk.version import VERSION
|
|
19
|
+
|
|
20
|
+
TEMP_PATH = "/tmp"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@click.command()
|
|
24
|
+
@click.option(
|
|
25
|
+
"--volcengine-access-key",
|
|
26
|
+
default=None,
|
|
27
|
+
help="Volcengine access key",
|
|
28
|
+
)
|
|
29
|
+
@click.option(
|
|
30
|
+
"--volcengine-secret-key",
|
|
31
|
+
default=None,
|
|
32
|
+
help="Volcengine secret key",
|
|
33
|
+
)
|
|
34
|
+
@click.option(
|
|
35
|
+
"--vefaas-app-name", required=True, help="Expected Volcengine FaaS application name"
|
|
36
|
+
)
|
|
37
|
+
@click.option(
|
|
38
|
+
"--veapig-instance-name", default="", help="Expected Volcengine APIG instance name"
|
|
39
|
+
)
|
|
40
|
+
@click.option(
|
|
41
|
+
"--veapig-service-name", default="", help="Expected Volcengine APIG service name"
|
|
42
|
+
)
|
|
43
|
+
@click.option(
|
|
44
|
+
"--veapig-upstream-name", default="", help="Expected Volcengine APIG upstream name"
|
|
45
|
+
)
|
|
46
|
+
@click.option(
|
|
47
|
+
"--short-term-memory-backend",
|
|
48
|
+
default="local",
|
|
49
|
+
type=click.Choice(["local", "mysql"]),
|
|
50
|
+
help="Backend for short-term memory",
|
|
51
|
+
)
|
|
52
|
+
@click.option("--use-adk-web", is_flag=True, help="Whether to use ADK Web")
|
|
53
|
+
@click.option(
|
|
54
|
+
"--auth-method",
|
|
55
|
+
default="none",
|
|
56
|
+
type=click.Choice(["none", "api-key", "oauth2"]),
|
|
57
|
+
help="=Authentication method for agent",
|
|
58
|
+
)
|
|
59
|
+
@click.option(
|
|
60
|
+
"--user-pool-name",
|
|
61
|
+
default="",
|
|
62
|
+
help="Expected Volcengine Identity user pool name",
|
|
63
|
+
)
|
|
64
|
+
@click.option(
|
|
65
|
+
"--client-name",
|
|
66
|
+
default="",
|
|
67
|
+
help="Expected Volcengine Identity client name",
|
|
68
|
+
)
|
|
69
|
+
@click.option("--path", default=".", help="Local project path")
|
|
70
|
+
@click.option("--iam-role", default=None, help="iam role for the vefaas function")
|
|
71
|
+
def deploy(
|
|
72
|
+
volcengine_access_key: str,
|
|
73
|
+
volcengine_secret_key: str,
|
|
74
|
+
vefaas_app_name: str,
|
|
75
|
+
veapig_instance_name: str,
|
|
76
|
+
veapig_service_name: str,
|
|
77
|
+
veapig_upstream_name: str,
|
|
78
|
+
short_term_memory_backend: str,
|
|
79
|
+
use_adk_web: bool,
|
|
80
|
+
auth_method: str,
|
|
81
|
+
user_pool_name: str,
|
|
82
|
+
client_name: str,
|
|
83
|
+
path: str,
|
|
84
|
+
iam_role: str,
|
|
85
|
+
) -> None:
|
|
86
|
+
"""Deploy a user project to Volcengine FaaS application.
|
|
87
|
+
|
|
88
|
+
This command deploys a VeADK agent project to Volcengine's Function as a Service (FaaS)
|
|
89
|
+
platform. It creates a deployment package from the local project, configures the necessary
|
|
90
|
+
cloud resources, and manages the deployment process including template generation,
|
|
91
|
+
file copying, and cloud resource provisioning.
|
|
92
|
+
|
|
93
|
+
The deployment process includes:
|
|
94
|
+
1. Creating a temporary deployment package using cookiecutter templates
|
|
95
|
+
2. Copying the user's project files to the deployment structure
|
|
96
|
+
3. Processing configuration files and requirements
|
|
97
|
+
4. Executing the deployment to Volcengine FaaS
|
|
98
|
+
5. Cleaning up temporary files
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
volcengine_access_key: Volcengine access key for API authentication. If not provided,
|
|
102
|
+
will use VOLCENGINE_ACCESS_KEY environment variable
|
|
103
|
+
volcengine_secret_key: Volcengine secret key for API authentication. If not provided,
|
|
104
|
+
will use VOLCENGINE_SECRET_KEY environment variable
|
|
105
|
+
vefaas_app_name: Name of the target Volcengine FaaS application where the
|
|
106
|
+
project will be deployed
|
|
107
|
+
veapig_instance_name: Optional Volcengine API Gateway instance name for
|
|
108
|
+
external API access configuration
|
|
109
|
+
veapig_service_name: Optional Volcengine API Gateway service name
|
|
110
|
+
veapig_upstream_name: Optional Volcengine API Gateway upstream name
|
|
111
|
+
short_term_memory_backend: Backend type for short-term memory storage.
|
|
112
|
+
Choices are 'local' or 'mysql'
|
|
113
|
+
use_adk_web: Flag to enable ADK Web interface for the deployed agent
|
|
114
|
+
auth_method: Authentication for the agent.
|
|
115
|
+
Choices are 'none', 'api-key' or 'oauth2'.
|
|
116
|
+
veidentity_user_pool_name: Optional Volcengine Identity user pool name
|
|
117
|
+
veidentity_client_name: Optional Volcengine Identity client name
|
|
118
|
+
path: Local directory path containing the VeADK project to deploy
|
|
119
|
+
|
|
120
|
+
Note:
|
|
121
|
+
- The function automatically processes and copies requirements.txt if present in the project
|
|
122
|
+
- config.yaml files are excluded from deployment for security reasons
|
|
123
|
+
- Temporary files are created in /tmp and cleaned up after deployment
|
|
124
|
+
- The deployment uses cookiecutter templates for standardized project structure
|
|
125
|
+
"""
|
|
126
|
+
import asyncio
|
|
127
|
+
import shutil
|
|
128
|
+
from pathlib import Path
|
|
129
|
+
|
|
130
|
+
from cookiecutter.main import cookiecutter
|
|
131
|
+
|
|
132
|
+
import veadk.integrations.ve_faas as vefaas
|
|
133
|
+
from veadk.config import getenv
|
|
134
|
+
from veadk.utils.logger import get_logger
|
|
135
|
+
from veadk.utils.misc import formatted_timestamp, load_module_from_file
|
|
136
|
+
import os
|
|
137
|
+
from veadk.config import veadk_environments
|
|
138
|
+
|
|
139
|
+
logger = get_logger(__name__)
|
|
140
|
+
|
|
141
|
+
if not volcengine_access_key:
|
|
142
|
+
volcengine_access_key = getenv("VOLCENGINE_ACCESS_KEY")
|
|
143
|
+
if not volcengine_secret_key:
|
|
144
|
+
volcengine_secret_key = getenv("VOLCENGINE_SECRET_KEY")
|
|
145
|
+
if not iam_role:
|
|
146
|
+
iam_role = getenv("IAM_ROLE", None, allow_false_values=True)
|
|
147
|
+
else:
|
|
148
|
+
os.environ["IAM_ROLE"] = iam_role
|
|
149
|
+
veadk_environments["IAM_ROLE"] = iam_role
|
|
150
|
+
|
|
151
|
+
user_proj_abs_path = Path(path).resolve()
|
|
152
|
+
template_dir_path = Path(vefaas.__file__).parent / "template"
|
|
153
|
+
|
|
154
|
+
tmp_dir_name = f"{user_proj_abs_path.name}_{formatted_timestamp()}"
|
|
155
|
+
|
|
156
|
+
settings = {
|
|
157
|
+
"local_dir_name": tmp_dir_name.replace("-", "_"),
|
|
158
|
+
"app_name": user_proj_abs_path.name.replace("-", "_"),
|
|
159
|
+
"agent_module_name": user_proj_abs_path.name,
|
|
160
|
+
"short_term_memory_backend": short_term_memory_backend,
|
|
161
|
+
"vefaas_application_name": vefaas_app_name,
|
|
162
|
+
"veapig_instance_name": veapig_instance_name,
|
|
163
|
+
"veapig_service_name": veapig_service_name,
|
|
164
|
+
"veapig_upstream_name": veapig_upstream_name,
|
|
165
|
+
"use_adk_web": use_adk_web,
|
|
166
|
+
"auth_method": auth_method,
|
|
167
|
+
"veidentity_user_pool_name": user_pool_name,
|
|
168
|
+
"veidentity_client_name": client_name,
|
|
169
|
+
"veadk_version": VERSION,
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
cookiecutter(
|
|
173
|
+
template=str(template_dir_path),
|
|
174
|
+
output_dir=TEMP_PATH,
|
|
175
|
+
no_input=True,
|
|
176
|
+
extra_context=settings,
|
|
177
|
+
)
|
|
178
|
+
logger.debug(f"Create a template project at {TEMP_PATH}/{tmp_dir_name}")
|
|
179
|
+
|
|
180
|
+
agent_dir = (
|
|
181
|
+
Path(TEMP_PATH)
|
|
182
|
+
/ tmp_dir_name
|
|
183
|
+
/ "src"
|
|
184
|
+
/ user_proj_abs_path.name.replace("-", "_")
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
# remove /tmp/tmp_dir_name/src/user_proj_abs_path.name
|
|
188
|
+
shutil.rmtree(agent_dir)
|
|
189
|
+
agent_dir.mkdir(parents=True, exist_ok=True)
|
|
190
|
+
|
|
191
|
+
# copy
|
|
192
|
+
shutil.copytree(user_proj_abs_path, agent_dir, dirs_exist_ok=True)
|
|
193
|
+
logger.debug(f"Remove agent module from {user_proj_abs_path} to {agent_dir}")
|
|
194
|
+
|
|
195
|
+
# copy requirements.txt
|
|
196
|
+
if (user_proj_abs_path / "requirements.txt").exists():
|
|
197
|
+
logger.debug(
|
|
198
|
+
f"Find a requirements.txt in {user_proj_abs_path}/requirements.txt, copy it to temp project."
|
|
199
|
+
)
|
|
200
|
+
shutil.copy(
|
|
201
|
+
user_proj_abs_path / "requirements.txt",
|
|
202
|
+
Path(TEMP_PATH) / tmp_dir_name / "src" / "requirements.txt",
|
|
203
|
+
)
|
|
204
|
+
else:
|
|
205
|
+
logger.warning(
|
|
206
|
+
"No requirements.txt found in the user project, we will use a default one."
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
# avoid upload user's config.yaml
|
|
210
|
+
if (user_proj_abs_path / "config.yaml").exists():
|
|
211
|
+
logger.warning(
|
|
212
|
+
f"Find a config.yaml in {user_proj_abs_path}/config.yaml, we will not upload it by default."
|
|
213
|
+
)
|
|
214
|
+
shutil.move(agent_dir / "config.yaml", Path(TEMP_PATH) / tmp_dir_name)
|
|
215
|
+
else:
|
|
216
|
+
logger.info(
|
|
217
|
+
"No config.yaml found in the user project. Some environment variables may not be set."
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
# load
|
|
221
|
+
logger.debug(
|
|
222
|
+
f"Load deploy module from {Path(TEMP_PATH) / tmp_dir_name / 'deploy.py'}"
|
|
223
|
+
)
|
|
224
|
+
deploy_module = load_module_from_file(
|
|
225
|
+
module_name="deploy_module",
|
|
226
|
+
file_path=str(Path(TEMP_PATH) / tmp_dir_name / "deploy.py"),
|
|
227
|
+
)
|
|
228
|
+
logger.info(f"Begin deploy from {Path(TEMP_PATH) / tmp_dir_name / 'src'}")
|
|
229
|
+
asyncio.run(deploy_module.main())
|
|
230
|
+
|
|
231
|
+
# remove tmp file
|
|
232
|
+
logger.info("Deploy done. Delete temp dir.")
|
|
233
|
+
shutil.rmtree(Path(TEMP_PATH) / tmp_dir_name)
|
veadk/cli/cli_eval.py
ADDED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
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 click
|
|
16
|
+
|
|
17
|
+
from veadk.utils.logger import get_logger
|
|
18
|
+
|
|
19
|
+
logger = get_logger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@click.command()
|
|
23
|
+
@click.option(
|
|
24
|
+
"--agent-dir",
|
|
25
|
+
default=".",
|
|
26
|
+
help="To-be-evaluated agent directory. Must export `root_agent` in `agent.py`",
|
|
27
|
+
)
|
|
28
|
+
@click.option(
|
|
29
|
+
"--agent-a2a-url",
|
|
30
|
+
default=None,
|
|
31
|
+
help="To-be-evaluated agent URL. The agent should be deployed as A2A mode.",
|
|
32
|
+
)
|
|
33
|
+
@click.option(
|
|
34
|
+
"--evalset-file",
|
|
35
|
+
required=True,
|
|
36
|
+
help="Google ADK formatted evalset file path",
|
|
37
|
+
)
|
|
38
|
+
@click.option(
|
|
39
|
+
"--evaluator",
|
|
40
|
+
type=click.Choice(["adk", "deepeval"], case_sensitive=False),
|
|
41
|
+
help="Evaluator type, choose `adk` or `deepeval`",
|
|
42
|
+
)
|
|
43
|
+
@click.option(
|
|
44
|
+
"--judge-model-name",
|
|
45
|
+
default="doubao-1-5-pro-256k-250115",
|
|
46
|
+
help="Judge model name, default is `doubao-1-5-pro-256k-250115`. Useless under `adk` evaluator.",
|
|
47
|
+
)
|
|
48
|
+
@click.option(
|
|
49
|
+
"--volcengine-access-key",
|
|
50
|
+
default=None,
|
|
51
|
+
help="Volcengine access key for using Volcengine models",
|
|
52
|
+
)
|
|
53
|
+
@click.option(
|
|
54
|
+
"--volcengine-secret-key",
|
|
55
|
+
default=None,
|
|
56
|
+
help="Volcengine secret key for using Volcengine models",
|
|
57
|
+
)
|
|
58
|
+
def eval(
|
|
59
|
+
agent_dir: str,
|
|
60
|
+
agent_a2a_url: str,
|
|
61
|
+
evalset_file: str,
|
|
62
|
+
evaluator: str,
|
|
63
|
+
judge_model_name: str,
|
|
64
|
+
volcengine_access_key: str,
|
|
65
|
+
volcengine_secret_key: str,
|
|
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
|
+
"""
|
|
122
|
+
import asyncio
|
|
123
|
+
import os
|
|
124
|
+
from pathlib import Path
|
|
125
|
+
|
|
126
|
+
from google.adk.cli.utils.agent_loader import AgentLoader
|
|
127
|
+
|
|
128
|
+
from veadk.a2a.remote_ve_agent import RemoteVeAgent
|
|
129
|
+
from veadk.config import getenv, settings
|
|
130
|
+
from veadk.prompts.prompt_evaluator import eval_principle_prompt
|
|
131
|
+
|
|
132
|
+
try:
|
|
133
|
+
from deepeval.metrics import GEval, ToolCorrectnessMetric
|
|
134
|
+
from deepeval.test_case import LLMTestCaseParams
|
|
135
|
+
|
|
136
|
+
from veadk.evaluation.adk_evaluator import ADKEvaluator
|
|
137
|
+
from veadk.evaluation.deepeval_evaluator import DeepevalEvaluator
|
|
138
|
+
except ImportError:
|
|
139
|
+
raise ImportError(
|
|
140
|
+
"Please install veadk with `[evaluation]` extras, e.g., `pip install veadk-python[eval]`"
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
# ====== prepare agent instance ======
|
|
144
|
+
if not agent_dir and not agent_a2a_url:
|
|
145
|
+
raise ValueError(
|
|
146
|
+
"Option `--agent-dir` or `--agent-a2a-url` should be provided one of them."
|
|
147
|
+
)
|
|
148
|
+
|
|
149
|
+
if agent_dir and agent_a2a_url:
|
|
150
|
+
logger.warning(
|
|
151
|
+
"`--agent-dir` and `--agent-a2a-url` are both provided, will use `--agent-a2a-url`."
|
|
152
|
+
)
|
|
153
|
+
agent_instance = RemoteVeAgent(name="a2a_agent", url=agent_a2a_url)
|
|
154
|
+
logger.info(f"Loaded agent from {agent_a2a_url}")
|
|
155
|
+
|
|
156
|
+
if not agent_dir and agent_a2a_url:
|
|
157
|
+
agent_instance = RemoteVeAgent(name="a2a_agent", url=agent_a2a_url)
|
|
158
|
+
logger.info(f"Loaded agent from {agent_a2a_url}")
|
|
159
|
+
|
|
160
|
+
if agent_dir and not agent_a2a_url:
|
|
161
|
+
agent_instance = AgentLoader(str(Path(agent_dir).parent.resolve())).load_agent(
|
|
162
|
+
str(Path(agent_dir).name)
|
|
163
|
+
)
|
|
164
|
+
logger.info(f"Loaded agent from {agent_dir}, agent name: {agent_instance.name}")
|
|
165
|
+
|
|
166
|
+
# ====== prepare envs ======
|
|
167
|
+
if volcengine_access_key and "VOLCENGINE_ACCESS_KEY" not in os.environ:
|
|
168
|
+
os.environ["VOLCENGINE_ACCESS_KEY"] = volcengine_access_key
|
|
169
|
+
if volcengine_secret_key and "VOLCENGINE_SECRET_KEY" not in os.environ:
|
|
170
|
+
os.environ["VOLCENGINE_SECRET_KEY"] = volcengine_secret_key
|
|
171
|
+
|
|
172
|
+
# ====== prepare evaluator instance ======
|
|
173
|
+
evaluator_instance = None
|
|
174
|
+
if evaluator == "adk" and judge_model_name:
|
|
175
|
+
logger.warning(
|
|
176
|
+
"Using Google ADK evaluator, `--judge-model-name` will be ignored."
|
|
177
|
+
)
|
|
178
|
+
evaluator_instance = ADKEvaluator(agent=agent_instance)
|
|
179
|
+
|
|
180
|
+
asyncio.run(evaluator_instance.evaluate(eval_set_file_path=evalset_file))
|
|
181
|
+
|
|
182
|
+
if evaluator == "deepeval":
|
|
183
|
+
if not volcengine_access_key:
|
|
184
|
+
volcengine_access_key = getenv("VOLCENGINE_ACCESS_KEY")
|
|
185
|
+
if not volcengine_secret_key:
|
|
186
|
+
volcengine_secret_key = getenv("VOLCENGINE_SECRET_KEY")
|
|
187
|
+
|
|
188
|
+
evaluator_instance = DeepevalEvaluator(
|
|
189
|
+
agent=agent_instance,
|
|
190
|
+
judge_model_api_key=settings.model.api_key,
|
|
191
|
+
judge_model_name=judge_model_name,
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
judge_model = evaluator_instance.judge_model
|
|
195
|
+
|
|
196
|
+
metrics = [
|
|
197
|
+
GEval(
|
|
198
|
+
threshold=0.8,
|
|
199
|
+
name="Base Evaluation",
|
|
200
|
+
criteria=eval_principle_prompt,
|
|
201
|
+
evaluation_params=[
|
|
202
|
+
LLMTestCaseParams.INPUT,
|
|
203
|
+
LLMTestCaseParams.ACTUAL_OUTPUT,
|
|
204
|
+
LLMTestCaseParams.EXPECTED_OUTPUT,
|
|
205
|
+
],
|
|
206
|
+
model=judge_model,
|
|
207
|
+
),
|
|
208
|
+
ToolCorrectnessMetric(threshold=0.5, model=judge_model),
|
|
209
|
+
]
|
|
210
|
+
|
|
211
|
+
asyncio.run(
|
|
212
|
+
evaluator_instance.evaluate(
|
|
213
|
+
eval_set_file_path=evalset_file, metrics=metrics
|
|
214
|
+
)
|
|
215
|
+
)
|
veadk/cli/cli_init.py
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
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 warnings
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
import click
|
|
19
|
+
|
|
20
|
+
from veadk.version import VERSION
|
|
21
|
+
|
|
22
|
+
warnings.filterwarnings(
|
|
23
|
+
"ignore", category=UserWarning, module="pydantic._internal._fields"
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
|
|
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
|
+
"""
|
|
36
|
+
vefaas_application_name = click.prompt(
|
|
37
|
+
"Volcengine FaaS application name", default="veadk-cloud-agent"
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
veapig_instance_name = click.prompt(
|
|
41
|
+
"Volcengine API Gateway instance name", default="", show_default=True
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
veapig_service_name = click.prompt(
|
|
45
|
+
"Volcengine API Gateway service name", default="", show_default=True
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
veapig_upstream_name = click.prompt(
|
|
49
|
+
"Volcengine API Gateway upstream name", default="", show_default=True
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
deploy_mode_options = {
|
|
53
|
+
"1": "A2A/MCP Server",
|
|
54
|
+
"2": "VeADK Web / Google ADK Web",
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
click.echo("Choose a deploy mode:")
|
|
58
|
+
for key, value in deploy_mode_options.items():
|
|
59
|
+
click.echo(f" {key}. {value}")
|
|
60
|
+
|
|
61
|
+
deploy_mode = click.prompt(
|
|
62
|
+
"Enter your choice", type=click.Choice(deploy_mode_options.keys())
|
|
63
|
+
)
|
|
64
|
+
use_adk_web = deploy_mode == "2"
|
|
65
|
+
|
|
66
|
+
auth_method_options = {}
|
|
67
|
+
auth_methods = {}
|
|
68
|
+
if use_adk_web:
|
|
69
|
+
auth_method_options = {
|
|
70
|
+
"1": "None",
|
|
71
|
+
"2": "OAuth2",
|
|
72
|
+
}
|
|
73
|
+
auth_methods = {
|
|
74
|
+
"1": "none",
|
|
75
|
+
"2": "oauth2",
|
|
76
|
+
}
|
|
77
|
+
else:
|
|
78
|
+
auth_method_options = {
|
|
79
|
+
"1": "None",
|
|
80
|
+
"2": "API key",
|
|
81
|
+
"3": "OAuth2",
|
|
82
|
+
}
|
|
83
|
+
auth_methods = {
|
|
84
|
+
"1": "none",
|
|
85
|
+
"2": "api-key",
|
|
86
|
+
"3": "oauth2",
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
click.echo("Choose an authentication method:")
|
|
90
|
+
for key, value in auth_method_options.items():
|
|
91
|
+
click.echo(f" {key}. {value}")
|
|
92
|
+
|
|
93
|
+
auth_method_idx = click.prompt(
|
|
94
|
+
"Enter your choice", type=click.Choice(auth_method_options.keys())
|
|
95
|
+
)
|
|
96
|
+
auth_method = auth_methods[auth_method_idx]
|
|
97
|
+
|
|
98
|
+
veidentity_user_pool_name = ""
|
|
99
|
+
veidentity_client_name = ""
|
|
100
|
+
if auth_method == "oauth2":
|
|
101
|
+
veidentity_user_pool_name = click.prompt(
|
|
102
|
+
"Volcengine Identity user pool name", default="", show_default=True
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
if use_adk_web:
|
|
106
|
+
veidentity_client_name = click.prompt(
|
|
107
|
+
"Volcengine Identity client name", default="", show_default=True
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
"vefaas_application_name": vefaas_application_name,
|
|
112
|
+
"veapig_instance_name": veapig_instance_name,
|
|
113
|
+
"veapig_service_name": veapig_service_name,
|
|
114
|
+
"veapig_upstream_name": veapig_upstream_name,
|
|
115
|
+
"use_adk_web": use_adk_web,
|
|
116
|
+
"auth_method": auth_method,
|
|
117
|
+
"veidentity_user_pool_name": veidentity_user_pool_name,
|
|
118
|
+
"veidentity_client_name": veidentity_client_name,
|
|
119
|
+
"veadk_version": VERSION,
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@click.command()
|
|
124
|
+
@click.option(
|
|
125
|
+
"--vefaas-template-type", default="template", help="Expected template type"
|
|
126
|
+
)
|
|
127
|
+
def init(
|
|
128
|
+
vefaas_template_type: str,
|
|
129
|
+
) -> None:
|
|
130
|
+
"""Initialize a new VeADK project that can be deployed to Volcengine FaaS.
|
|
131
|
+
|
|
132
|
+
This command creates a new VeADK project from predefined templates using an interactive
|
|
133
|
+
setup process. It generates a complete project structure with all necessary files,
|
|
134
|
+
configurations, and deployment scripts ready for Volcengine cloud deployment.
|
|
135
|
+
|
|
136
|
+
The initialization process includes:
|
|
137
|
+
1. Interactive prompts for collecting deployment configuration
|
|
138
|
+
2. Template selection based on the specified template type
|
|
139
|
+
3. Project directory creation with proper structure
|
|
140
|
+
4. Configuration file generation with user preferences
|
|
141
|
+
5. Ready-to-use deployment scripts and source code structure
|
|
142
|
+
|
|
143
|
+
Available template types:
|
|
144
|
+
- 'template' (default): Creates an A2A/MCP/Web server template with a weather-reporter
|
|
145
|
+
example application. Suitable for most agent development scenarios.
|
|
146
|
+
- 'web_template': Creates a web application template with a simple-blog example.
|
|
147
|
+
Designed for web-based agent applications with UI components.
|
|
148
|
+
|
|
149
|
+
The generated project structure includes:
|
|
150
|
+
- src/ directory containing agent source code
|
|
151
|
+
- deploy.py script for cloud deployment
|
|
152
|
+
- Configuration files for various deployment scenarios
|
|
153
|
+
- Example implementations based on the selected template
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
vefaas_template_type: The type of template to use for project initialization.
|
|
157
|
+
Defaults to 'template'. Valid options are:
|
|
158
|
+
- 'template': Standard agent template (weather-reporter example)
|
|
159
|
+
- 'web_template': Web application template (simple-blog example)
|
|
160
|
+
|
|
161
|
+
Note:
|
|
162
|
+
- If the target directory already exists, you will be prompted to confirm overwrite
|
|
163
|
+
- The generated project includes example code that can be modified for your use case
|
|
164
|
+
- All deployment configurations can be customized after project creation
|
|
165
|
+
- The deploy.py script provides automated deployment to Volcengine FaaS platform
|
|
166
|
+
"""
|
|
167
|
+
import shutil
|
|
168
|
+
from pathlib import Path
|
|
169
|
+
|
|
170
|
+
from cookiecutter.main import cookiecutter
|
|
171
|
+
|
|
172
|
+
import veadk.integrations.ve_faas as vefaas
|
|
173
|
+
|
|
174
|
+
if vefaas_template_type == "web_template":
|
|
175
|
+
click.echo(
|
|
176
|
+
"Welcome use VeADK to create your project. We will generate a `simple-blog` web application for you."
|
|
177
|
+
)
|
|
178
|
+
else:
|
|
179
|
+
click.echo(
|
|
180
|
+
"Welcome use VeADK to create your project. We will generate a `weather-reporter` application for you."
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
cwd = Path.cwd()
|
|
184
|
+
local_dir_name = click.prompt("Local directory name", default="veadk-cloud-proj")
|
|
185
|
+
target_dir_path = cwd / local_dir_name
|
|
186
|
+
|
|
187
|
+
if target_dir_path.exists():
|
|
188
|
+
click.confirm(
|
|
189
|
+
f"Directory '{target_dir_path}' already exists, do you want to overwrite it",
|
|
190
|
+
abort=True,
|
|
191
|
+
)
|
|
192
|
+
shutil.rmtree(target_dir_path)
|
|
193
|
+
|
|
194
|
+
settings = _render_prompts()
|
|
195
|
+
settings["local_dir_name"] = local_dir_name
|
|
196
|
+
|
|
197
|
+
if not vefaas_template_type:
|
|
198
|
+
vefaas_template_type = "template"
|
|
199
|
+
|
|
200
|
+
template_dir_path = Path(vefaas.__file__).parent / vefaas_template_type
|
|
201
|
+
|
|
202
|
+
cookiecutter(
|
|
203
|
+
template=str(template_dir_path),
|
|
204
|
+
output_dir=str(cwd),
|
|
205
|
+
extra_context=settings,
|
|
206
|
+
no_input=True,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
click.echo(f"Template project has been generated at {target_dir_path}")
|
|
210
|
+
click.echo(f"Edit {target_dir_path / 'src/'} to define your agents")
|
|
211
|
+
click.echo(
|
|
212
|
+
f"Edit {target_dir_path / 'deploy.py'} to define your deployment attributes"
|
|
213
|
+
)
|
|
214
|
+
click.echo("Run python `deploy.py` for deployment on Volcengine FaaS platform.")
|