Skip to content

Commit 131e5b8

Browse files
committed
fix deploy codes
1 parent 0c11473 commit 131e5b8

File tree

17 files changed

+299
-500
lines changed

17 files changed

+299
-500
lines changed

.gitleaks.toml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
[extend]
2+
useDefault = true
3+
4+
[[rules]]
5+
id = "aklt-key-pattern"
6+
description = "AKLT key pattern"
7+
regex = '''AKLT\w{40,70}'''
8+
9+
[[rules]]
10+
id = "akap-key-pattern"
11+
description = "AKAP key pattern"
12+
regex = '''AKAP\w{40,70}'''
13+
14+
[[rules]]
15+
id = "akip-key-pattern"
16+
description = "AKIP key pattern"
17+
regex = '''AKI\w{40,70}'''
18+
19+
[[rules]]
20+
id = "token-transformer-id-pattern"
21+
description = "Tokenizer/Transformer/Token ID patterns"
22+
regex = '''(tokenizer|transformer|token_id|tokenid|attention_head).{0,20}'''
23+
24+
[[rules]]
25+
id = "aws-style-key-pattern"
26+
description = "AWS-style key pattern"
27+
regex = '''(A3T[A-Z0-9]|AKIA|AGPA|AIDA|AROA|AIPA|ANPA|ANVA|ASIA)[A-Z0-9]{16}'''
28+
29+
[[rules]]
30+
id = "alibaba-ltai-pattern"
31+
description = "Alibaba LTAI key pattern"
32+
regex = '''(LTAI)[a-z0-9]{20}'''
33+
34+
[[rules]]
35+
id = "aktp-key-pattern"
36+
description = "AKTP key pattern"
37+
regex = '''AKTP\w{40,70}'''
38+
39+
[[rules]]
40+
id = "app-id-pattern"
41+
description = "App ID patterns"
42+
regex = '''([^*<\s|:>]{0,7})(app_id|appid)([^]()!<>;/@&,]{0,10}[(=:]\s{0,6}["']{0,1}[0-9]{6,32}["']{0,1})'''
43+
44+
[[rules]]
45+
id = "byted-org-domains"
46+
description = "byted.org domains"
47+
regex = '''.{0,15}\.?byted.org.{0,20}'''
48+
49+
[[rules]]
50+
id = "bytedance-net-domains"
51+
description = "bytedance.net domains"
52+
regex = '''.{0,15}\.?bytedance.net.{0,20}'''
53+
54+
[[rules]]
55+
id = "feishu-cn-domains"
56+
description = "bytedance.feishu.cn domains"
57+
regex = '''.{0,20}.bytedance\.feishu\.cn.{0,50}'''
58+
59+
[[rules]]
60+
id = "larkoffice-com-domains"
61+
description = "bytedance.larkoffice.com domains"
62+
regex = '''.{0,20}.bytedance\.larkoffice\.com.{0,50}'''
63+
64+
[[rules]]
65+
id = "private-ip-10-range"
66+
description = "Private IP address pattern (10.x.x.x)"
67+
regex = '''(10\.\d{1,3}\.\d{1,3}\.\d{1,3})'''

.pre-commit-config.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@ repos:
99
args: [ --fix ]
1010
# Run the formatter.
1111
- id: ruff-format
12-
types_or: [ python, pyi ]
12+
types_or: [ python, pyi ]
13+
- repo: https://github.com/gitleaks/gitleaks
14+
rev: v8.24.2
15+
hooks:
16+
- id: gitleaks

tests/test_cloud.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
import os
1616
import tempfile
17-
import pytest
17+
from unittest.mock import AsyncMock, Mock, patch
1818

19-
from unittest.mock import Mock, patch, AsyncMock
19+
import pytest
2020

2121
os.environ["VOLCENGINE_ACCESS_KEY"] = "test_access_key"
2222
os.environ["VOLCENGINE_SECRET_KEY"] = "test_secret_key"
@@ -110,7 +110,7 @@ async def test_cloud():
110110
# Test CloudApp delete_self functionality
111111
with patch("builtins.input", return_value="y"):
112112
with patch(
113-
"veadk.cli.services.vefaas.vefaas.VeFaaS"
113+
"veadk.integrations.ve_faas.ve_faas.VeFaaS"
114114
) as mock_vefaas_in_app:
115115
mock_vefaas_client = Mock()
116116
mock_vefaas_in_app.return_value = mock_vefaas_client

veadk/cli/cli.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,41 @@
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+
115
import click
216

317
from veadk.cli.cli_deploy import deploy
418
from veadk.cli.cli_init import init
519
from veadk.cli.cli_prompt import prompt
20+
from veadk.cli.cli_studio import studio
21+
from veadk.cli.cli_web import web
22+
from veadk.version import VERSION
623

724

