veadk-python 0.2.6__py3-none-any.whl → 0.2.8__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 (102) hide show
  1. veadk/agent.py +11 -18
  2. veadk/agent_builder.py +94 -0
  3. veadk/{database/__init__.py → auth/base_auth.py} +7 -2
  4. veadk/auth/veauth/apmplus_veauth.py +65 -0
  5. veadk/auth/veauth/ark_veauth.py +77 -0
  6. veadk/auth/veauth/base_veauth.py +50 -0
  7. veadk/auth/veauth/opensearch_veauth.py +75 -0
  8. veadk/auth/veauth/postgresql_veauth.py +75 -0
  9. veadk/auth/veauth/prompt_pilot_veauth.py +60 -0
  10. veadk/auth/veauth/vesearch_veauth.py +62 -0
  11. veadk/cli/cli.py +4 -0
  12. veadk/cli/cli_deploy.py +3 -2
  13. veadk/cli/cli_eval.py +160 -0
  14. veadk/cli/cli_init.py +1 -1
  15. veadk/cli/cli_pipeline.py +220 -0
  16. veadk/cli/cli_prompt.py +4 -4
  17. veadk/cli/cli_web.py +3 -1
  18. veadk/config.py +45 -81
  19. veadk/configs/database_configs.py +117 -0
  20. veadk/configs/model_configs.py +74 -0
  21. veadk/configs/tool_configs.py +42 -0
  22. veadk/configs/tracing_configs.py +110 -0
  23. veadk/consts.py +13 -1
  24. veadk/evaluation/base_evaluator.py +60 -44
  25. veadk/evaluation/deepeval_evaluator/deepeval_evaluator.py +18 -12
  26. veadk/evaluation/eval_set_recorder.py +2 -2
  27. veadk/integrations/ve_code_pipeline/__init__.py +13 -0
  28. veadk/integrations/ve_code_pipeline/ve_code_pipeline.py +431 -0
  29. veadk/integrations/ve_cozeloop/__init__.py +13 -0
  30. veadk/integrations/ve_cozeloop/ve_cozeloop.py +96 -0
  31. veadk/integrations/ve_cr/ve_cr.py +20 -5
  32. veadk/integrations/ve_faas/template/cookiecutter.json +1 -1
  33. veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/deploy.py +2 -2
  34. veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/agent.py +1 -1
  35. veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/run.sh +1 -5
  36. veadk/integrations/ve_faas/ve_faas.py +351 -36
  37. veadk/integrations/ve_prompt_pilot/ve_prompt_pilot.py +6 -3
  38. veadk/integrations/ve_tls/__init__.py +13 -0
  39. veadk/integrations/ve_tls/utils.py +117 -0
  40. veadk/integrations/ve_tls/ve_tls.py +208 -0
  41. veadk/integrations/ve_tos/ve_tos.py +71 -75
  42. veadk/knowledgebase/backends/__init__.py +13 -0
  43. veadk/knowledgebase/backends/base_backend.py +59 -0
  44. veadk/knowledgebase/backends/in_memory_backend.py +82 -0
  45. veadk/knowledgebase/backends/opensearch_backend.py +136 -0
  46. veadk/knowledgebase/backends/redis_backend.py +144 -0
  47. veadk/knowledgebase/backends/utils.py +91 -0
  48. veadk/knowledgebase/backends/vikingdb_knowledge_backend.py +412 -0
  49. veadk/knowledgebase/knowledgebase.py +109 -55
  50. veadk/memory/__init__.py +22 -0
  51. veadk/memory/long_term_memory.py +120 -51
  52. veadk/memory/long_term_memory_backends/__init__.py +13 -0
  53. veadk/{database/base_database.py → memory/long_term_memory_backends/base_backend.py} +10 -22
  54. veadk/memory/long_term_memory_backends/in_memory_backend.py +65 -0
  55. veadk/memory/long_term_memory_backends/opensearch_backend.py +120 -0
  56. veadk/memory/long_term_memory_backends/redis_backend.py +127 -0
  57. veadk/memory/long_term_memory_backends/vikingdb_memory_backend.py +148 -0
  58. veadk/memory/short_term_memory.py +80 -72
  59. veadk/memory/short_term_memory_backends/__init__.py +13 -0
  60. veadk/memory/short_term_memory_backends/base_backend.py +31 -0
  61. veadk/memory/short_term_memory_backends/mysql_backend.py +41 -0
  62. veadk/memory/short_term_memory_backends/postgresql_backend.py +41 -0
  63. veadk/memory/short_term_memory_backends/sqlite_backend.py +48 -0
  64. veadk/memory/short_term_memory_processor.py +9 -4
  65. veadk/runner.py +204 -247
  66. veadk/tools/builtin_tools/vesearch.py +2 -2
  67. veadk/tools/builtin_tools/video_generate.py +27 -20
  68. veadk/tools/builtin_tools/web_scraper.py +1 -1
  69. veadk/tools/builtin_tools/web_search.py +7 -7
  70. veadk/tools/load_knowledgebase_tool.py +1 -1
  71. veadk/tracing/telemetry/attributes/extractors/llm_attributes_extractors.py +20 -2
  72. veadk/tracing/telemetry/exporters/apmplus_exporter.py +178 -14
  73. veadk/tracing/telemetry/exporters/cozeloop_exporter.py +6 -9
  74. veadk/tracing/telemetry/exporters/inmemory_exporter.py +22 -8
  75. veadk/tracing/telemetry/exporters/tls_exporter.py +6 -10
  76. veadk/tracing/telemetry/opentelemetry_tracer.py +5 -8
  77. veadk/tracing/telemetry/telemetry.py +66 -60
  78. veadk/utils/logger.py +1 -1
  79. veadk/utils/misc.py +63 -0
  80. veadk/utils/volcengine_sign.py +6 -2
  81. veadk/version.py +1 -1
  82. {veadk_python-0.2.6.dist-info → veadk_python-0.2.8.dist-info}/METADATA +16 -3
  83. {veadk_python-0.2.6.dist-info → veadk_python-0.2.8.dist-info}/RECORD +93 -64
  84. veadk/database/database_adapter.py +0 -368
  85. veadk/database/database_factory.py +0 -80
  86. veadk/database/kv/redis_database.py +0 -159
  87. veadk/database/local_database.py +0 -61
  88. veadk/database/relational/mysql_database.py +0 -173
  89. veadk/database/vector/opensearch_vector_database.py +0 -263
  90. veadk/database/vector/type.py +0 -50
  91. veadk/database/viking/viking_database.py +0 -471
  92. veadk/database/viking/viking_memory_db.py +0 -525
  93. /veadk/{database/kv → auth}/__init__.py +0 -0
  94. /veadk/{database/relational → auth/veauth}/__init__.py +0 -0
  95. /veadk/{database/vector/__init__.py → auth/veauth/cozeloop_veauth.py} +0 -0
  96. /veadk/{database/viking → configs}/__init__.py +0 -0
  97. /veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{{ cookiecutter.app_name|replace('-', '_') }} → {{ cookiecutter.app_name }}}/__init__.py +0 -0
  98. /veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{{ cookiecutter.app_name|replace('-', '_') }} → {{ cookiecutter.app_name }}}/agent.py +0 -0
  99. {veadk_python-0.2.6.dist-info → veadk_python-0.2.8.dist-info}/WHEEL +0 -0
  100. {veadk_python-0.2.6.dist-info → veadk_python-0.2.8.dist-info}/entry_points.txt +0 -0
  101. {veadk_python-0.2.6.dist-info → veadk_python-0.2.8.dist-info}/licenses/LICENSE +0 -0
  102. {veadk_python-0.2.6.dist-info → veadk_python-0.2.8.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,11 +26,9 @@ 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_API_BASE,
32
- DEFAULT_MODEL_AGENT_NAME,
33
- DEFAULT_MODEL_AGENT_PROVIDER,
31
+ DEFAULT_AGENT_NAME,
34
32
  DEFAULT_MODEL_EXTRA_CONFIG,
35
33
  )
