veadk-python 0.2.5__py3-none-any.whl → 0.2.7__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.

Potentially problematic release.


This version of veadk-python might be problematic. Click here for more details.

Files changed (94) hide show
  1. veadk/agent.py +29 -22
  2. veadk/agent_builder.py +94 -0
  3. veadk/auth/__init__.py +13 -0
  4. veadk/auth/base_auth.py +22 -0
  5. veadk/auth/veauth/__init__.py +13 -0
  6. veadk/auth/veauth/apmplus_veauth.py +65 -0
  7. veadk/auth/veauth/ark_veauth.py +77 -0
  8. veadk/auth/veauth/base_veauth.py +50 -0
  9. veadk/auth/veauth/cozeloop_veauth.py +13 -0
  10. veadk/auth/veauth/prompt_pilot_veauth.py +60 -0
  11. veadk/auth/veauth/vesearch_veauth.py +62 -0
  12. veadk/cli/cli.py +2 -0
  13. veadk/cli/cli_deploy.py +5 -2
  14. veadk/cli/cli_init.py +25 -6
  15. veadk/cli/cli_pipeline.py +220 -0
  16. veadk/cli/cli_prompt.py +4 -4
  17. veadk/config.py +45 -81
  18. veadk/configs/__init__.py +13 -0
  19. veadk/configs/database_configs.py +83 -0
  20. veadk/configs/model_configs.py +42 -0
  21. veadk/configs/tool_configs.py +42 -0
  22. veadk/configs/tracing_configs.py +110 -0
  23. veadk/consts.py +32 -1
  24. veadk/database/database_adapter.py +256 -3
  25. veadk/database/kv/redis_database.py +47 -0
  26. veadk/database/local_database.py +23 -4
  27. veadk/database/relational/mysql_database.py +58 -0
  28. veadk/database/vector/opensearch_vector_database.py +6 -3
  29. veadk/database/viking/viking_database.py +272 -36
  30. veadk/integrations/ve_code_pipeline/__init__.py +13 -0
  31. veadk/integrations/ve_code_pipeline/ve_code_pipeline.py +431 -0
  32. veadk/integrations/ve_cozeloop/__init__.py +13 -0
  33. veadk/integrations/ve_cozeloop/ve_cozeloop.py +96 -0
  34. veadk/integrations/ve_cr/__init__.py +13 -0
  35. veadk/integrations/ve_cr/ve_cr.py +220 -0
  36. veadk/integrations/ve_faas/template/cookiecutter.json +3 -2
  37. veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/deploy.py +2 -2
  38. veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/agent.py +1 -1
  39. veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py +24 -1
  40. veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/requirements.txt +3 -1
  41. veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/run.sh +1 -12
  42. veadk/integrations/ve_faas/ve_faas.py +352 -35
  43. veadk/integrations/ve_faas/web_template/cookiecutter.json +17 -0
  44. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/__init__.py +13 -0
  45. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/clean.py +23 -0
  46. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/config.yaml.example +2 -0
  47. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/deploy.py +41 -0
  48. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/Dockerfile +23 -0
  49. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/app.py +123 -0
  50. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/init_db.py +46 -0
  51. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/models.py +36 -0
  52. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/requirements.txt +4 -0
  53. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/run.sh +21 -0
  54. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/static/css/style.css +368 -0
  55. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/static/js/admin.js +0 -0
  56. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/dashboard.html +21 -0
  57. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/edit_post.html +24 -0
  58. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/login.html +21 -0
  59. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/admin/posts.html +53 -0
  60. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/base.html +45 -0
  61. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/index.html +29 -0
  62. veadk/integrations/ve_faas/web_template/{{cookiecutter.local_dir_name}}/src/templates/post.html +14 -0
  63. veadk/integrations/ve_prompt_pilot/ve_prompt_pilot.py +6 -3
  64. veadk/integrations/ve_tls/__init__.py +13 -0
  65. veadk/integrations/ve_tls/utils.py +117 -0
  66. veadk/integrations/ve_tls/ve_tls.py +208 -0
  67. veadk/integrations/ve_tos/ve_tos.py +128 -73
  68. veadk/knowledgebase/knowledgebase.py +116 -20
  69. veadk/memory/long_term_memory.py +20 -21
  70. veadk/memory/short_term_memory_processor.py +9 -4
  71. veadk/runner.py +213 -223
  72. veadk/tools/builtin_tools/vesearch.py +2 -2
  73. veadk/tools/builtin_tools/video_generate.py +27 -20
  74. veadk/tracing/telemetry/attributes/extractors/common_attributes_extractors.py +5 -0
  75. veadk/tracing/telemetry/attributes/extractors/llm_attributes_extractors.py +253 -129
  76. veadk/tracing/telemetry/attributes/extractors/types.py +15 -4
  77. veadk/tracing/telemetry/exporters/apmplus_exporter.py +158 -12
  78. veadk/tracing/telemetry/exporters/cozeloop_exporter.py +4 -9
  79. veadk/tracing/telemetry/exporters/tls_exporter.py +4 -10
  80. veadk/tracing/telemetry/opentelemetry_tracer.py +11 -5
  81. veadk/tracing/telemetry/telemetry.py +23 -5
  82. veadk/utils/logger.py +1 -1
  83. veadk/utils/misc.py +48 -0
  84. veadk/utils/volcengine_sign.py +6 -2
  85. veadk/version.py +1 -1
  86. {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/METADATA +2 -1
  87. veadk_python-0.2.7.dist-info/RECORD +172 -0
  88. veadk_python-0.2.5.dist-info/RECORD +0 -127
  89. /veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{{ cookiecutter.app_name|replace('-', '_') }} → {{ cookiecutter.app_name }}}/__init__.py +0 -0
  90. /veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{{ cookiecutter.app_name|replace('-', '_') }} → {{ cookiecutter.app_name }}}/agent.py +0 -0
  91. {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/WHEEL +0 -0
  92. {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/entry_points.txt +0 -0
  93. {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/licenses/LICENSE +0 -0
  94. {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/top_level.txt +0 -0
veadk/agent.py CHANGED
@@ -14,11 +14,11 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
- from typing import Optional
17
+ from typing import Optional, Union
18
18
 
19
19
  from google.adk.agents import LlmAgent, RunConfig
20
20
  from google.adk.agents.base_agent import BaseAgent
21
- from google.adk.agents.llm_agent import ToolUnion
21
+ from google.adk.agents.llm_agent import InstructionProvider, ToolUnion
22
22
  from google.adk.agents.run_config import StreamingMode
23
23
  from google.adk.models.lite_llm import LiteLlm
24
24
  from google.adk.runners import Runner
@@ -26,12 +26,10 @@ from google.genai import types
26
26
  from pydantic import ConfigDict, Field
27
27
  from typing_extensions import Any
28
28
 
29
- from veadk.config import getenv
29
+ from veadk.config import settings
30
30
  from veadk.consts import (
31
- DEFAULT_MODEL_AGENT_PROVIDER,
32
- DEFAULT_MODEL_AGENT_API_BASE,
33
- DEFAULT_MODEL_AGENT_NAME,
34
- DEFAULT_MODEL_EXTRA_HEADERS,
31
+ DEFAULT_AGENT_NAME,
32
+ DEFAULT_MODEL_EXTRA_CONFIG,
35
33
  )
36
34
  from veadk.evaluation import EvalSetRecorder
37
35
  from veadk.knowledgebase import KnowledgeBase
@@ -53,25 +51,25 @@ class Agent(LlmAgent):
53
51
  model_config = ConfigDict(arbitrary_types_allowed=True, extra="allow")
54
52
  """The model config"""
55
53
 
56
- name: str = "veAgent"
54
+ name: str = DEFAULT_AGENT_NAME
57
55
  """The name of the agent."""
58
56
 
59
57
  description: str = DEFAULT_DESCRIPTION
60
58
  """The description of the agent. This will be helpful in A2A scenario."""
61
59
 
62
- instruction: str = DEFAULT_INSTRUCTION
63
- """The instruction for the agent, such as principles of function calling."""
60
+ instruction: Union[str, InstructionProvider] = DEFAULT_INSTRUCTION
61
+ """The instruction for the agent."""
64
62
 
65
- model_name: str = getenv("MODEL_AGENT_NAME", DEFAULT_MODEL_AGENT_NAME)
63
+ model_name: str = Field(default_factory=lambda: settings.model.name)
66
64
  """The name of the model for agent running."""
67
65
 
68
- model_provider: str = getenv("MODEL_AGENT_PROVIDER", DEFAULT_MODEL_AGENT_PROVIDER)
66
+ model_provider: str = Field(default_factory=lambda: settings.model.provider)
69
67
  """The provider of the model for agent running."""
70
68
 
71
- model_api_base: str = getenv("MODEL_AGENT_API_BASE", DEFAULT_MODEL_AGENT_API_BASE)
69
+ model_api_base: str = Field(default_factory=lambda: settings.model.api_base)
72
70
  """The api base of the model for agent running."""
73
71
 
74
- model_api_key: str = Field(default_factory=lambda: getenv("MODEL_AGENT_API_KEY"))
72
+ model_api_key: str = Field(default_factory=lambda: settings.model.api_key)
75
73
  """The api key of the model for agent running."""
76
74
 
77
75
  model_extra_config: dict = Field(default_factory=dict)
@@ -95,17 +93,26 @@ class Agent(LlmAgent):
95
93
  tracers: list[BaseTracer] = []
96
94
  """The tracers provided to agent."""
97
95
 
98
- serve_url: str = ""
99
- """The url of agent serving host. Show in agent card."""
100
-
101
96
  def model_post_init(self, __context: Any) -> None:
102
97
  super().model_post_init(None) # for sub_agents init
103
98
 
104
- # add model request source (veadk) in extra headers
105
- if self.model_extra_config and "extra_headers" in self.model_extra_config:
106
- self.model_extra_config["extra_headers"] |= DEFAULT_MODEL_EXTRA_HEADERS
107
- else:
108
- self.model_extra_config["extra_headers"] = DEFAULT_MODEL_EXTRA_HEADERS
99
+ # combine user model config with VeADK defaults
100
+ headers = DEFAULT_MODEL_EXTRA_CONFIG["extra_headers"].copy()
101
+ body = DEFAULT_MODEL_EXTRA_CONFIG["extra_body"].copy()
102
+
103
+ if self.model_extra_config:
104
+ user_headers = self.model_extra_config.get("extra_headers", {})
105
+ user_body = self.model_extra_config.get("extra_body", {})
106
+
107
+ headers |= user_headers
108
+ body |= user_body
109
+
110
+ self.model_extra_config |= {
111
+ "extra_headers": headers,
112
+ "extra_body": body,
113
+ }
114
+
115
+ logger.info(f"Model extra config: {self.model_extra_config}")
109
116
 
110
117
  if not self.model:
111
118
  self.model = LiteLlm(
veadk/agent_builder.py ADDED
@@ -0,0 +1,94 @@
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 importlib
16
+
17
+ from google.adk.agents import BaseAgent
18
+ from omegaconf import OmegaConf
19
+
20
+ from veadk.a2a.remote_ve_agent import RemoteVeAgent
21
+ from veadk.agent import Agent
22
+ from veadk.agents.loop_agent import LoopAgent
23
+ from veadk.agents.parallel_agent import ParallelAgent
24
+ from veadk.agents.sequential_agent import SequentialAgent
25
+ from veadk.utils.logger import get_logger
26
+
27
+ logger = get_logger(__name__)
28
+
29
+ AGENT_TYPES = {
30
+ "Agent": Agent,
31
+ "SequentialAgent": SequentialAgent,
32
+ "ParallelAgent": ParallelAgent,
33
+ "LoopAgent": LoopAgent,
34
+ "RemoteVeAgent": RemoteVeAgent,
35
+ }
36
+
37
+
38
+ class AgentBuilder:
39
+ def __init__(self) -> None:
40
+ pass
41
+
42
+ def _build(self, agent_config: dict) -> BaseAgent:
43
+ logger.info(f"Building agent with config: {agent_config}")
44
+
45
+ sub_agents = []
46
+ if agent_config.get("sub_agents", None):
47
+ for sub_agent_config in agent_config["sub_agents"]:
48
+ agent = self._build(sub_agent_config)
49
+ sub_agents.append(agent)
50
+ agent_config.pop("sub_agents")
51
+
52
+ tools = []
53
+ if agent_config.get("tools", []):
54
+ for tool in agent_config["tools"]:
55
+ module_name = tool["module"]
56
+ func_name = tool["func"]
57
+
58
+ module = importlib.import_module(module_name)
59
+ func = getattr(module, func_name)
60
+
61
+ tools.append(func)
62
+ agent_config.pop("tools")
63
+
64
+ agent_cls = AGENT_TYPES[agent_config["type"]]
65
+ agent = agent_cls(**agent_config, sub_agents=sub_agents, tools=tools)
66
+
67
+ logger.debug("Build agent done.")
68
+
69
+ return agent
70
+
71
+ def _read_config(self, path: str) -> dict:
72
+ """Read config file (from `path`) to a in-memory dict."""
73
+ assert path.endswith(".yaml"), "Agent config file must be a `.yaml` file."
74
+
75
+ config = OmegaConf.load(path)
76
+ config_dict = OmegaConf.to_container(config, resolve=True)
77
+
78
+ assert isinstance(config_dict, dict), (
79
+ "Parsed config must in `dict` format. Pls check your building file format."
80
+ )
81
+
82
+ return config_dict
83
+
84
+ def build(
85
+ self,
86
+ path: str,
87
+ root_agent_identifier: str = "root_agent",
88
+ ) -> BaseAgent:
89
+ config = self._read_config(path)
90
+
91
+ agent_config = config[root_agent_identifier]
92
+ agent = self._build(agent_config)
93
+
94
+ return agent
veadk/auth/__init__.py ADDED
@@ -0,0 +1,13 @@
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.
@@ -0,0 +1,22 @@
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
+ class BaseAuth:
17
+ def __init__(self) -> None: ...
18
+
19
+ def _fetch_token(self) -> str | dict: ...
20
+
21
+ @property
22
+ def token(self) -> str | dict: ...
@@ -0,0 +1,13 @@
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.
@@ -0,0 +1,65 @@
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 os
16
+
17
+ from typing_extensions import override
18
+
19
+ from veadk.auth.veauth.base_veauth import BaseVeAuth
20
+ from veadk.utils.logger import get_logger
21
+ from veadk.utils.volcengine_sign import ve_request
22
+
23
+ logger = get_logger(__name__)
24
+
25
+
26
+ class APMPlusVeAuth(BaseVeAuth):
27
+ def __init__(
28
+ self,
29
+ access_key: str = os.getenv("VOLCENGINE_ACCESS_KEY", ""),
30
+ secret_key: str = os.getenv("VOLCENGINE_SECRET_KEY", ""),
31
+ region: str = "cn-beijing",
32
+ ) -> None:
33
+ super().__init__(access_key, secret_key)
34
+
35
+ self.region = region
36
+
37
+ self._token: str = ""
38
+
39
+ @override
40
+ def _fetch_token(self) -> None:
41
+ logger.info("Fetching APMPlus token...")
42
+
43
+ res = ve_request(
44
+ request_body={},
45
+ action="GetAppKey",
46
+ ak=self.access_key,
47
+ sk=self.secret_key,
48
+ service="apmplus_server",
49
+ version="2024-07-30",
50
+ region=self.region,
51
+ host="open.volcengineapi.com",
52
+ # APMPlus frontend required
53
+ header={"X-Apmplus-Region": self.region.replace("-", "_")},
54
+ )
55
+ try:
56
+ self._token = res["data"]["app_key"]
57
+ except KeyError:
58
+ raise ValueError(f"Failed to get APMPlus token: {res}")
59
+
60
+ @property
61
+ def token(self) -> str:
62
+ if self._token:
63
+ return self._token
64
+ self._fetch_token()
65
+ return self._token
@@ -0,0 +1,77 @@
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 os
16
+
17
+ from typing_extensions import override
18
+
19
+ from veadk.auth.veauth.base_veauth import BaseVeAuth
20
+ from veadk.utils.logger import get_logger
21
+ from veadk.utils.volcengine_sign import ve_request
22
+
23
+ logger = get_logger(__name__)
24
+
25
+
26
+ class ARKVeAuth(BaseVeAuth):
27
+ def __init__(
28
+ self,
29
+ access_key: str = os.getenv("VOLCENGINE_ACCESS_KEY", ""),
30
+ secret_key: str = os.getenv("VOLCENGINE_SECRET_KEY", ""),
31
+ ) -> None:
32
+ super().__init__(access_key, secret_key)
33
+
34
+ self._token: str = ""
35
+
36
+ @override
37
+ def _fetch_token(self) -> None:
38
+ logger.info("Fetching ARK token...")
39
+ # list api keys
40
+ first_api_key_id = ""
41
+ res = ve_request(
42
+ request_body={"ProjectName": "default", "Filter": {}},
43
+ action="ListApiKeys",
44
+ ak=self.access_key,
45
+ sk=self.secret_key,
46
+ service="ark",
47
+ version="2024-01-01",
48
+ region="cn-beijing",
49
+ host="open.volcengineapi.com",
50
+ )
51
+ try:
52
+ first_api_key_id = res["Result"]["Items"][0]["Id"]
53
+ except KeyError:
54
+ raise ValueError(f"Failed to get ARK api key list: {res}")
55
+
56
+ # get raw api key
57
+ res = ve_request(
58
+ request_body={"Id": first_api_key_id},
59
+ action="GetRawApiKey",
60
+ ak=self.access_key,
61
+ sk=self.secret_key,
62
+ service="ark",
63
+ version="2024-01-01",
64
+ region="cn-beijing",
65
+ host="open.volcengineapi.com",
66
+ )
67
+ try:
68
+ self._token = res["Result"]["ApiKey"]
69
+ except KeyError:
70
+ raise ValueError(f"Failed to get ARK api key: {res}")
71
+
72
+ @property
73
+ def token(self) -> str:
74
+ if self._token:
75
+ return self._token
76
+ self._fetch_token()
77
+ return self._token
@@ -0,0 +1,50 @@
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 os
16
+ from abc import ABC, abstractmethod
17
+
18
+ from veadk.auth.base_auth import BaseAuth
19
+
20
+
21
+ class BaseVeAuth(ABC, BaseAuth):
22
+ volcengine_access_key: str
23
+ """Volcengine Access Key"""
24
+
25
+ volcengine_secret_key: str
26
+ """Volcengine Secret Key"""
27
+
28
+ def __init__(
29
+ self,
30
+ access_key: str | None = None,
31
+ secret_key: str | None = None,
32
+ ) -> None:
33
+ super().__init__()
34
+
35
+ final_ak = access_key or os.getenv("VOLCENGINE_ACCESS_KEY")
36
+ final_sk = secret_key or os.getenv("VOLCENGINE_SECRET_KEY")
37
+
38
+ assert final_ak, "Volcengine access key cannot be empty."
39
+ assert final_sk, "Volcengine secret key cannot be empty."
40
+
41
+ self.access_key = final_ak
42
+ self.secret_key = final_sk
43
+
44
+ self._token: str = ""
45
+
46
+ @abstractmethod
47
+ def _fetch_token(self) -> None: ...
48
+
49
+ @property
50
+ def token(self) -> str: ...
@@ -0,0 +1,13 @@
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.
@@ -0,0 +1,60 @@
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 os
16
+
17
+ from typing_extensions import override
18
+
19
+ from veadk.auth.veauth.base_veauth import BaseVeAuth
20
+ from veadk.utils.logger import get_logger
21
+ from veadk.utils.volcengine_sign import ve_request
22
+
23
+ logger = get_logger(__name__)
24
+
25
+
26
+ class PromptPilotVeAuth(BaseVeAuth):
27
+ def __init__(
28
+ self,
29
+ access_key: str = os.getenv("VOLCENGINE_ACCESS_KEY", ""),
30
+ secret_key: str = os.getenv("VOLCENGINE_SECRET_KEY", ""),
31
+ ) -> None:
32
+ super().__init__(access_key, secret_key)
33
+
34
+ self._token: str = ""
35
+
36
+ @override
37
+ def _fetch_token(self) -> None:
38
+ logger.info("Fetching Prompt Pilot token...")
39
+
40
+ res = ve_request(
41
+ request_body={},
42
+ action="GetOrCreatePromptPilotAPIKeys",
43
+ ak=self.access_key,
44
+ sk=self.secret_key,
45
+ service="ark",
46
+ version="2024-01-01",
47
+ region="cn-beijing",
48
+ host="open.volcengineapi.com",
49
+ )
50
+ try:
51
+ self._token = res["Result"]["APIKeys"][0]["APIKey"]
52
+ except KeyError:
53
+ raise ValueError(f"Failed to get Prompt Pilot token: {res}")
54
+
55
+ @property
56
+ def token(self) -> str:
57
+ if self._token:
58
+ return self._token
59
+ self._fetch_token()
60
+ return self._token
@@ -0,0 +1,62 @@
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 os
16
+
17
+ from typing_extensions import override
18
+
19
+ from veadk.auth.veauth.base_veauth import BaseVeAuth
20
+ from veadk.utils.logger import get_logger
21
+ from veadk.utils.volcengine_sign import ve_request
22
+
23
+ logger = get_logger(__name__)
24
+
25
+
26
+ class VesearchVeAuth(BaseVeAuth):
27
+ def __init__(
28
+ self,
29
+ access_key: str = os.getenv("VOLCENGINE_ACCESS_KEY", ""),
30
+ secret_key: str = os.getenv("VOLCENGINE_SECRET_KEY", ""),
31
+ ) -> None:
32
+ super().__init__(access_key, secret_key)
33
+
34
+ self._token: str = ""
35
+
36
+ @override
37
+ def _fetch_token(self):
38
+ logger.info("Fetching VeSearch token ...")
39
+
40
+ res = ve_request(
41
+ request_body={"biz_scene": "search_agent", "page": 1, "rows": 10},
42
+ action="ListAPIKeys",
43
+ ak=self.access_key,
44
+ sk=self.secret_key,
45
+ service="content_customization",
46
+ version="2025-01-01",
47
+ region="cn-beijing",
48
+ host="open.volcengineapi.com",
49
+ )
50
+ try:
51
+ self._token = res["Result"]["api_key_vos"][0]["api_key"]
52
+
53
+ logger.info("Fetching VeSearch token done.")
54
+ except KeyError:
55
+ raise ValueError(f"Failed to get VeSearch token: {res}")
56
+
57
+ @property
58
+ def token(self) -> str:
59
+ if self._token:
60
+ return self._token
61
+ self._fetch_token()
62
+ return self._token
veadk/cli/cli.py CHANGED
@@ -19,6 +19,7 @@ from veadk.cli.cli_deploy import deploy
19
19
  from veadk.cli.cli_init import init
20
20
  from veadk.cli.cli_prompt import prompt
21
21
  from veadk.cli.cli_web import web
22
+ from veadk.cli.cli_pipeline import pipeline
22
23
  from veadk.version import VERSION
23
24
 
24
25
 
@@ -35,6 +36,7 @@ veadk.add_command(deploy)
35
36
  veadk.add_command(init)
36
37
  veadk.add_command(prompt)
37
38
  veadk.add_command(web)
39
+ veadk.add_command(pipeline)
38
40
 
39
41
  if __name__ == "__main__":
40
42
  veadk()
veadk/cli/cli_deploy.py CHANGED
@@ -15,6 +15,8 @@
15
15
 
16
16
  import click
17
17
 
18
+ from veadk.version import VERSION
19
+
18
20
  TEMP_PATH = "/tmp"
19
21
 
20
22
 
@@ -85,8 +87,8 @@ def deploy(
85
87
  tmp_dir_name = f"{user_proj_abs_path.name}_{formatted_timestamp()}"
86
88
 
87
89
  settings = {
88
- "local_dir_name": tmp_dir_name,
89
- "app_name": user_proj_abs_path.name,
90
+ "local_dir_name": tmp_dir_name.replace("-", "_"),
91
+ "app_name": user_proj_abs_path.name.replace("-", "_"),
90
92
  "agent_module_name": user_proj_abs_path.name,
91
93
  "short_term_memory_backend": short_term_memory_backend,
92
94
  "vefaas_application_name": vefaas_app_name,
@@ -94,6 +96,7 @@ def deploy(
94
96
  "veapig_service_name": veapig_service_name,
95
97
  "veapig_upstream_name": veapig_upstream_name,
96
98
  "use_adk_web": use_adk_web,
99
+ "veadk_version": VERSION,
97
100
  }
98
101
 
99
102
  cookiecutter(
veadk/cli/cli_init.py CHANGED
@@ -17,6 +17,8 @@ from typing import Any
17
17
 
18
18
  import click
19
19
 
20
+ from veadk.version import VERSION
21
+
20
22
  warnings.filterwarnings(
21
23
  "ignore", category=UserWarning, module="pydantic._internal._fields"
22
24
  )
@@ -58,12 +60,21 @@ def _render_prompts() -> dict[str, Any]:
58
60
  "veapig_service_name": veapig_service_name,
59
61
  "veapig_upstream_name": veapig_upstream_name,
60
62
  "use_adk_web": deploy_mode == "2",
63
+ "veadk_version": VERSION,
61
64
  }
62
65
 
63
66
 
64
67
  @click.command()
65
- def init() -> None:
66
- """Init a veadk project that can be deployed to Volcengine VeFaaS."""
68
+ @click.option(
69
+ "--vefaas-template-type", default="template", help="Expected template type"
70
+ )
71
+ def init(
72
+ vefaas_template_type: str,
73
+ ) -> None:
74
+ """Init a veadk project that can be deployed to Volcengine VeFaaS.
75
+
76
+ `template` is A2A/MCP/Web server template, `web_template` is for web applications (i.e., a simple blog).
77
+ """
67
78
  import shutil
68
79
  from pathlib import Path
69
80
 
@@ -71,9 +82,14 @@ def init() -> None:
71
82
 
72
83
  import veadk.integrations.ve_faas as vefaas
73
84
 
74
- click.echo(
75
- "Welcome use VeADK to create your project. We will generate a `weather-reporter` application for you."
76
- )
85
+ if vefaas_template_type == "web_template":
86
+ click.echo(
87
+ "Welcome use VeADK to create your project. We will generate a `simple-blog` web application for you."
88
+ )
89
+ else:
90
+ click.echo(
91
+ "Welcome use VeADK to create your project. We will generate a `weather-reporter` application for you."
92
+ )
77
93
 
78
94
  cwd = Path.cwd()
79
95
  local_dir_name = click.prompt("Local directory name", default="veadk-cloud-proj")
@@ -89,7 +105,10 @@ def init() -> None:
89
105
  settings = _render_prompts()
90
106
  settings["local_dir_name"] = local_dir_name
91
107
 
92
- template_dir_path = Path(vefaas.__file__).parent / "template"
108
+ if not vefaas_template_type:
109
+ vefaas_template_type = "template"
110
+
111
+ template_dir_path = Path(vefaas.__file__).parent / vefaas_template_type
93
112
 
94
113
  cookiecutter(
95
114
  template=str(template_dir_path),