825
@click.group()
26+
@click.version_option(
27+
version=VERSION, prog_name="Volcengine Agent Development Kit (VeADK)"
28+
)
929
def veadk():
1030
"""Volcengine ADK command line tools"""
1131
pass
1232

1333

1434
veadk.add_command(deploy)
15-
veadk.add_command(prompt)
1635
veadk.add_command(init)
36+
veadk.add_command(prompt)
37+
veadk.add_command(studio)
38+
veadk.add_command(web)
1739

1840
if __name__ == "__main__":
1941
veadk()

veadk/cli/cli_deploy.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
import click
216

317

veadk/cli/cli_init.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
from typing import Any
216

317
import click

veadk/cli/cli_prompt.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
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+
115
import click
216

317

veadk/cli/cli_studio.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import click
16+
17+
18+
@click.command()
19+
@click.option("--path", default=".", help="Path to the agent directory")
20+
def studio(path: str) -> None:
21+
"""Run VeADK Studio with the specified agent. The VeADK Studio will be deprecated soon."""
22+
import os
23+
from pathlib import Path
24+
25+
import uvicorn
26+
27+
from veadk.cli.studio.fast_api import get_fast_api_app
28+
from veadk.utils.misc import load_module_from_file
29+
30+
path = str(Path(path).resolve())
31+
32+
agent_py_path = os.path.join(path, "agent.py")
33+
34+
module = load_module_from_file(
35+
module_name="local_agent", file_path=str(agent_py_path)
36+
)
37+
38+
agent = None
39+
short_term_memory = None
40+
try:
41+
agent = module.agent
42+
short_term_memory = module.short_term_memory
43+
except AttributeError as e:
44+
missing = str(e).split("'")[1] if "'" in str(e) else "unknown"
45+
raise AttributeError(f"agent.py is missing required variable: {missing}")
46+
47+
app = get_fast_api_app(agent, short_term_memory)
48+
49+
uvicorn.run(
50+
app,
51+
host="127.0.0.1",
52+
port=8000,
53+
log_level="info",
54+
loop="asyncio", # for deepeval
55+
)

veadk/cli/cli_web.py

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,85 @@
1-
def web():
2-
pass
1+
# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import click
16+
17+
18+
@click.command()
19+
@click.option("--host", default="127.0.0.1", help="Host to run the web server on")
20+
def web(host: str) -> None:
21+
"""Launch web with long term and short term memory."""
22+
import os
23+
from typing import Any
24+
25+
from google.adk.cli.utils.shared_value import SharedValue
26+
27+
from veadk.memory.short_term_memory import ShortTermMemory
28+
from veadk.utils.logger import get_logger
29+
30+
logger = get_logger(__name__)
31+
32+
def init_for_veadk(
33+
self,
34+
*,
35+
agent_loader: Any,
36+
session_service: Any,
37+
memory_service: Any,
38+
artifact_service: Any,
39+
credential_service: Any,
40+
eval_sets_manager: Any,
41+
eval_set_results_manager: Any,
42+
agents_dir: str,
43+
):
44+
self.agent_loader = agent_loader
45+
self.artifact_service = artifact_service
46+
self.credential_service = credential_service
47+
self.eval_sets_manager = eval_sets_manager
48+
self.eval_set_results_manager = eval_set_results_manager
49+
self.agents_dir = agents_dir
50+
self.runners_to_clean = set()
51+
self.current_app_name_ref = SharedValue(value="")
52+
self.runner_dict = {}
53+
54+
short_term_memory_backend = os.getenv("SHORT_TERM_MEMORY_BACKEND")
55+
if not short_term_memory_backend: # prevent None or empty string
56+
short_term_memory_backend = "local"
57+
logger.info(f"Short term memory: backend={short_term_memory_backend}")
58+
59+
long_term_memory_backend = os.getenv("LONG_TERM_MEMORY_BACKEND")
60+
long_term_memory = None
61+
62+
if long_term_memory_backend:
63+
from veadk.memory.long_term_memory import LongTermMemory
64+
65+
logger.info(f"Long term memory: backend={long_term_memory_backend}")
66+
long_term_memory = LongTermMemory(backend=long_term_memory_backend) # type: ignore
67+
else:
68+
logger.info("No long term memory backend settings detected.")
69+
70+
self.session_service = ShortTermMemory(
71+
backend=short_term_memory_backend # type: ignore
72+
).session_service
73+
74+
self.memory_service = long_term_memory
75+
76+
import google.adk.cli.adk_web_server
77+
78+
google.adk.cli.adk_web_server.AdkWebServer.__init__ = init_for_veadk
79+
80+
import google.adk.cli.cli_tools_click as cli_tools_click
81+
82+
agents_dir = os.getcwd()
83+
logger.info(f"Load agents from {agents_dir}")
84+
85+
cli_tools_click.cli_web.main(args=[agents_dir, "--host", host])

0 commit comments

Comments
 (0)