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_kb.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
from pathlib import Path
|
|
16
|
+
from typing import Literal
|
|
17
|
+
|
|
18
|
+
import click
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@click.command()
|
|
22
|
+
@click.option(
|
|
23
|
+
"--backend",
|
|
24
|
+
type=click.Choice(
|
|
25
|
+
["local", "opensearch", "viking", "redis"],
|
|
26
|
+
case_sensitive=False,
|
|
27
|
+
),
|
|
28
|
+
required=True,
|
|
29
|
+
)
|
|
30
|
+
@click.option(
|
|
31
|
+
"--app_name",
|
|
32
|
+
default="",
|
|
33
|
+
help="`app_name` for init your knowledgebase",
|
|
34
|
+
)
|
|
35
|
+
@click.option(
|
|
36
|
+
"--index",
|
|
37
|
+
default="",
|
|
38
|
+
help="Knowledgebase index",
|
|
39
|
+
)
|
|
40
|
+
@click.option(
|
|
41
|
+
"--path",
|
|
42
|
+
required=True,
|
|
43
|
+
help="Knowledge file or directory path",
|
|
44
|
+
)
|
|
45
|
+
def add(
|
|
46
|
+
backend: Literal["local", "opensearch", "viking", "redis"],
|
|
47
|
+
app_name: str,
|
|
48
|
+
index: str,
|
|
49
|
+
path: str,
|
|
50
|
+
):
|
|
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
|
+
"""
|
|
87
|
+
_path = Path(path)
|
|
88
|
+
assert _path.exists(), f"Path {path} not exists. Please check your input."
|
|
89
|
+
|
|
90
|
+
from veadk.knowledgebase import KnowledgeBase
|
|
91
|
+
|
|
92
|
+
knowledgebase = KnowledgeBase(backend=backend, app_name=app_name, index=index)
|
|
93
|
+
|
|
94
|
+
if _path.is_file():
|
|
95
|
+
knowledgebase.add_from_files(files=[path])
|
|
96
|
+
elif _path.is_dir():
|
|
97
|
+
knowledgebase.add_from_directory(directory=path)
|
|
98
|
+
else:
|
|
99
|
+
raise RuntimeError(
|
|
100
|
+
"Unsupported knowledgebase file type, only support a single file and a directory."
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
@click.group()
|
|
105
|
+
def kb():
|
|
106
|
+
"""VeADK Knowledgebase management"""
|
|
107
|
+
pass
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
kb.add_command(add)
|
|
@@ -0,0 +1,285 @@
|
|
|
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
|
+
|
|
17
|
+
import click
|
|
18
|
+
|
|
19
|
+
from veadk.config import getenv
|
|
20
|
+
from veadk.consts import (
|
|
21
|
+
DEFAULT_CR_INSTANCE_NAME,
|
|
22
|
+
DEFAULT_CR_NAMESPACE_NAME,
|
|
23
|
+
DEFAULT_CR_REPO_NAME,
|
|
24
|
+
)
|
|
25
|
+
from veadk.integrations.ve_code_pipeline.ve_code_pipeline import VeCodePipeline
|
|
26
|
+
from veadk.integrations.ve_cr.ve_cr import VeCR
|
|
27
|
+
from veadk.integrations.ve_faas.ve_faas import VeFaaS
|
|
28
|
+
from veadk.utils.logger import get_logger
|
|
29
|
+
from veadk.version import VERSION
|
|
30
|
+
|
|
31
|
+
logger = get_logger(__name__)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
warnings.filterwarnings(
|
|
35
|
+
"ignore", category=UserWarning, module="pydantic._internal._fields"
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
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
|
+
"""
|
|
52
|
+
vecr = VeCR(
|
|
53
|
+
access_key=volcengine_settings["volcengine_access_key"],
|
|
54
|
+
secret_key=volcengine_settings["volcengine_secret_key"],
|
|
55
|
+
region=volcengine_settings["volcengine_region"],
|
|
56
|
+
)
|
|
57
|
+
try:
|
|
58
|
+
vecr._create_instance(cr_settings["cr_instance_name"])
|
|
59
|
+
except Exception as e:
|
|
60
|
+
click.echo(f"Failed to create CR instance: {e}")
|
|
61
|
+
raise
|
|
62
|
+
|
|
63
|
+
try:
|
|
64
|
+
vecr._create_namespace(
|
|
65
|
+
instance_name=cr_settings["cr_instance_name"],
|
|
66
|
+
namespace_name=cr_settings["cr_namespace_name"],
|
|
67
|
+
)
|
|
68
|
+
except Exception as e:
|
|
69
|
+
click.echo(f"Failed to create CR namespace: {e}")
|
|
70
|
+
raise
|
|
71
|
+
|
|
72
|
+
try:
|
|
73
|
+
vecr._create_repo(
|
|
74
|
+
instance_name=cr_settings["cr_instance_name"],
|
|
75
|
+
namespace_name=cr_settings["cr_namespace_name"],
|
|
76
|
+
repo_name=cr_settings["cr_repo_name"],
|
|
77
|
+
)
|
|
78
|
+
except Exception as e:
|
|
79
|
+
click.echo(f"Failed to create CR repo: {e}")
|
|
80
|
+
raise
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@click.command()
|
|
84
|
+
@click.option(
|
|
85
|
+
"--veadk-version",
|
|
86
|
+
default=VERSION,
|
|
87
|
+
help=f"Base VeADK image tag can be 'preview', 'latest', or a specific VeADK version (e.g., {VERSION})",
|
|
88
|
+
)
|
|
89
|
+
@click.option(
|
|
90
|
+
"--github-url",
|
|
91
|
+
required=True,
|
|
92
|
+
help="The github url of your project",
|
|
93
|
+
)
|
|
94
|
+
@click.option(
|
|
95
|
+
"--github-branch",
|
|
96
|
+
required=True,
|
|
97
|
+
help="The github branch of your project",
|
|
98
|
+
)
|
|
99
|
+
@click.option(
|
|
100
|
+
"--github-token",
|
|
101
|
+
required=True,
|
|
102
|
+
help="The github token to manage your project",
|
|
103
|
+
)
|
|
104
|
+
@click.option(
|
|
105
|
+
"--volcengine-access-key",
|
|
106
|
+
default=None,
|
|
107
|
+
help="Volcengine access key, if not set, will use the value of environment variable VOLCENGINE_ACCESS_KEY",
|
|
108
|
+
)
|
|
109
|
+
@click.option(
|
|
110
|
+
"--volcengine-secret-key",
|
|
111
|
+
default=None,
|
|
112
|
+
help="Volcengine secret key, if not set, will use the value of environment variable VOLCENGINE_SECRET_KEY",
|
|
113
|
+
)
|
|
114
|
+
@click.option(
|
|
115
|
+
"--region",
|
|
116
|
+
default="cn-beijing",
|
|
117
|
+
help="Region for Volcengine VeFaaS, CR, and Pipeline. Default is cn-beijing",
|
|
118
|
+
)
|
|
119
|
+
@click.option(
|
|
120
|
+
"--cr-instance-name",
|
|
121
|
+
default=DEFAULT_CR_INSTANCE_NAME,
|
|
122
|
+
help="Volcengine Container Registry instance name, default is veadk-user-instance",
|
|
123
|
+
)
|
|
124
|
+
@click.option(
|
|
125
|
+
"--cr-namespace-name",
|
|
126
|
+
default=DEFAULT_CR_NAMESPACE_NAME,
|
|
127
|
+
help="Volcengine Container Registry namespace name, default is veadk-user-namespace",
|
|
128
|
+
)
|
|
129
|
+
@click.option(
|
|
130
|
+
"--cr-repo-name",
|
|
131
|
+
default=DEFAULT_CR_REPO_NAME,
|
|
132
|
+
help="Volcengine Container Registry repo name, default is veadk-user-repo",
|
|
133
|
+
)
|
|
134
|
+
@click.option(
|
|
135
|
+
"--vefaas-function-id",
|
|
136
|
+
default=None,
|
|
137
|
+
help="Volcengine FaaS function ID, if not set, a new function will be created automatically",
|
|
138
|
+
)
|
|
139
|
+
def pipeline(
|
|
140
|
+
veadk_version: str,
|
|
141
|
+
github_url: str,
|
|
142
|
+
github_branch: str,
|
|
143
|
+
github_token: str,
|
|
144
|
+
volcengine_access_key: str,
|
|
145
|
+
volcengine_secret_key: str,
|
|
146
|
+
region: str,
|
|
147
|
+
cr_instance_name: str,
|
|
148
|
+
cr_namespace_name: str,
|
|
149
|
+
cr_repo_name: str,
|
|
150
|
+
vefaas_function_id: str,
|
|
151
|
+
) -> None:
|
|
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
|
+
"""
|
|
206
|
+
|
|
207
|
+
click.echo(
|
|
208
|
+
"Welcome use VeADK to integrate your project to volcengine pipeline for CI/CD."
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
if not volcengine_access_key:
|
|
212
|
+
volcengine_access_key = getenv("VOLCENGINE_ACCESS_KEY")
|
|
213
|
+
if not volcengine_secret_key:
|
|
214
|
+
volcengine_secret_key = getenv("VOLCENGINE_SECRET_KEY")
|
|
215
|
+
|
|
216
|
+
volcengine_settings = {
|
|
217
|
+
"volcengine_access_key": volcengine_access_key,
|
|
218
|
+
"volcengine_secret_key": volcengine_secret_key,
|
|
219
|
+
"volcengine_region": region,
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
cr_settings = {
|
|
223
|
+
"cr_domain": f"{cr_instance_name}-{region}.cr.volces.com",
|
|
224
|
+
"cr_instance_name": cr_instance_name,
|
|
225
|
+
"cr_namespace_name": cr_namespace_name,
|
|
226
|
+
"cr_repo_name": cr_repo_name,
|
|
227
|
+
"cr_region": region,
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if not vefaas_function_id:
|
|
231
|
+
click.echo(
|
|
232
|
+
"No Function ID specified. VeADK will create one automatically. Please specify a function name:"
|
|
233
|
+
)
|
|
234
|
+
function_name = click.prompt(
|
|
235
|
+
"Function name", default="veadk-image-function", show_default=False
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
_create_cr(volcengine_settings, cr_settings)
|
|
239
|
+
|
|
240
|
+
if not vefaas_function_id:
|
|
241
|
+
vefaas_client = VeFaaS(
|
|
242
|
+
access_key=volcengine_settings["volcengine_access_key"],
|
|
243
|
+
secret_key=volcengine_settings["volcengine_secret_key"],
|
|
244
|
+
region=volcengine_settings["volcengine_region"],
|
|
245
|
+
)
|
|
246
|
+
_, _, function_id = vefaas_client.deploy_image(
|
|
247
|
+
name=function_name,
|
|
248
|
+
image="veadk-cn-beijing.cr.volces.com/veadk/simple-fastapi:0.1",
|
|
249
|
+
registry_name=cr_settings["cr_instance_name"],
|
|
250
|
+
)
|
|
251
|
+
logger.debug(f"Created function {function_name} with ID: {function_id}")
|
|
252
|
+
|
|
253
|
+
client = VeCodePipeline(
|
|
254
|
+
volcengine_access_key=volcengine_settings["volcengine_access_key"],
|
|
255
|
+
volcengine_secret_key=volcengine_settings["volcengine_secret_key"],
|
|
256
|
+
region=volcengine_settings["volcengine_region"],
|
|
257
|
+
)
|
|
258
|
+
|
|
259
|
+
click.echo("=====================================================")
|
|
260
|
+
click.echo("Using the following configuration to create pipeline:")
|
|
261
|
+
click.echo(f"Use VeADK version: {veadk_version}")
|
|
262
|
+
click.echo(f"Github url: {github_url}")
|
|
263
|
+
click.echo(f"Github branch: {github_branch}")
|
|
264
|
+
click.echo(f"VeFaaS function name: {function_name}")
|
|
265
|
+
click.echo(f"VeFaaS function ID: {function_id}")
|
|
266
|
+
click.echo(f"Container Registry domain: {cr_settings['cr_domain']}")
|
|
267
|
+
click.echo(f"Container Registry namespace name: {cr_settings['cr_namespace_name']}")
|
|
268
|
+
click.echo(f"Container Registry region: {region}")
|
|
269
|
+
click.echo(f"Container Registry instance name: {cr_settings['cr_instance_name']}")
|
|
270
|
+
click.echo(f"Container Registry repo name: {cr_settings['cr_repo_name']}")
|
|
271
|
+
|
|
272
|
+
client.deploy(
|
|
273
|
+
base_image_tag=veadk_version,
|
|
274
|
+
github_url=github_url,
|
|
275
|
+
github_branch=github_branch,
|
|
276
|
+
github_token=github_token,
|
|
277
|
+
cr_domain=cr_settings["cr_domain"],
|
|
278
|
+
cr_namespace_name=cr_settings["cr_namespace_name"],
|
|
279
|
+
cr_region=cr_settings["cr_region"],
|
|
280
|
+
cr_instance_name=cr_settings["cr_instance_name"],
|
|
281
|
+
cr_repo_name=cr_settings["cr_repo_name"],
|
|
282
|
+
function_id=function_id,
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
click.echo("Pipeline has been created successfully.")
|
veadk/cli/cli_prompt.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
|
|
18
|
+
@click.command()
|
|
19
|
+
@click.option(
|
|
20
|
+
"--path", default=".", help="Agent file path with global variable `agent=...`"
|
|
21
|
+
)
|
|
22
|
+
@click.option("--feedback", default="", help="Suggestions for prompt optimization")
|
|
23
|
+
@click.option("--api-key", default="", help="API Key of PromptPilot")
|
|
24
|
+
@click.option("--workspace-id", default="", help="Workspace ID of PromptPilot")
|
|
25
|
+
@click.option(
|
|
26
|
+
"--model-name",
|
|
27
|
+
default="doubao-1.5-pro-32k-250115",
|
|
28
|
+
help="Model name for prompt optimization",
|
|
29
|
+
)
|
|
30
|
+
def prompt(
|
|
31
|
+
path: str, feedback: str, api_key: str, workspace_id: str, model_name: str
|
|
32
|
+
) -> None:
|
|
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
|
+
"""
|
|
49
|
+
from pathlib import Path
|
|
50
|
+
|
|
51
|
+
from veadk.agent import Agent
|
|
52
|
+
from veadk.config import settings
|
|
53
|
+
from veadk.integrations.ve_prompt_pilot.ve_prompt_pilot import VePromptPilot
|
|
54
|
+
from veadk.utils.misc import load_module_from_file
|
|
55
|
+
|
|
56
|
+
module_name = "agents_for_prompt_pilot"
|
|
57
|
+
module_abs_path = Path(path).resolve()
|
|
58
|
+
|
|
59
|
+
module = load_module_from_file(
|
|
60
|
+
module_name=module_name, file_path=str(module_abs_path)
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# get all global variables from module
|
|
64
|
+
globals_in_module = vars(module)
|
|
65
|
+
|
|
66
|
+
agents = []
|
|
67
|
+
for global_variable_name, global_variable_value in globals_in_module.items():
|
|
68
|
+
if isinstance(global_variable_value, Agent):
|
|
69
|
+
agent = global_variable_value
|
|
70
|
+
agents.append(agent)
|
|
71
|
+
|
|
72
|
+
if len(agents) > 0:
|
|
73
|
+
click.echo(f"Found {len(agents)} agents in {module_abs_path}")
|
|
74
|
+
|
|
75
|
+
if not api_key:
|
|
76
|
+
api_key = settings.prompt_pilot.api_key
|
|
77
|
+
|
|
78
|
+
if not workspace_id:
|
|
79
|
+
raise ValueError("Please provide workspace_id for PromptPilot service.")
|
|
80
|
+
|
|
81
|
+
ve_prompt_pilot = VePromptPilot(api_key=api_key, workspace_id=workspace_id)
|
|
82
|
+
ve_prompt_pilot.optimize(
|
|
83
|
+
agents=agents, feedback=feedback, model_name=model_name
|
|
84
|
+
)
|
|
85
|
+
else:
|
|
86
|
+
click.echo(f"No agents found in {module_abs_path}")
|
veadk/cli/cli_update.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
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.cloud.cloud_agent_engine import CloudAgentEngine
|
|
18
|
+
from veadk.utils.logger import get_logger
|
|
19
|
+
from veadk.config import getenv
|
|
20
|
+
|
|
21
|
+
logger = get_logger(__name__)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@click.command()
|
|
25
|
+
@click.option(
|
|
26
|
+
"--volcengine-access-key",
|
|
27
|
+
default=None,
|
|
28
|
+
help="Volcengine access key for authentication. Defaults to VOLCENGINE_ACCESS_KEY environment variable.",
|
|
29
|
+
)
|
|
30
|
+
@click.option(
|
|
31
|
+
"--volcengine-secret-key",
|
|
32
|
+
default=None,
|
|
33
|
+
help="Volcengine secret key for authentication. Defaults to VOLCENGINE_SECRET_KEY environment variable.",
|
|
34
|
+
)
|
|
35
|
+
@click.option(
|
|
36
|
+
"--vefaas-app-name",
|
|
37
|
+
required=True,
|
|
38
|
+
help="Name of the cloud application to update.",
|
|
39
|
+
)
|
|
40
|
+
@click.option(
|
|
41
|
+
"--path",
|
|
42
|
+
default=".",
|
|
43
|
+
help="Local path containing the updated code. Defaults to current directory.",
|
|
44
|
+
)
|
|
45
|
+
def update(
|
|
46
|
+
volcengine_access_key: str,
|
|
47
|
+
volcengine_secret_key: str,
|
|
48
|
+
vefaas_app_name: str,
|
|
49
|
+
path: str,
|
|
50
|
+
) -> None:
|
|
51
|
+
"""Update function code of a deployed cloud application on Volcengine FaaS.
|
|
52
|
+
|
|
53
|
+
This command updates the code of an existing cloud application without changing
|
|
54
|
+
the endpoint or other resources. It uploads the local project code to replace
|
|
55
|
+
the existing function implementation.
|
|
56
|
+
|
|
57
|
+
The update process:
|
|
58
|
+
1. Authenticates with Volcengine using provided credentials
|
|
59
|
+
2. Validates the local project path and application name
|
|
60
|
+
3. Uploads the updated code to the existing application
|
|
61
|
+
4. Preserves the existing endpoint and gateway configuration
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
volcengine_access_key: Volcengine platform access key for authentication.
|
|
65
|
+
If not provided, uses VOLCENGINE_ACCESS_KEY environment variable.
|
|
66
|
+
volcengine_secret_key: Volcengine platform secret key for authentication.
|
|
67
|
+
If not provided, uses VOLCENGINE_SECRET_KEY environment variable.
|
|
68
|
+
vefaas_app_name: Name of the existing cloud application to update.
|
|
69
|
+
path: Local directory path containing the updated agent project.
|
|
70
|
+
Defaults to current directory if not specified.
|
|
71
|
+
|
|
72
|
+
Note:
|
|
73
|
+
- Application must already exist on Volcengine FaaS
|
|
74
|
+
- Only function code is updated, endpoint remains unchanged
|
|
75
|
+
- Uses default region 'cn-beijing' for Volcengine services
|
|
76
|
+
|
|
77
|
+
Raises:
|
|
78
|
+
ValueError: If authentication fails or application not found.
|
|
79
|
+
FileNotFoundError: If local path does not exist.
|
|
80
|
+
"""
|
|
81
|
+
# Set environment variables if provided
|
|
82
|
+
if not volcengine_access_key:
|
|
83
|
+
volcengine_access_key = getenv("VOLCENGINE_ACCESS_KEY")
|
|
84
|
+
if not volcengine_secret_key:
|
|
85
|
+
volcengine_secret_key = getenv("VOLCENGINE_SECRET_KEY")
|
|
86
|
+
|
|
87
|
+
# Initialize cloud agent engine
|
|
88
|
+
engine = CloudAgentEngine(
|
|
89
|
+
volcengine_access_key=volcengine_access_key,
|
|
90
|
+
volcengine_secret_key=volcengine_secret_key,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
try:
|
|
94
|
+
# Update function code
|
|
95
|
+
updated_app = engine.update_function_code(
|
|
96
|
+
application_name=vefaas_app_name,
|
|
97
|
+
path=path,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
logger.info(f"Successfully updated cloud application '{vefaas_app_name}'")
|
|
101
|
+
logger.info(f"Endpoint: {updated_app.vefaas_endpoint}")
|
|
102
|
+
logger.info(f"Application ID: {updated_app.vefaas_application_id}")
|
|
103
|
+
|
|
104
|
+
except Exception as e:
|
|
105
|
+
logger.error(f"Failed to update cloud application: {e}")
|
|
106
|
+
raise
|