36
34
  from veadk.evaluation import EvalSetRecorder
@@ -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,9 +93,6 @@ 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
 
@@ -201,7 +196,6 @@ class Agent(LlmAgent):
201
196
  collect_runtime_data: bool = False,
202
197
  eval_set_id: str = "",
203
198
  save_session_to_memory: bool = False,
204
- enable_memory_optimization: bool = False,
205
199
  ):
206
200
  """Running the agent. The runner and session service will be created automatically.
207
201
 
@@ -231,7 +225,6 @@ class Agent(LlmAgent):
231
225
  # memory service
232
226
  short_term_memory = ShortTermMemory(
233
227
  backend="database" if load_history_sessions_from_db else "local",
234
- enable_memory_optimization=enable_memory_optimization,
235
228
  db_url=db_url,
236
229
  )
237
230
  session_service = short_term_memory.session_service
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
@@ -12,6 +12,11 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- from .database_factory import DatabaseFactory
16
15
 
17
- __all__ = ["DatabaseFactory"]
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,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,75 @@
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
+ # Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
16
+ #
17
+ # Licensed under the Apache License, Version 2.0 (the "License");
18
+ # you may not use this file except in compliance with the License.
19
+ # You may obtain a copy of the License at
20
+ #
21
+ # http://www.apache.org/licenses/LICENSE-2.0
22
+ #
23
+ # Unless required by applicable law or agreed to in writing, software
24
+ # distributed under the License is distributed on an "AS IS" BASIS,
25
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ # See the License for the specific language governing permissions and
27
+ # limitations under the License.
28
+
29
+ import os
30
+
31
+ from typing_extensions import override
32
+
33
+ from veadk.auth.veauth.base_veauth import BaseVeAuth
34
+ from veadk.utils.logger import get_logger
35
+
36
+ # from veadk.utils.volcengine_sign import ve_request
37
+
38
+ logger = get_logger(__name__)
39
+
40
+
41
+ class OpensearchVeAuth(BaseVeAuth):
42
+ def __init__(
43
+ self,
44
+ access_key: str = os.getenv("VOLCENGINE_ACCESS_KEY", ""),
45
+ secret_key: str = os.getenv("VOLCENGINE_SECRET_KEY", ""),
46
+ ) -> None:
47
+ super().__init__(access_key, secret_key)
48
+
49
+ self._token: str = ""
50
+
51
+ @override
52
+ def _fetch_token(self) -> None:
53
+ logger.info("Fetching Opensearch STS token...")
54
+
55
+ # res = ve_request(
56
+ # request_body={},
57
+ # action="GetOrCreatePromptPilotAPIKeys",
58
+ # ak=self.access_key,
59
+ # sk=self.secret_key,
60
+ # service="ark",
61
+ # version="2024-01-01",
62
+ # region="cn-beijing",
63
+ # host="open.volcengineapi.com",
64
+ # )
65
+ # try:
66
+ # self._token = res["Result"]["APIKeys"][0]["APIKey"]
67
+ # except KeyError:
68
+ # raise ValueError(f"Failed to get Prompt Pilot token: {res}")
69
+
70
+ @property
71
+ def token(self) -> str:
72
+ if self._token:
73
+ return self._token
74
+ self._fetch_token()
75
+ return self._token
@@ -0,0 +1,75 @@
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
+ # Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
16
+ #
17
+ # Licensed under the Apache License, Version 2.0 (the "License");
18
+ # you may not use this file except in compliance with the License.
19
+ # You may obtain a copy of the License at
20
+ #
21
+ # http://www.apache.org/licenses/LICENSE-2.0
22
+ #
23
+ # Unless required by applicable law or agreed to in writing, software
24
+ # distributed under the License is distributed on an "AS IS" BASIS,
25
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ # See the License for the specific language governing permissions and
27
+ # limitations under the License.
28
+
29
+ import os
30
+
31
+ from typing_extensions import override
32
+
33
+ from veadk.auth.veauth.base_veauth import BaseVeAuth
34
+ from veadk.utils.logger import get_logger
35
+
36
+ # from veadk.utils.volcengine_sign import ve_request
37
+
38
+ logger = get_logger(__name__)
39
+
40
+
41
+ class PostgreSqlVeAuth(BaseVeAuth):
42
+ def __init__(
43
+ self,
44
+ access_key: str = os.getenv("VOLCENGINE_ACCESS_KEY", ""),
45
+ secret_key: str = os.getenv("VOLCENGINE_SECRET_KEY", ""),
46
+ ) -> None:
47
+ super().__init__(access_key, secret_key)
48
+
49
+ self._token: str = ""
50
+
51
+ @override
52
+ def _fetch_token(self) -> None:
53
+ logger.info("Fetching PostgreSQL STS token...")
54
+
55
+ # res = ve_request(
56
+ # request_body={},
57
+ # action="GetOrCreatePromptPilotAPIKeys",
58
+ # ak=self.access_key,
59
+ # sk=self.secret_key,
60
+ # service="ark",
61
+ # version="2024-01-01",
62
+ # region="cn-beijing",
63
+ # host="open.volcengineapi.com",
64
+ # )
65
+ # try:
66
+ # self._token = res["Result"]["APIKeys"][0]["APIKey"]
67
+ # except KeyError:
68
+ # raise ValueError(f"Failed to get Prompt Pilot token: {res}")
69
+
70
+ @property
71
+ def token(self) -> str:
72
+ if self._token:
73
+ return self._token
74
+ self._fetch_token()
75
+ return self._token
@@ -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
@@ -16,7 +16,9 @@
16
16
  import click
17
17
 
18
18
  from veadk.cli.cli_deploy import deploy
19
+ from veadk.cli.cli_eval import eval
19
20
  from veadk.cli.cli_init import init
21
+ from veadk.cli.cli_pipeline import pipeline
20
22
  from veadk.cli.cli_prompt import prompt
21
23
  from veadk.cli.cli_web import web
22
24
  from veadk.version import VERSION
@@ -35,6 +37,8 @@ veadk.add_command(deploy)
35
37
  veadk.add_command(init)
36
38
  veadk.add_command(prompt)
37
39
  veadk.add_command(web)
40
+ veadk.add_command(pipeline)
41
+ veadk.add_command(eval)
38
42
 
39
43
  if __name__ == "__main__":
40
44
  veadk()