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.
- veadk/agent.py +29 -22
- veadk/agent_builder.py +94 -0
- veadk/auth/__init__.py +13 -0
- veadk/auth/base_auth.py +22 -0
- veadk/auth/veauth/__init__.py +13 -0
- veadk/auth/veauth/apmplus_veauth.py +65 -0
- veadk/auth/veauth/ark_veauth.py +77 -0
- veadk/auth/veauth/base_veauth.py +50 -0
- veadk/auth/veauth/cozeloop_veauth.py +13 -0
- veadk/auth/veauth/prompt_pilot_veauth.py +60 -0
- veadk/auth/veauth/vesearch_veauth.py +62 -0
- veadk/cli/cli.py +2 -0
- veadk/cli/cli_deploy.py +5 -2
- veadk/cli/cli_init.py +25 -6
- veadk/cli/cli_pipeline.py +220 -0
- veadk/cli/cli_prompt.py +4 -4
- veadk/config.py +45 -81
- veadk/configs/__init__.py +13 -0
- veadk/configs/database_configs.py +83 -0
- veadk/configs/model_configs.py +42 -0
- veadk/configs/tool_configs.py +42 -0
- veadk/configs/tracing_configs.py +110 -0
- veadk/consts.py +32 -1
- veadk/database/database_adapter.py +256 -3
- veadk/database/kv/redis_database.py +47 -0
- veadk/database/local_database.py +23 -4
- veadk/database/relational/mysql_database.py +58 -0
- veadk/database/vector/opensearch_vector_database.py +6 -3
- veadk/database/viking/viking_database.py +272 -36
- 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/template/cookiecutter.json +3 -2
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/deploy.py +2 -2
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/agent.py +1 -1
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py +24 -1
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/requirements.txt +3 -1
- veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/run.sh +1 -12
- veadk/integrations/ve_faas/ve_faas.py +352 -35
- veadk/integrations/ve_faas/web_template/cookiecutter.json +17 -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 +41 -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_prompt_pilot/ve_prompt_pilot.py +6 -3
- veadk/integrations/ve_tls/__init__.py +13 -0
- veadk/integrations/ve_tls/utils.py +117 -0
- veadk/integrations/ve_tls/ve_tls.py +208 -0
- veadk/integrations/ve_tos/ve_tos.py +128 -73
- veadk/knowledgebase/knowledgebase.py +116 -20
- veadk/memory/long_term_memory.py +20 -21
- veadk/memory/short_term_memory_processor.py +9 -4
- veadk/runner.py +213 -223
- veadk/tools/builtin_tools/vesearch.py +2 -2
- veadk/tools/builtin_tools/video_generate.py +27 -20
- veadk/tracing/telemetry/attributes/extractors/common_attributes_extractors.py +5 -0
- veadk/tracing/telemetry/attributes/extractors/llm_attributes_extractors.py +253 -129
- veadk/tracing/telemetry/attributes/extractors/types.py +15 -4
- veadk/tracing/telemetry/exporters/apmplus_exporter.py +158 -12
- veadk/tracing/telemetry/exporters/cozeloop_exporter.py +4 -9
- veadk/tracing/telemetry/exporters/tls_exporter.py +4 -10
- veadk/tracing/telemetry/opentelemetry_tracer.py +11 -5
- veadk/tracing/telemetry/telemetry.py +23 -5
- veadk/utils/logger.py +1 -1
- veadk/utils/misc.py +48 -0
- veadk/utils/volcengine_sign.py +6 -2
- veadk/version.py +1 -1
- {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/METADATA +2 -1
- veadk_python-0.2.7.dist-info/RECORD +172 -0
- veadk_python-0.2.5.dist-info/RECORD +0 -127
- /veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{{ cookiecutter.app_name|replace('-', '_') }} → {{ cookiecutter.app_name }}}/__init__.py +0 -0
- /veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/{{{ cookiecutter.app_name|replace('-', '_') }} → {{ cookiecutter.app_name }}}/agent.py +0 -0
- {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/WHEEL +0 -0
- {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/entry_points.txt +0 -0
- {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/licenses/LICENSE +0 -0
- {veadk_python-0.2.5.dist-info → veadk_python-0.2.7.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
vecr = VeCR(
|
|
41
|
+
access_key=volcengine_settings["volcengine_access_key"],
|
|
42
|
+
secret_key=volcengine_settings["volcengine_secret_key"],
|
|
43
|
+
region=volcengine_settings["volcengine_region"],
|
|
44
|
+
)
|
|
45
|
+
try:
|
|
46
|
+
vecr._create_instance(cr_settings["cr_instance_name"])
|
|
47
|
+
except Exception as e:
|
|
48
|
+
click.echo(f"Failed to create CR instance: {e}")
|
|
49
|
+
raise
|
|
50
|
+
|
|
51
|
+
try:
|
|
52
|
+
vecr._create_namespace(
|
|
53
|
+
instance_name=cr_settings["cr_instance_name"],
|
|
54
|
+
namespace_name=cr_settings["cr_namespace_name"],
|
|
55
|
+
)
|
|
56
|
+
except Exception as e:
|
|
57
|
+
click.echo(f"Failed to create CR namespace: {e}")
|
|
58
|
+
raise
|
|
59
|
+
|
|
60
|
+
try:
|
|
61
|
+
vecr._create_repo(
|
|
62
|
+
instance_name=cr_settings["cr_instance_name"],
|
|
63
|
+
namespace_name=cr_settings["cr_namespace_name"],
|
|
64
|
+
repo_name=cr_settings["cr_repo_name"],
|
|
65
|
+
)
|
|
66
|
+
except Exception as e:
|
|
67
|
+
click.echo(f"Failed to create CR repo: {e}")
|
|
68
|
+
raise
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@click.command()
|
|
72
|
+
@click.option(
|
|
73
|
+
"--veadk-version",
|
|
74
|
+
default=VERSION,
|
|
75
|
+
help=f"Base VeADK image tag can be 'preview', 'latest', or a specific VeADK version (e.g., {VERSION})",
|
|
76
|
+
)
|
|
77
|
+
@click.option(
|
|
78
|
+
"--github-url",
|
|
79
|
+
required=True,
|
|
80
|
+
help="The github url of your project",
|
|
81
|
+
)
|
|
82
|
+
@click.option(
|
|
83
|
+
"--github-branch",
|
|
84
|
+
required=True,
|
|
85
|
+
help="The github branch of your project",
|
|
86
|
+
)
|
|
87
|
+
@click.option(
|
|
88
|
+
"--github-token",
|
|
89
|
+
required=True,
|
|
90
|
+
help="The github token to manage your project",
|
|
91
|
+
)
|
|
92
|
+
@click.option(
|
|
93
|
+
"--volcengine-access-key",
|
|
94
|
+
default=None,
|
|
95
|
+
help="Volcengine access key, if not set, will use the value of environment variable VOLCENGINE_ACCESS_KEY",
|
|
96
|
+
)
|
|
97
|
+
@click.option(
|
|
98
|
+
"--volcengine-secret-key",
|
|
99
|
+
default=None,
|
|
100
|
+
help="Volcengine secret key, if not set, will use the value of environment variable VOLCENGINE_SECRET_KEY",
|
|
101
|
+
)
|
|
102
|
+
@click.option(
|
|
103
|
+
"--region",
|
|
104
|
+
default="cn-beijing",
|
|
105
|
+
help="Region for Volcengine VeFaaS, CR, and Pipeline. Default is cn-beijing",
|
|
106
|
+
)
|
|
107
|
+
@click.option(
|
|
108
|
+
"--cr-instance-name",
|
|
109
|
+
default=DEFAULT_CR_INSTANCE_NAME,
|
|
110
|
+
help="Volcengine Container Registry instance name, default is veadk-user-instance",
|
|
111
|
+
)
|
|
112
|
+
@click.option(
|
|
113
|
+
"--cr-namespace-name",
|
|
114
|
+
default=DEFAULT_CR_NAMESPACE_NAME,
|
|
115
|
+
help="Volcengine Container Registry namespace name, default is veadk-user-namespace",
|
|
116
|
+
)
|
|
117
|
+
@click.option(
|
|
118
|
+
"--cr-repo-name",
|
|
119
|
+
default=DEFAULT_CR_REPO_NAME,
|
|
120
|
+
help="Volcengine Container Registry repo name, default is veadk-user-repo",
|
|
121
|
+
)
|
|
122
|
+
@click.option(
|
|
123
|
+
"--vefaas-function-id",
|
|
124
|
+
default=None,
|
|
125
|
+
help="Volcengine FaaS function ID, if not set, a new function will be created automatically",
|
|
126
|
+
)
|
|
127
|
+
def pipeline(
|
|
128
|
+
veadk_version: str,
|
|
129
|
+
github_url: str,
|
|
130
|
+
github_branch: str,
|
|
131
|
+
github_token: str,
|
|
132
|
+
volcengine_access_key: str,
|
|
133
|
+
volcengine_secret_key: str,
|
|
134
|
+
region: str,
|
|
135
|
+
cr_instance_name: str,
|
|
136
|
+
cr_namespace_name: str,
|
|
137
|
+
cr_repo_name: str,
|
|
138
|
+
vefaas_function_id: str,
|
|
139
|
+
) -> None:
|
|
140
|
+
"""Integrate a veadk project to volcengine pipeline for CI/CD"""
|
|
141
|
+
|
|
142
|
+
click.echo(
|
|
143
|
+
"Welcome use VeADK to integrate your project to volcengine pipeline for CI/CD."
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
if not volcengine_access_key:
|
|
147
|
+
volcengine_access_key = getenv("VOLCENGINE_ACCESS_KEY")
|
|
148
|
+
if not volcengine_secret_key:
|
|
149
|
+
volcengine_secret_key = getenv("VOLCENGINE_SECRET_KEY")
|
|
150
|
+
|
|
151
|
+
volcengine_settings = {
|
|
152
|
+
"volcengine_access_key": volcengine_access_key,
|
|
153
|
+
"volcengine_secret_key": volcengine_secret_key,
|
|
154
|
+
"volcengine_region": region,
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
cr_settings = {
|
|
158
|
+
"cr_domain": f"{cr_instance_name}-{region}.cr.volces.com",
|
|
159
|
+
"cr_instance_name": cr_instance_name,
|
|
160
|
+
"cr_namespace_name": cr_namespace_name,
|
|
161
|
+
"cr_repo_name": cr_repo_name,
|
|
162
|
+
"cr_region": region,
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if not vefaas_function_id:
|
|
166
|
+
click.echo(
|
|
167
|
+
"No Function ID specified. VeADK will create one automatically. Please specify a function name:"
|
|
168
|
+
)
|
|
169
|
+
function_name = click.prompt(
|
|
170
|
+
"Function name", default="veadk-image-function", show_default=False
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
_create_cr(volcengine_settings, cr_settings)
|
|
174
|
+
|
|
175
|
+
if not vefaas_function_id:
|
|
176
|
+
vefaas_client = VeFaaS(
|
|
177
|
+
access_key=volcengine_settings["volcengine_access_key"],
|
|
178
|
+
secret_key=volcengine_settings["volcengine_secret_key"],
|
|
179
|
+
region=volcengine_settings["volcengine_region"],
|
|
180
|
+
)
|
|
181
|
+
_, _, function_id = vefaas_client.deploy_image(
|
|
182
|
+
name=function_name,
|
|
183
|
+
image="veadk-cn-beijing.cr.volces.com/veadk/simple-fastapi:0.1",
|
|
184
|
+
registry_name=cr_settings["cr_instance_name"],
|
|
185
|
+
)
|
|
186
|
+
logger.debug(f"Created function {function_name} with ID: {function_id}")
|
|
187
|
+
|
|
188
|
+
client = VeCodePipeline(
|
|
189
|
+
volcengine_access_key=volcengine_settings["volcengine_access_key"],
|
|
190
|
+
volcengine_secret_key=volcengine_settings["volcengine_secret_key"],
|
|
191
|
+
region=volcengine_settings["volcengine_region"],
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
click.echo("=====================================================")
|
|
195
|
+
click.echo("Using the following configuration to create pipeline:")
|
|
196
|
+
click.echo(f"Use VeADK version: {veadk_version}")
|
|
197
|
+
click.echo(f"Github url: {github_url}")
|
|
198
|
+
click.echo(f"Github branch: {github_branch}")
|
|
199
|
+
click.echo(f"VeFaaS function name: {function_name}")
|
|
200
|
+
click.echo(f"VeFaaS function ID: {function_id}")
|
|
201
|
+
click.echo(f"Container Registry domain: {cr_settings['cr_domain']}")
|
|
202
|
+
click.echo(f"Container Registry namespace name: {cr_settings['cr_namespace_name']}")
|
|
203
|
+
click.echo(f"Container Registry region: {region}")
|
|
204
|
+
click.echo(f"Container Registry instance name: {cr_settings['cr_instance_name']}")
|
|
205
|
+
click.echo(f"Container Registry repo name: {cr_settings['cr_repo_name']}")
|
|
206
|
+
|
|
207
|
+
client.deploy(
|
|
208
|
+
base_image_tag=veadk_version,
|
|
209
|
+
github_url=github_url,
|
|
210
|
+
github_branch=github_branch,
|
|
211
|
+
github_token=github_token,
|
|
212
|
+
cr_domain=cr_settings["cr_domain"],
|
|
213
|
+
cr_namespace_name=cr_settings["cr_namespace_name"],
|
|
214
|
+
cr_region=cr_settings["cr_region"],
|
|
215
|
+
cr_instance_name=cr_settings["cr_instance_name"],
|
|
216
|
+
cr_repo_name=cr_settings["cr_repo_name"],
|
|
217
|
+
function_id=function_id,
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
click.echo("Pipeline has been created successfully.")
|
veadk/cli/cli_prompt.py
CHANGED
|
@@ -19,8 +19,8 @@ import click
|
|
|
19
19
|
@click.option(
|
|
20
20
|
"--path", default=".", help="Agent file path with global variable `agent=...`"
|
|
21
21
|
)
|
|
22
|
-
@click.option("--feedback", default=
|
|
23
|
-
@click.option("--api-key", default=
|
|
22
|
+
@click.option("--feedback", default="", help="Suggestions for prompt optimization")
|
|
23
|
+
@click.option("--api-key", default="", help="API Key of PromptPilot")
|
|
24
24
|
@click.option(
|
|
25
25
|
"--model-name",
|
|
26
26
|
default="doubao-1.5-pro-32k-250115",
|
|
@@ -31,7 +31,7 @@ def prompt(path: str, feedback: str, api_key: str, model_name: str) -> None:
|
|
|
31
31
|
from pathlib import Path
|
|
32
32
|
|
|
33
33
|
from veadk.agent import Agent
|
|
34
|
-
from veadk.config import
|
|
34
|
+
from veadk.config import settings
|
|
35
35
|
from veadk.integrations.ve_prompt_pilot.ve_prompt_pilot import VePromptPilot
|
|
36
36
|
from veadk.utils.misc import load_module_from_file
|
|
37
37
|
|
|
@@ -55,7 +55,7 @@ def prompt(path: str, feedback: str, api_key: str, model_name: str) -> None:
|
|
|
55
55
|
click.echo(f"Found {len(agents)} agents in {module_abs_path}")
|
|
56
56
|
|
|
57
57
|
if not api_key:
|
|
58
|
-
api_key =
|
|
58
|
+
api_key = settings.prompt_pilot.api_key
|
|
59
59
|
ve_prompt_pilot = VePromptPilot(api_key)
|
|
60
60
|
ve_prompt_pilot.optimize(
|
|
61
61
|
agents=agents, feedback=feedback, model_name=model_name
|
veadk/config.py
CHANGED
|
@@ -13,95 +13,48 @@
|
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
15
|
import os
|
|
16
|
-
from typing import Any
|
|
16
|
+
from typing import Any
|
|
17
17
|
|
|
18
18
|
from dotenv import find_dotenv
|
|
19
|
-
from
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
from pydantic import BaseModel, Field
|
|
20
|
+
|
|
21
|
+
from veadk.configs.database_configs import (
|
|
22
|
+
MysqlConfig,
|
|
23
|
+
OpensearchConfig,
|
|
24
|
+
RedisConfig,
|
|
25
|
+
TOSConfig,
|
|
26
|
+
VikingKnowledgebaseConfig,
|
|
25
27
|
)
|
|
28
|
+
from veadk.configs.model_configs import ModelConfig
|
|
29
|
+
from veadk.configs.tool_configs import BuiltinToolConfigs, PromptPilotConfig
|
|
30
|
+
from veadk.configs.tracing_configs import (
|
|
31
|
+
APMPlusConfig,
|
|
32
|
+
CozeloopConfig,
|
|
33
|
+
PrometheusConfig,
|
|
34
|
+
TLSConfig,
|
|
35
|
+
)
|
|
36
|
+
from veadk.utils.misc import set_envs
|
|
26
37
|
|
|
27
|
-
settings = None
|
|
28
|
-
veadk_environments = {}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
def flatten_dict(
|
|
32
|
-
d: MutableMapping[str, Any], parent_key: str = "", sep: str = "_"
|
|
33
|
-
) -> Dict[str, Any]:
|
|
34
|
-
"""Flatten a nested dictionary, using a separator in the keys.
|
|
35
|
-
Useful for pydantic_v1 models with nested fields -- first use
|
|
36
|
-
dct = mdl.model_dump()
|
|
37
|
-
to get a nested dictionary, then use this function to flatten it.
|
|
38
|
-
"""
|
|
39
|
-
items: List[Tuple[str, Any]] = []
|
|
40
|
-
for k, v in d.items():
|
|
41
|
-
new_key = f"{parent_key}{sep}{k}" if parent_key else k
|
|
42
|
-
if isinstance(v, MutableMapping):
|
|
43
|
-
items.extend(flatten_dict(v, new_key, sep=sep).items())
|
|
44
|
-
else:
|
|
45
|
-
items.append((new_key, v))
|
|
46
|
-
return dict(items)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
class Settings(BaseSettings):
|
|
50
|
-
model_config = SettingsConfigDict(
|
|
51
|
-
yaml_file=find_dotenv(filename="config.yaml", usecwd=True), extra="allow"
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
@classmethod
|
|
55
|
-
def settings_customise_sources(
|
|
56
|
-
cls,
|
|
57
|
-
settings_cls: type[BaseSettings],
|
|
58
|
-
init_settings: PydanticBaseSettingsSource,
|
|
59
|
-
env_settings: PydanticBaseSettingsSource,
|
|
60
|
-
dotenv_settings: PydanticBaseSettingsSource,
|
|
61
|
-
file_secret_settings: PydanticBaseSettingsSource,
|
|
62
|
-
) -> tuple[PydanticBaseSettingsSource, ...]:
|
|
63
|
-
yaml_source = YamlConfigSettingsSource(settings_cls)
|
|
64
|
-
raw_data = yaml_source()
|
|
65
|
-
flat_data = flatten_dict(raw_data)
|
|
66
|
-
|
|
67
|
-
init_source = InitSettingsSource(settings_cls, flat_data)
|
|
68
|
-
return (
|
|
69
|
-
init_source,
|
|
70
|
-
env_settings,
|
|
71
|
-
dotenv_settings,
|
|
72
|
-
file_secret_settings,
|
|
73
|
-
)
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def prepare_settings():
|
|
77
|
-
path = find_dotenv(filename="config.yaml", usecwd=True)
|
|
78
|
-
|
|
79
|
-
if path == "" or path is None or not os.path.exists(path):
|
|
80
|
-
# logger.warning(
|
|
81
|
-
# "Default and recommanded config file `config.yaml` not found. Please put it in the root directory of your project."
|
|
82
|
-
# )
|
|
83
|
-
pass
|
|
84
|
-
else:
|
|
85
|
-
# logger.info(f"Loading config file from {path}")
|
|
86
|
-
global settings
|
|
87
|
-
settings = Settings()
|
|
88
|
-
|
|
89
|
-
for k, v in settings.model_dump().items():
|
|
90
|
-
global veadk_environments
|
|
91
|
-
|
|
92
|
-
k = k.upper()
|
|
93
|
-
if k in os.environ:
|
|
94
|
-
veadk_environments[k] = os.environ[k]
|
|
95
|
-
continue
|
|
96
|
-
veadk_environments[k] = str(v)
|
|
97
|
-
os.environ[k] = str(v)
|
|
98
38
|
|
|
39
|
+
class VeADKConfig(BaseModel):
|
|
40
|
+
model: ModelConfig = Field(default_factory=ModelConfig)
|
|
41
|
+
"""Config for agent reasoning model."""
|
|
99
42
|
|
|
100
|
-
|
|
43
|
+
tool: BuiltinToolConfigs = Field(default_factory=BuiltinToolConfigs)
|
|
44
|
+
prompt_pilot: PromptPilotConfig = Field(default_factory=PromptPilotConfig)
|
|
101
45
|
|
|
46
|
+
apmplus_config: APMPlusConfig = Field(default_factory=APMPlusConfig)
|
|
47
|
+
cozeloop_config: CozeloopConfig = Field(default_factory=CozeloopConfig)
|
|
48
|
+
tls_config: TLSConfig = Field(default_factory=TLSConfig)
|
|
49
|
+
prometheus_config: PrometheusConfig = Field(default_factory=PrometheusConfig)
|
|
102
50
|
|
|
103
|
-
|
|
104
|
-
|
|
51
|
+
tos: TOSConfig = Field(default_factory=TOSConfig)
|
|
52
|
+
opensearch: OpensearchConfig = Field(default_factory=OpensearchConfig)
|
|
53
|
+
mysql: MysqlConfig = Field(default_factory=MysqlConfig)
|
|
54
|
+
redis: RedisConfig = Field(default_factory=RedisConfig)
|
|
55
|
+
viking_knowledgebase: VikingKnowledgebaseConfig = Field(
|
|
56
|
+
default_factory=VikingKnowledgebaseConfig
|
|
57
|
+
)
|
|
105
58
|
|
|
106
59
|
|
|
107
60
|
def getenv(
|
|
@@ -129,3 +82,14 @@ def getenv(
|
|
|
129
82
|
raise ValueError(
|
|
130
83
|
f"The environment variable `{env_name}` not exists. Please set this in your environment variable or config.yaml."
|
|
131
84
|
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
config_yaml_path = find_dotenv(filename="config.yaml", usecwd=True)
|
|
88
|
+
|
|
89
|
+
veadk_environments = {}
|
|
90
|
+
|
|
91
|
+
if config_yaml_path:
|
|
92
|
+
config_dict, _veadk_environments = set_envs(config_yaml_path=config_yaml_path)
|
|
93
|
+
veadk_environments.update(_veadk_environments)
|
|
94
|
+
|
|
95
|
+
settings = VeADKConfig()
|
|
@@ -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,83 @@
|
|
|
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 functools import cached_property
|
|
17
|
+
|
|
18
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
19
|
+
|
|
20
|
+
from veadk.consts import DEFAULT_TOS_BUCKET_NAME
|
|
21
|
+
from veadk.integrations.ve_tos.ve_tos import VeTOS
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class OpensearchConfig(BaseSettings):
|
|
25
|
+
model_config = SettingsConfigDict(env_prefix="DATABASE_OPENSEARCH_")
|
|
26
|
+
|
|
27
|
+
host: str = ""
|
|
28
|
+
|
|
29
|
+
port: int = 9200
|
|
30
|
+
|
|
31
|
+
username: str = ""
|
|
32
|
+
|
|
33
|
+
password: str = ""
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class MysqlConfig(BaseSettings):
|
|
37
|
+
model_config = SettingsConfigDict(env_prefix="DATABASE_MYSQL_")
|
|
38
|
+
|
|
39
|
+
host: str = ""
|
|
40
|
+
|
|
41
|
+
user: str = ""
|
|
42
|
+
|
|
43
|
+
password: str = ""
|
|
44
|
+
|
|
45
|
+
database: str = ""
|
|
46
|
+
|
|
47
|
+
charset: str = "utf8"
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class RedisConfig(BaseSettings):
|
|
51
|
+
model_config = SettingsConfigDict(env_prefix="DATABASE_REDIS_")
|
|
52
|
+
|
|
53
|
+
host: str = ""
|
|
54
|
+
|
|
55
|
+
port: int = 6379
|
|
56
|
+
|
|
57
|
+
password: str = ""
|
|
58
|
+
|
|
59
|
+
db: int = 0
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
class VikingKnowledgebaseConfig(BaseSettings):
|
|
63
|
+
model_config = SettingsConfigDict(env_prefix="DATABASE_VIKING_")
|
|
64
|
+
|
|
65
|
+
project: str = "default"
|
|
66
|
+
"""User project in Volcengine console web."""
|
|
67
|
+
|
|
68
|
+
region: str = "cn-beijing"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class TOSConfig(BaseSettings):
|
|
72
|
+
model_config = SettingsConfigDict(env_prefix="DATABASE_TOS_")
|
|
73
|
+
|
|
74
|
+
endpoint: str = "tos-cn-beijing.volces.com"
|
|
75
|
+
|
|
76
|
+
region: str = "cn-beijing"
|
|
77
|
+
|
|
78
|
+
@cached_property
|
|
79
|
+
def bucket(self) -> str:
|
|
80
|
+
_bucket = os.getenv("DATABASE_TOS_BUCKET") or DEFAULT_TOS_BUCKET_NAME
|
|
81
|
+
|
|
82
|
+
VeTOS(bucket_name=_bucket).create_bucket()
|
|
83
|
+
return _bucket
|
|
@@ -0,0 +1,42 @@
|
|
|
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 functools import cached_property
|
|
17
|
+
|
|
18
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
19
|
+
|
|
20
|
+
from veadk.auth.veauth.ark_veauth import ARKVeAuth
|
|
21
|
+
from veadk.consts import (
|
|
22
|
+
DEFAULT_MODEL_AGENT_API_BASE,
|
|
23
|
+
DEFAULT_MODEL_AGENT_NAME,
|
|
24
|
+
DEFAULT_MODEL_AGENT_PROVIDER,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ModelConfig(BaseSettings):
|
|
29
|
+
model_config = SettingsConfigDict(env_prefix="MODEL_AGENT_")
|
|
30
|
+
|
|
31
|
+
name: str = DEFAULT_MODEL_AGENT_NAME
|
|
32
|
+
"""Model name for agent reasoning."""
|
|
33
|
+
|
|
34
|
+
provider: str = DEFAULT_MODEL_AGENT_PROVIDER
|
|
35
|
+
"""Model provider for LiteLLM initialization."""
|
|
36
|
+
|
|
37
|
+
api_base: str = DEFAULT_MODEL_AGENT_API_BASE
|
|
38
|
+
"""The api base of the model for agent reasoning."""
|
|
39
|
+
|
|
40
|
+
@cached_property
|
|
41
|
+
def api_key(self) -> str:
|
|
42
|
+
return os.getenv("MODEL_AGENT_API_KEY") or ARKVeAuth().token
|
|
@@ -0,0 +1,42 @@
|
|
|
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 functools import cached_property
|
|
17
|
+
|
|
18
|
+
from pydantic import BaseModel, Field
|
|
19
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
20
|
+
|
|
21
|
+
from veadk.auth.veauth.prompt_pilot_veauth import PromptPilotVeAuth
|
|
22
|
+
from veadk.auth.veauth.vesearch_veauth import VesearchVeAuth
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class PromptPilotConfig(BaseModel):
|
|
26
|
+
@cached_property
|
|
27
|
+
def api_key(self) -> str:
|
|
28
|
+
return os.getenv("PROMPT_PILOT_API_KEY") or PromptPilotVeAuth().token
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class VeSearchConfig(BaseSettings):
|
|
32
|
+
model_config = SettingsConfigDict(env_prefix="TOOL_VESEARCH_")
|
|
33
|
+
|
|
34
|
+
endpoint: int | str = ""
|
|
35
|
+
|
|
36
|
+
@cached_property
|
|
37
|
+
def api_key(self) -> str:
|
|
38
|
+
return os.getenv("TOOL_VESEARCH_API_KEY") or VesearchVeAuth().token
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class BuiltinToolConfigs(BaseModel):
|
|
42
|
+
vesearch: VeSearchConfig = Field(default_factory=VeSearchConfig)
|
|
@@ -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
|
+
import os
|
|
16
|
+
from functools import cached_property
|
|
17
|
+
|
|
18
|
+
from pydantic import Field
|
|
19
|
+
from pydantic_settings import BaseSettings, SettingsConfigDict
|
|
20
|
+
|
|
21
|
+
from veadk.auth.veauth.apmplus_veauth import APMPlusVeAuth
|
|
22
|
+
from veadk.consts import (
|
|
23
|
+
DEFAULT_APMPLUS_OTEL_EXPORTER_ENDPOINT,
|
|
24
|
+
DEFAULT_APMPLUS_OTEL_EXPORTER_SERVICE_NAME,
|
|
25
|
+
DEFAULT_COZELOOP_OTEL_EXPORTER_ENDPOINT,
|
|
26
|
+
DEFAULT_COZELOOP_SPACE_NAME,
|
|
27
|
+
DEFAULT_TLS_OTEL_EXPORTER_ENDPOINT,
|
|
28
|
+
DEFAULT_TLS_OTEL_EXPORTER_REGION,
|
|
29
|
+
)
|
|
30
|
+
from veadk.integrations.ve_cozeloop.ve_cozeloop import VeCozeloop
|
|
31
|
+
from veadk.integrations.ve_tls.ve_tls import VeTLS
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class APMPlusConfig(BaseSettings):
|
|
35
|
+
otel_exporter_endpoint: str = Field(
|
|
36
|
+
default=DEFAULT_APMPLUS_OTEL_EXPORTER_ENDPOINT,
|
|
37
|
+
alias="OBSERVABILITY_OPENTELEMETRY_APMPLUS_ENDPOINT",
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
otel_exporter_service_name: str = Field(
|
|
41
|
+
default=DEFAULT_APMPLUS_OTEL_EXPORTER_SERVICE_NAME,
|
|
42
|
+
alias="OBSERVABILITY_OPENTELEMETRY_APMPLUS_SERVICE_NAME",
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
@cached_property
|
|
46
|
+
def otel_exporter_api_key(self) -> str:
|
|
47
|
+
return (
|
|
48
|
+
os.getenv("OBSERVABILITY_OPENTELEMETRY_APMPLUS_API_KEY")
|
|
49
|
+
or APMPlusVeAuth().token
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class CozeloopConfig(BaseSettings):
|
|
54
|
+
otel_exporter_endpoint: str = Field(
|
|
55
|
+
default=DEFAULT_COZELOOP_OTEL_EXPORTER_ENDPOINT,
|
|
56
|
+
alias="OBSERVABILITY_OPENTELEMETRY_COZELOOP_ENDPOINT",
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
otel_exporter_api_key: str = Field(
|
|
60
|
+
default="", alias="OBSERVABILITY_OPENTELEMETRY_COZELOOP_API_KEY"
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
# TODO: auto fetching via AK/SK pair
|
|
64
|
+
# @cached_property
|
|
65
|
+
# def otel_exporter_api_key(self) -> str:
|
|
66
|
+
# pass
|
|
67
|
+
|
|
68
|
+
@cached_property
|
|
69
|
+
def otel_exporter_space_id(self) -> str:
|
|
70
|
+
workspace_id = os.getenv(
|
|
71
|
+
"OBSERVABILITY_OPENTELEMETRY_COZELOOP_SERVICE_NAME", ""
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
if not workspace_id:
|
|
75
|
+
# create a default one
|
|
76
|
+
workspace_id = VeCozeloop(self.otel_exporter_api_key).create_workspace(
|
|
77
|
+
workspace_name=DEFAULT_COZELOOP_SPACE_NAME
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
return workspace_id
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
class TLSConfig(BaseSettings):
|
|
84
|
+
otel_exporter_endpoint: str = Field(
|
|
85
|
+
default=DEFAULT_TLS_OTEL_EXPORTER_ENDPOINT,
|
|
86
|
+
alias="OBSERVABILITY_OPENTELEMETRY_TLS_ENDPOINT",
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
otel_exporter_region: str = Field(
|
|
90
|
+
default=DEFAULT_TLS_OTEL_EXPORTER_REGION,
|
|
91
|
+
alias="OBSERVABILITY_OPENTELEMETRY_TLS_REGION",
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
@cached_property
|
|
95
|
+
def otel_exporter_topic_id(self) -> str:
|
|
96
|
+
_topic_id = (
|
|
97
|
+
os.getenv("OBSERVABILITY_OPENTELEMETRY_TLS_SERVICE_NAME")
|
|
98
|
+
or VeTLS().get_trace_topic_id()
|
|
99
|
+
)
|
|
100
|
+
return _topic_id
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class PrometheusConfig(BaseSettings):
|
|
104
|
+
model_config = SettingsConfigDict(env_prefix="OBSERVABILITY_PROMETHEUS_")
|
|
105
|
+
|
|
106
|
+
pushgateway_url: str = ""
|
|
107
|
+
|
|
108
|
+
pushgateway_username: str = ""
|
|
109
|
+
|
|
110
|
+
pushgateway_password: str = ""
|