veadk-python 0.2.14__py3-none-any.whl → 0.2.16__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 +39 -0
- veadk/cli/cli_create.py +20 -40
- veadk/cli/cli_web.py +60 -151
- veadk/config.py +12 -1
- veadk/tools/builtin_tools/generate_image.py +23 -0
- veadk/tools/builtin_tools/run_code.py +5 -1
- veadk/tracing/telemetry/opentelemetry_tracer.py +6 -3
- veadk/utils/misc.py +7 -0
- veadk/version.py +1 -1
- {veadk_python-0.2.14.dist-info → veadk_python-0.2.16.dist-info}/METADATA +1 -1
- {veadk_python-0.2.14.dist-info → veadk_python-0.2.16.dist-info}/RECORD +15 -14
- {veadk_python-0.2.14.dist-info → veadk_python-0.2.16.dist-info}/WHEEL +0 -0
- {veadk_python-0.2.14.dist-info → veadk_python-0.2.16.dist-info}/entry_points.txt +0 -0
- {veadk_python-0.2.14.dist-info → veadk_python-0.2.16.dist-info}/licenses/LICENSE +0 -0
- {veadk_python-0.2.14.dist-info → veadk_python-0.2.16.dist-info}/top_level.txt +0 -0
veadk/agent.py
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
from __future__ import annotations
|
|
16
16
|
|
|
17
|
+
import os
|
|
17
18
|
from typing import Optional, Union
|
|
18
19
|
|
|
19
20
|
from google.adk.agents import LlmAgent, RunConfig
|
|
@@ -132,6 +133,8 @@ class Agent(LlmAgent):
|
|
|
132
133
|
"You are trying to use your own LiteLLM client, some default request headers may be missing."
|
|
133
134
|
)
|
|
134
135
|
|
|
136
|
+
self._prepare_tracers()
|
|
137
|
+
|
|
135
138
|
if self.knowledgebase:
|
|
136
139
|
from veadk.tools.builtin_tools.load_knowledgebase import (
|
|
137
140
|
LoadKnowledgebaseTool,
|
|
@@ -194,6 +197,42 @@ class Agent(LlmAgent):
|
|
|
194
197
|
|
|
195
198
|
return final_output
|
|
196
199
|
|
|
200
|
+
def _prepare_tracers(self):
|
|
201
|
+
enable_apmplus_tracer = os.getenv("ENABLE_APMPLUS", "false").lower() == "true"
|
|
202
|
+
enable_cozeloop_tracer = os.getenv("ENABLE_COZELOOP", "false").lower() == "true"
|
|
203
|
+
enable_tls_tracer = os.getenv("ENABLE_TLS", "false").lower() == "true"
|
|
204
|
+
|
|
205
|
+
if not self.tracers:
|
|
206
|
+
from veadk.tracing.telemetry.opentelemetry_tracer import OpentelemetryTracer
|
|
207
|
+
|
|
208
|
+
self.tracers.append(OpentelemetryTracer())
|
|
209
|
+
|
|
210
|
+
exporters = self.tracers[0].exporters # type: ignore
|
|
211
|
+
|
|
212
|
+
from veadk.tracing.telemetry.exporters.apmplus_exporter import APMPlusExporter
|
|
213
|
+
from veadk.tracing.telemetry.exporters.cozeloop_exporter import CozeloopExporter
|
|
214
|
+
from veadk.tracing.telemetry.exporters.tls_exporter import TLSExporter
|
|
215
|
+
|
|
216
|
+
if enable_apmplus_tracer and not any(
|
|
217
|
+
isinstance(e, APMPlusExporter) for e in exporters
|
|
218
|
+
):
|
|
219
|
+
self.tracers[0].exporters.append(APMPlusExporter()) # type: ignore
|
|
220
|
+
logger.info("Enable APMPlus exporter by env.")
|
|
221
|
+
|
|
222
|
+
if enable_cozeloop_tracer and not any(
|
|
223
|
+
isinstance(e, CozeloopExporter) for e in exporters
|
|
224
|
+
):
|
|
225
|
+
self.tracers[0].exporters.append(CozeloopExporter()) # type: ignore
|
|
226
|
+
logger.info("Enable CozeLoop exporter by env.")
|
|
227
|
+
|
|
228
|
+
if enable_tls_tracer and not any(isinstance(e, TLSExporter) for e in exporters):
|
|
229
|
+
self.tracers[0].exporters.append(TLSExporter()) # type: ignore
|
|
230
|
+
logger.info("Enable TLS exporter by env.")
|
|
231
|
+
|
|
232
|
+
logger.debug(
|
|
233
|
+
f"Opentelemetry Tracer init {len(self.tracers[0].exporters)} exporters" # type: ignore
|
|
234
|
+
)
|
|
235
|
+
|
|
197
236
|
async def run(
|
|
198
237
|
self,
|
|
199
238
|
prompt: str | list[str],
|
veadk/cli/cli_create.py
CHANGED
|
@@ -16,26 +16,8 @@ import click
|
|
|
16
16
|
import shutil
|
|
17
17
|
from pathlib import Path
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
agent:
|
|
22
|
-
name: doubao-seed-1-6-251015
|
|
23
|
-
api_key: {ark_api_key}
|
|
24
|
-
video:
|
|
25
|
-
name: doubao-seedance-1-0-pro-250528
|
|
26
|
-
# if you want to use different api_key, just uncomment following line and complete api_key
|
|
27
|
-
# api_key:
|
|
28
|
-
image:
|
|
29
|
-
name: doubao-seedream-4-0-250828
|
|
30
|
-
# if you want to use different api_key, just uncomment following line and complete api_key
|
|
31
|
-
# api_key:
|
|
32
|
-
|
|
33
|
-
logging:
|
|
34
|
-
# ERROR
|
|
35
|
-
# WARNING
|
|
36
|
-
# INFO
|
|
37
|
-
# DEBUG
|
|
38
|
-
level: DEBUG
|
|
19
|
+
_ENV_TEMPLATE = """\
|
|
20
|
+
MODEL_AGENT_API_KEY={ark_api_key}
|
|
39
21
|
"""
|
|
40
22
|
|
|
41
23
|
_INIT_PY_TEMPLATE = """\
|
|
@@ -49,16 +31,17 @@ root_agent = Agent(
|
|
|
49
31
|
name="root_agent",
|
|
50
32
|
description="A helpful assistant for user questions.",
|
|
51
33
|
instruction="Answer user questions to the best of your knowledge",
|
|
34
|
+
model_name="doubao-seed-1-6-251015", # <---- you can change your model here
|
|
52
35
|
)
|
|
53
36
|
"""
|
|
54
37
|
|
|
55
38
|
_SUCCESS_MSG = """\
|
|
56
|
-
Agent
|
|
57
|
-
-
|
|
58
|
-
-
|
|
59
|
-
-
|
|
39
|
+
Agent created in {agent_folder}:
|
|
40
|
+
- .env
|
|
41
|
+
- __init__.py
|
|
42
|
+
- agent.py
|
|
60
43
|
|
|
61
|
-
You can run the agent by executing:
|
|
44
|
+
You can run the agent by executing: veadk web
|
|
62
45
|
"""
|
|
63
46
|
|
|
64
47
|
|
|
@@ -69,37 +52,34 @@ def _prompt_for_ark_api_key() -> str:
|
|
|
69
52
|
)
|
|
70
53
|
click.echo("You have two options:")
|
|
71
54
|
click.echo(" 1. Enter the API key now.")
|
|
72
|
-
click.echo(" 2. Configure it later in the generated
|
|
55
|
+
click.echo(" 2. Configure it later in the generated .env file.")
|
|
73
56
|
choice = click.prompt("Please select an option", type=click.Choice(["1", "2"]))
|
|
74
57
|
if choice == "1":
|
|
75
58
|
return click.prompt("Please enter your ARK API key")
|
|
76
59
|
else:
|
|
77
|
-
click.secho(
|
|
78
|
-
"You can set the `api_key` in the config.yaml file later.", fg="yellow"
|
|
79
|
-
)
|
|
60
|
+
click.secho("You can set the `api_key` in the .env file later.", fg="yellow")
|
|
80
61
|
return ""
|
|
81
62
|
|
|
82
63
|
|
|
83
|
-
def _generate_files(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
agent_file_path = agent_dir_path / "agent.py"
|
|
64
|
+
def _generate_files(ark_api_key: str, target_dir_path: Path) -> None:
|
|
65
|
+
target_dir_path.mkdir(exist_ok=True)
|
|
66
|
+
env_path = target_dir_path / ".env"
|
|
67
|
+
init_file_path = target_dir_path / "__init__.py"
|
|
68
|
+
agent_file_path = target_dir_path / "agent.py"
|
|
89
69
|
|
|
90
|
-
|
|
91
|
-
|
|
70
|
+
env_content = _ENV_TEMPLATE.format(ark_api_key=ark_api_key)
|
|
71
|
+
env_path.write_text(env_content)
|
|
92
72
|
init_file_path.write_text(_INIT_PY_TEMPLATE)
|
|
93
73
|
agent_file_path.write_text(_AGENT_PY_TEMPLATE)
|
|
94
74
|
|
|
95
75
|
click.secho(
|
|
96
|
-
_SUCCESS_MSG.format(
|
|
76
|
+
_SUCCESS_MSG.format(agent_folder=target_dir_path),
|
|
97
77
|
fg="green",
|
|
98
78
|
)
|
|
99
79
|
|
|
100
80
|
|
|
101
81
|
@click.command()
|
|
102
|
-
@click.
|
|
82
|
+
@click.argument("agent_name", required=False)
|
|
103
83
|
@click.option("--ark-api-key", help="The ARK API key.")
|
|
104
84
|
def create(agent_name: str, ark_api_key: str) -> None:
|
|
105
85
|
"""Creates a new agent in the current folder with prepopulated agent template."""
|
|
@@ -119,4 +99,4 @@ def create(agent_name: str, ark_api_key: str) -> None:
|
|
|
119
99
|
return
|
|
120
100
|
shutil.rmtree(target_dir_path)
|
|
121
101
|
|
|
122
|
-
_generate_files(
|
|
102
|
+
_generate_files(ark_api_key, target_dir_path)
|
veadk/cli/cli_web.py
CHANGED
|
@@ -12,99 +12,13 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
from
|
|
15
|
+
from functools import wraps
|
|
16
16
|
|
|
17
17
|
import click
|
|
18
18
|
|
|
19
|
-
from veadk.
|
|
20
|
-
from veadk.memory.short_term_memory import ShortTermMemory
|
|
19
|
+
from veadk.utils.logger import get_logger
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
def _get_stm_from_module(module) -> ShortTermMemory:
|
|
24
|
-
return module.agent_run_config.short_term_memory
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
def _get_stm_from_env() -> ShortTermMemory:
|
|
28
|
-
import os
|
|
29
|
-
|
|
30
|
-
from veadk.utils.logger import get_logger
|
|
31
|
-
|
|
32
|
-
logger = get_logger(__name__)
|
|
33
|
-
|
|
34
|
-
short_term_memory_backend = os.getenv("SHORT_TERM_MEMORY_BACKEND")
|
|
35
|
-
if not short_term_memory_backend: # prevent None or empty string
|
|
36
|
-
short_term_memory_backend = "local"
|
|
37
|
-
logger.info(f"Short term memory: backend={short_term_memory_backend}")
|
|
38
|
-
|
|
39
|
-
return ShortTermMemory(backend=short_term_memory_backend) # type: ignore
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def _get_ltm_from_module(module) -> LongTermMemory | None:
|
|
43
|
-
agent = module.agent_run_config.agent
|
|
44
|
-
|
|
45
|
-
if not hasattr(agent, "long_term_memory"):
|
|
46
|
-
return None
|
|
47
|
-
else:
|
|
48
|
-
return agent.long_term_memory
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def _get_ltm_from_env() -> LongTermMemory | None:
|
|
52
|
-
import os
|
|
53
|
-
|
|
54
|
-
from veadk.utils.logger import get_logger
|
|
55
|
-
|
|
56
|
-
logger = get_logger(__name__)
|
|
57
|
-
|
|
58
|
-
long_term_memory_backend = os.getenv("LONG_TERM_MEMORY_BACKEND")
|
|
59
|
-
app_name = os.getenv("VEADK_WEB_APP_NAME", "")
|
|
60
|
-
user_id = os.getenv("VEADK_WEB_USER_ID", "")
|
|
61
|
-
|
|
62
|
-
if long_term_memory_backend:
|
|
63
|
-
logger.info(f"Long term memory: backend={long_term_memory_backend}")
|
|
64
|
-
return LongTermMemory(
|
|
65
|
-
backend=long_term_memory_backend, app_name=app_name, user_id=user_id
|
|
66
|
-
) # type: ignore
|
|
67
|
-
else:
|
|
68
|
-
logger.warning("No long term memory backend settings detected.")
|
|
69
|
-
return None
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
def _get_memory(
|
|
73
|
-
module_path: str,
|
|
74
|
-
) -> tuple[ShortTermMemory, LongTermMemory | None]:
|
|
75
|
-
from veadk.utils.logger import get_logger
|
|
76
|
-
from veadk.utils.misc import load_module_from_file
|
|
77
|
-
|
|
78
|
-
logger = get_logger(__name__)
|
|
79
|
-
|
|
80
|
-
# 1. load user module
|
|
81
|
-
try:
|
|
82
|
-
module_file_path = module_path
|
|
83
|
-
module = load_module_from_file(
|
|
84
|
-
module_name="agent_and_mem", file_path=f"{module_file_path}/agent.py"
|
|
85
|
-
)
|
|
86
|
-
except Exception as e:
|
|
87
|
-
logger.error(
|
|
88
|
-
f"Failed to get memory config from `agent.py`: {e}. Fallback to get memory from environment variables."
|
|
89
|
-
)
|
|
90
|
-
return _get_stm_from_env(), _get_ltm_from_env()
|
|
91
|
-
|
|
92
|
-
if not hasattr(module, "agent_run_config"):
|
|
93
|
-
logger.error(
|
|
94
|
-
"You must export `agent_run_config` as a global variable in `agent.py`. Fallback to get memory from environment variables."
|
|
95
|
-
)
|
|
96
|
-
return _get_stm_from_env(), _get_ltm_from_env()
|
|
97
|
-
|
|
98
|
-
# 2. try to get short term memory
|
|
99
|
-
# short term memory must exist in user code, as we use `default_factory` to init it
|
|
100
|
-
short_term_memory = _get_stm_from_module(module)
|
|
101
|
-
|
|
102
|
-
# 3. try to get long term memory
|
|
103
|
-
long_term_memory = _get_ltm_from_module(module)
|
|
104
|
-
if not long_term_memory:
|
|
105
|
-
long_term_memory = _get_ltm_from_env()
|
|
106
|
-
|
|
107
|
-
return short_term_memory, long_term_memory
|
|
21
|
+
logger = get_logger(__name__)
|
|
108
22
|
|
|
109
23
|
|
|
110
24
|
def patch_adkwebserver_disable_openapi():
|
|
@@ -133,71 +47,66 @@ def patch_adkwebserver_disable_openapi():
|
|
|
133
47
|
google.adk.cli.adk_web_server.AdkWebServer.get_fast_api_app = wrapped_get_fast_api
|
|
134
48
|
|
|
135
49
|
|
|
136
|
-
@click.command(
|
|
137
|
-
|
|
138
|
-
@click.option(
|
|
139
|
-
"--app_name", default="", help="The `app_name` for initializing long term memory"
|
|
140
|
-
)
|
|
141
|
-
@click.option(
|
|
142
|
-
"--user_id", default="", help="The `user_id` for initializing long term memory"
|
|
50
|
+
@click.command(
|
|
51
|
+
context_settings=dict(ignore_unknown_options=True, allow_extra_args=True)
|
|
143
52
|
)
|
|
144
|
-
|
|
53
|
+
@click.pass_context
|
|
54
|
+
def web(ctx, *args, **kwargs) -> None:
|
|
145
55
|
"""Launch web with long term and short term memory."""
|
|
146
|
-
import
|
|
147
|
-
from
|
|
148
|
-
|
|
149
|
-
from
|
|
150
|
-
|
|
151
|
-
from veadk.
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
56
|
+
from google.adk.cli import adk_web_server
|
|
57
|
+
from google.adk.runners import Runner as ADKRunner
|
|
58
|
+
|
|
59
|
+
from veadk import Agent
|
|
60
|
+
from veadk.agents.loop_agent import LoopAgent
|
|
61
|
+
from veadk.agents.parallel_agent import ParallelAgent
|
|
62
|
+
from veadk.agents.sequential_agent import SequentialAgent
|
|
63
|
+
|
|
64
|
+
def before_get_runner_async(func):
|
|
65
|
+
logger.info("Hook before `get_runner_async`")
|
|
66
|
+
|
|
67
|
+
@wraps(func)
|
|
68
|
+
async def wrapper(*args, **kwargs) -> ADKRunner:
|
|
69
|
+
self: adk_web_server.AdkWebServer = args[0]
|
|
70
|
+
app_name: str = args[1]
|
|
71
|
+
"""Returns the cached runner for the given app."""
|
|
72
|
+
agent_or_app = self.agent_loader.load_agent(app_name)
|
|
73
|
+
|
|
74
|
+
if isinstance(agent_or_app, (SequentialAgent, LoopAgent, ParallelAgent)):
|
|
75
|
+
logger.warning(
|
|
76
|
+
"Detect VeADK workflow agent, the short-term memory and long-term memory of each sub agent are useless."
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
if isinstance(agent_or_app, Agent):
|
|
80
|
+
logger.info("Detect VeADK Agent.")
|
|
81
|
+
|
|
82
|
+
if agent_or_app.short_term_memory:
|
|
83
|
+
self.session_service = (
|
|
84
|
+
agent_or_app.short_term_memory.session_service
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
if agent_or_app.long_term_memory:
|
|
88
|
+
self.memory_service = agent_or_app.long_term_memory
|
|
89
|
+
logger.info(
|
|
90
|
+
f"Long term memory backend is {self.memory_service.backend}"
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
logger.info(
|
|
94
|
+
f"Current session_service={self.session_service.__class__.__name__}, memory_service={self.memory_service.__class__.__name__}"
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
runner = await func(*args, **kwargs)
|
|
98
|
+
return runner
|
|
99
|
+
|
|
100
|
+
return wrapper
|
|
101
|
+
|
|
102
|
+
adk_web_server.AdkWebServer.get_runner_async = before_get_runner_async(
|
|
103
|
+
adk_web_server.AdkWebServer.get_runner_async
|
|
104
|
+
)
|
|
192
105
|
|
|
193
|
-
google.adk.cli.adk_web_server.AdkWebServer.__init__ = init_for_veadk
|
|
194
106
|
patch_adkwebserver_disable_openapi()
|
|
195
107
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
agents_dir = os.getcwd()
|
|
199
|
-
logger.info(f"Load agents from {agents_dir}")
|
|
108
|
+
from google.adk.cli.cli_tools_click import cli_web
|
|
200
109
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
)
|
|
110
|
+
extra_args = ctx.args
|
|
111
|
+
logger.debug(f"User args: {ctx.args}")
|
|
112
|
+
cli_web.main(args=extra_args, standalone_mode=False)
|
veadk/config.py
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
import os
|
|
16
16
|
from typing import Any
|
|
17
17
|
|
|
18
|
-
from dotenv import find_dotenv
|
|
18
|
+
from dotenv import find_dotenv, load_dotenv
|
|
19
19
|
from pydantic import BaseModel, Field
|
|
20
20
|
|
|
21
21
|
from veadk.configs.database_configs import (
|
|
@@ -33,8 +33,16 @@ from veadk.configs.tracing_configs import (
|
|
|
33
33
|
PrometheusConfig,
|
|
34
34
|
TLSConfig,
|
|
35
35
|
)
|
|
36
|
+
from veadk.utils.logger import get_logger
|
|
36
37
|
from veadk.utils.misc import set_envs
|
|
37
38
|
|
|
39
|
+
logger = get_logger(__name__)
|
|
40
|
+
|
|
41
|
+
if load_dotenv(find_dotenv(usecwd=True)):
|
|
42
|
+
logger.info(f"Find `.env` file in {find_dotenv(usecwd=True)}, load envs.")
|
|
43
|
+
else:
|
|
44
|
+
logger.info("No env file found.")
|
|
45
|
+
|
|
38
46
|
|
|
39
47
|
class VeADKConfig(BaseModel):
|
|
40
48
|
model: ModelConfig = Field(default_factory=ModelConfig)
|
|
@@ -89,7 +97,10 @@ config_yaml_path = find_dotenv(filename="config.yaml", usecwd=True)
|
|
|
89
97
|
veadk_environments = {}
|
|
90
98
|
|
|
91
99
|
if config_yaml_path:
|
|
100
|
+
logger.info(f"Find `config.yaml` file in {config_yaml_path}")
|
|
92
101
|
config_dict, _veadk_environments = set_envs(config_yaml_path=config_yaml_path)
|
|
93
102
|
veadk_environments.update(_veadk_environments)
|
|
103
|
+
else:
|
|
104
|
+
logger.warning("No `config.yaml` file found.")
|
|
94
105
|
|
|
95
106
|
settings = VeADKConfig()
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from veadk.tools.builtin_tools.image_generate import image_generate # noqa: F401
|
|
16
|
+
from veadk.utils.logger import get_logger
|
|
17
|
+
|
|
18
|
+
logger = get_logger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
logger.warning(
|
|
22
|
+
"The 'generate_image' tool is deprecated and will be removed in future versions. Use `image_generate` tool from `veadk.tools.builtin_tools.image_generate` instead."
|
|
23
|
+
)
|
|
@@ -42,6 +42,10 @@ def run_code(code: str, language: str, tool_context: ToolContext) -> str:
|
|
|
42
42
|
region = getenv("AGENTKIT_TOOL_REGION", "cn-beijing")
|
|
43
43
|
|
|
44
44
|
session_id = tool_context._invocation_context.session.id
|
|
45
|
+
agent_name = tool_context._invocation_context.agent.name
|
|
46
|
+
user_id = tool_context._invocation_context.user_id
|
|
47
|
+
tool_user_session_id = agent_name + "_" + user_id + "_" + session_id
|
|
48
|
+
logger.debug(f"tool_user_session_id: {tool_user_session_id}")
|
|
45
49
|
|
|
46
50
|
logger.debug(
|
|
47
51
|
f"Running code in language: {language}, session_id={session_id}, code={code}, tool_id={tool_id}, host={host}, service={service}, region={region}"
|
|
@@ -53,7 +57,7 @@ def run_code(code: str, language: str, tool_context: ToolContext) -> str:
|
|
|
53
57
|
res = ve_request(
|
|
54
58
|
request_body={
|
|
55
59
|
"ToolId": tool_id,
|
|
56
|
-
"UserSessionId":
|
|
60
|
+
"UserSessionId": tool_user_session_id,
|
|
57
61
|
"OperationType": "RunCode",
|
|
58
62
|
"OperationPayload": json.dumps(
|
|
59
63
|
{
|
|
@@ -21,7 +21,7 @@ from typing import Any
|
|
|
21
21
|
from opentelemetry import trace as trace_api
|
|
22
22
|
from opentelemetry.sdk import trace as trace_sdk
|
|
23
23
|
from opentelemetry.sdk.resources import Resource
|
|
24
|
-
from opentelemetry.sdk.trace import
|
|
24
|
+
from opentelemetry.sdk.trace import SpanLimits, TracerProvider
|
|
25
25
|
from opentelemetry.sdk.trace.export import BatchSpanProcessor, SimpleSpanProcessor
|
|
26
26
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
27
27
|
from typing_extensions import override
|
|
@@ -31,8 +31,8 @@ from veadk.tracing.telemetry.exporters.apmplus_exporter import APMPlusExporter
|
|
|
31
31
|
from veadk.tracing.telemetry.exporters.base_exporter import BaseExporter
|
|
32
32
|
from veadk.tracing.telemetry.exporters.inmemory_exporter import InMemoryExporter
|
|
33
33
|
from veadk.utils.logger import get_logger
|
|
34
|
-
from veadk.utils.patches import patch_google_adk_telemetry
|
|
35
34
|
from veadk.utils.misc import get_temp_dir
|
|
35
|
+
from veadk.utils.patches import patch_google_adk_telemetry
|
|
36
36
|
|
|
37
37
|
logger = get_logger(__name__)
|
|
38
38
|
|
|
@@ -131,12 +131,15 @@ class OpentelemetryTracer(BaseModel, BaseTracer):
|
|
|
131
131
|
) + global_tracer_provider._active_span_processor._span_processors
|
|
132
132
|
|
|
133
133
|
self._processors.append(self._inmemory_exporter.processor)
|
|
134
|
+
self.exporters.append(self._inmemory_exporter)
|
|
134
135
|
else:
|
|
135
136
|
logger.warning(
|
|
136
137
|
"InMemoryExporter processor is not initialized, cannot add to OpentelemetryTracer."
|
|
137
138
|
)
|
|
138
139
|
|
|
139
|
-
logger.info(
|
|
140
|
+
logger.info(
|
|
141
|
+
f"Init OpentelemetryTracer with {len(self._processors)} exporter(s)."
|
|
142
|
+
)
|
|
140
143
|
|
|
141
144
|
@property
|
|
142
145
|
def trace_file_path(self) -> str:
|
veadk/utils/misc.py
CHANGED
|
@@ -128,6 +128,10 @@ def getenv(
|
|
|
128
128
|
|
|
129
129
|
|
|
130
130
|
def set_envs(config_yaml_path: str) -> tuple[dict, dict]:
|
|
131
|
+
from veadk.utils.logger import get_logger
|
|
132
|
+
|
|
133
|
+
logger = get_logger(__name__)
|
|
134
|
+
|
|
131
135
|
with open(config_yaml_path, "r", encoding="utf-8") as yaml_file:
|
|
132
136
|
config_dict = safe_load(yaml_file)
|
|
133
137
|
|
|
@@ -138,6 +142,9 @@ def set_envs(config_yaml_path: str) -> tuple[dict, dict]:
|
|
|
138
142
|
k = k.upper()
|
|
139
143
|
|
|
140
144
|
if k in os.environ:
|
|
145
|
+
logger.info(
|
|
146
|
+
f"Environment variable {k} has been set, value in `config.yaml` will be ignored."
|
|
147
|
+
)
|
|
141
148
|
veadk_environments[k] = os.environ[k]
|
|
142
149
|
continue
|
|
143
150
|
veadk_environments[k] = str(v)
|
veadk/version.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: veadk-python
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.16
|
|
4
4
|
Summary: Volcengine agent development kit, integrations with Volcengine cloud services.
|
|
5
5
|
Author-email: Yaozheng Fang <fangyozheng@gmail.com>, Guodong Li <cu.eric.lee@gmail.com>, Zhi Han <sliverydayday@gmail.com>, Meng Wang <mengwangwm@gmail.com>
|
|
6
6
|
License: Apache License
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
veadk/__init__.py,sha256=9l1lyb9ifhHQeetmIBWZnIdwUCVyMyz1EnKsKz8BBG8,1135
|
|
2
|
-
veadk/agent.py,sha256=
|
|
2
|
+
veadk/agent.py,sha256=YmT6Iu5UKro8S13URuDq9LIoP9ZQKZWuK2SA1AA_Fwo,12809
|
|
3
3
|
veadk/agent_builder.py,sha256=HI7mRrUZ72_7i-jVzNDx1anTZHy7UxX7jr2Drxxx6j8,3031
|
|
4
|
-
veadk/config.py,sha256=
|
|
4
|
+
veadk/config.py,sha256=pirKse9MH9RQmgepM41vgVg9_22t2aa_6i-yuTipnxk,3578
|
|
5
5
|
veadk/consts.py,sha256=8FcwnvKxQM50r8HDQxnhI-Ml_mjyfYdkGDxbyPBrW5Q,2679
|
|
6
6
|
veadk/runner.py,sha256=_DGNwX-t3sHJFJvHs-rRHXbjCZza8I_zU8AN3Fw5nRY,14217
|
|
7
7
|
veadk/types.py,sha256=zOOzG-QJy-MkzHeicWJzy2_L5U4ERrWziPubIUEbd8c,1656
|
|
8
|
-
veadk/version.py,sha256=
|
|
8
|
+
veadk/version.py,sha256=714odtak2c78LIi25wI3LP8hoXdf3L5pSNhC12OA6V0,654
|
|
9
9
|
veadk/a2a/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
|
|
10
10
|
veadk/a2a/agent_card.py,sha256=lhtgW1acMpxYUdULHEZwVFXOi6Xh4lNkf4S7QIhbFFI,1525
|
|
11
11
|
veadk/a2a/remote_ve_agent.py,sha256=L2nzT8PlDI-lLtcaTJqk-D2Uvw9beKl8OEUqp-8qCbA,3510
|
|
@@ -29,7 +29,7 @@ veadk/auth/veauth/utils.py,sha256=cVEKWQZeX5fzx3JLB1odv59D8lhOAF1Pb3rsgO6evmM,21
|
|
|
29
29
|
veadk/auth/veauth/vesearch_veauth.py,sha256=rgup3VBbRSLligrsDFOEwpneq1BEtFwf9xpgNFWHKqc,2008
|
|
30
30
|
veadk/cli/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
|
|
31
31
|
veadk/cli/cli.py,sha256=Iti595PE0g_R04njivyl0_fgNlPEYhCP-9j9ZkN80vQ,1496
|
|
32
|
-
veadk/cli/cli_create.py,sha256=
|
|
32
|
+
veadk/cli/cli_create.py,sha256=CSDGMSEgWVo87_mTlbCP_J1u2h-29QuYJhB07_PrD44,3302
|
|
33
33
|
veadk/cli/cli_deploy.py,sha256=-P4PmXLGByypXGksshBT7BQ0U42hIvlHibXd_k4YfhQ,5328
|
|
34
34
|
veadk/cli/cli_eval.py,sha256=TVSraCTyTxo_pLu5fhtk3TiZUOZkN3G2BLam1ybFXBc,5446
|
|
35
35
|
veadk/cli/cli_init.py,sha256=f2A3RwUj9pApmUTl6FHmMwTTwyKl83pkvZRorTgl-XM,3982
|
|
@@ -37,7 +37,7 @@ veadk/cli/cli_kb.py,sha256=SmLz3g6o2LiPa6WzkdyAOExuboHkpAIrN-4qaH4rxn8,1962
|
|
|
37
37
|
veadk/cli/cli_pipeline.py,sha256=6FV4WyoapFPAy_P3dzrRm07m6aGjrtLiY4aCFT7CEHs,7510
|
|
38
38
|
veadk/cli/cli_prompt.py,sha256=atw6O3zkjD1tOsFOOg7rs9HbS4exwaNe_Pces6CoyFY,2582
|
|
39
39
|
veadk/cli/cli_uploadevalset.py,sha256=RdelvbXEBalXGxHnPJ-8ZQ1PRiex39328yhAWgZ5mAI,4342
|
|
40
|
-
veadk/cli/cli_web.py,sha256=
|
|
40
|
+
veadk/cli/cli_web.py,sha256=B8VQVqEH05XoJYYcGT9FKBHItQ1Wd6BhWuNZv9_1YEA,3992
|
|
41
41
|
veadk/cloud/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
|
|
42
42
|
veadk/cloud/cloud_agent_engine.py,sha256=u-v-kkAhRgZY1r82CQRwfkYnj0n7ft8qIW_r-yhnMSI,8461
|
|
43
43
|
veadk/cloud/cloud_app.py,sha256=2bmEf7RH1Kwz8HLZ0aY3pVn0R8xi1T7kcGRTRyaWawY,8746
|
|
@@ -144,13 +144,14 @@ veadk/tools/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
|
|
|
144
144
|
veadk/tools/demo_tools.py,sha256=Gu3sxygcYVS2cv3WqUOl-Gq4JhMlDAktoCHOFT0gbFQ,2216
|
|
145
145
|
veadk/tools/load_knowledgebase_tool.py,sha256=UUTv0Za9GkEXAkl1SXmyq0HGCKGvSlH_f8Ok6O6e52M,4704
|
|
146
146
|
veadk/tools/builtin_tools/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
|
|
147
|
+
veadk/tools/builtin_tools/generate_image.py,sha256=b80yMziV0PR9_1oAd5HyDbZGAi3OMpUgL1xMyxW35m8,979
|
|
147
148
|
veadk/tools/builtin_tools/image_edit.py,sha256=KslsuabBchAYR3ZrWSO5viEe5ORUAe0GI1qQ6mxoIU0,11588
|
|
148
149
|
veadk/tools/builtin_tools/image_generate.py,sha256=frBUYEmizq6B4cRIUTfWKpLF2RywposJf-hZ8kkZvV8,18075
|
|
149
150
|
veadk/tools/builtin_tools/lark.py,sha256=b2IWsN8fZFh9aweSGznaOqA30TCOLpVjNCDNa1LHZl4,2046
|
|
150
151
|
veadk/tools/builtin_tools/las.py,sha256=rgKfnK5GsHVbmkp-rc7rtCvWg-yYNxMjeV0ayCyRpjM,913
|
|
151
152
|
veadk/tools/builtin_tools/load_knowledgebase.py,sha256=Xqtq25DL720goRegCVmmkpH2Ye2VWLcrF5ncC37gK_Y,3427
|
|
152
153
|
veadk/tools/builtin_tools/mcp_router.py,sha256=l3xcIHAHQ0AGCZG3mYyhwM0btqEMDe4TY2S-UYUM8M0,883
|
|
153
|
-
veadk/tools/builtin_tools/run_code.py,sha256=
|
|
154
|
+
veadk/tools/builtin_tools/run_code.py,sha256=aPfhXepk0-JJDslcAOs07OW0JNr4YAQ8fh6ZpmNUHLs,2888
|
|
154
155
|
veadk/tools/builtin_tools/vesearch.py,sha256=prPP0w6lYeIEPwuZdmV00RAzaW4MeH8lYtK-NluaXtU,1748
|
|
155
156
|
veadk/tools/builtin_tools/video_generate.py,sha256=hlvwoLESUV8vOPiNFVNPF0ithWqH7N5c6ElMvyI-lBM,16101
|
|
156
157
|
veadk/tools/builtin_tools/web_scraper.py,sha256=iVnxWVf2mVgOnEOeQ6Bg5ATYN-g1ZPCTK6VJm710be0,2408
|
|
@@ -162,7 +163,7 @@ veadk/tools/sandbox/computer_sandbox.py,sha256=e0d3pwaxBbLLihK-rFv2tUU7bmAwPTvSp
|
|
|
162
163
|
veadk/tracing/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
|
|
163
164
|
veadk/tracing/base_tracer.py,sha256=AQQopQ81Y1dGt3BF1iT8el5iSJC7HH5NrW9sU9R92v8,1098
|
|
164
165
|
veadk/tracing/telemetry/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
|
|
165
|
-
veadk/tracing/telemetry/opentelemetry_tracer.py,sha256=
|
|
166
|
+
veadk/tracing/telemetry/opentelemetry_tracer.py,sha256=4T9KxoSLbhzk1psErHwz2cWXHAMJcNzl9OXj_iCkcPs,7851
|
|
166
167
|
veadk/tracing/telemetry/telemetry.py,sha256=qM7Y9UlxTk78Z8inigtDZEoSSsUCY7b1nOmTWfVQ1mA,11033
|
|
167
168
|
veadk/tracing/telemetry/attributes/attributes.py,sha256=t08vbKenendKdlUrs3Q94p5F8TZEjh-oewBE5ABWDsE,1074
|
|
168
169
|
veadk/tracing/telemetry/attributes/extractors/common_attributes_extractors.py,sha256=AcJEw9RFQskK0l9rii7BZJPJa-peHJtrWt8Ge0R5fLU,2753
|
|
@@ -178,12 +179,12 @@ veadk/tracing/telemetry/exporters/tls_exporter.py,sha256=YODDfqZJKq3SiuDqxjERuJo
|
|
|
178
179
|
veadk/utils/__init__.py,sha256=pkSabKw7_ai4NOo56pXKL40EcaxIDh6HYxPXOY7qWbo,634
|
|
179
180
|
veadk/utils/logger.py,sha256=e4swzeXa-qZ1U2-TDBtfKOurzy4_6t4qPJR9yngNfVg,1605
|
|
180
181
|
veadk/utils/mcp_utils.py,sha256=aET7pX3LXmRe2-Jh7_xRvxrVyl1dN7uPAUk16luwMlQ,1525
|
|
181
|
-
veadk/utils/misc.py,sha256=
|
|
182
|
+
veadk/utils/misc.py,sha256=wtAKfTFXWhBeQWQYxsrW0KuI63bdDxQag0izKJvkW-E,5172
|
|
182
183
|
veadk/utils/patches.py,sha256=dcHdlJ8IciyMjDuMy6-_6McUqJYyLz0yHmJ0xH8lWOw,2752
|
|
183
184
|
veadk/utils/volcengine_sign.py,sha256=3xn6ca2OAg_AFyP2dqFTSioqkeDel_BoKURUtCcO-EQ,6736
|
|
184
|
-
veadk_python-0.2.
|
|
185
|
-
veadk_python-0.2.
|
|
186
|
-
veadk_python-0.2.
|
|
187
|
-
veadk_python-0.2.
|
|
188
|
-
veadk_python-0.2.
|
|
189
|
-
veadk_python-0.2.
|
|
185
|
+
veadk_python-0.2.16.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
186
|
+
veadk_python-0.2.16.dist-info/METADATA,sha256=LsRvQPbx3f1I8TOQdCqCRIX3FqgE5xu2iDCYP2NyoiI,18428
|
|
187
|
+
veadk_python-0.2.16.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
188
|
+
veadk_python-0.2.16.dist-info/entry_points.txt,sha256=-g28D6dNV-2UvAiRP9VF0oOVSDSJ5zlLUIZ34ArAqF8,46
|
|
189
|
+
veadk_python-0.2.16.dist-info/top_level.txt,sha256=Qqi3ycJ4anKiZWBXtUBIy8zK9ZuXJsFa05oFq8O8qqY,6
|
|
190
|
+
veadk_python-0.2.16.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|