Skip to content

Commit 2e272b4

Browse files
chore(vefaas): add clean module for template (#115)
* chore(vefaas): add clean module for template * add file header
1 parent 17b2fca commit 2e272b4

File tree

4 files changed

+59
-8
lines changed

4 files changed

+59
-8
lines changed

veadk/cloud/cloud_app.py

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# limitations under the License.
1414

1515
import json
16+
import time
1617
from typing import Any
1718
from uuid import uuid4
1819

@@ -60,9 +61,11 @@ def __init__(
6061
if not vefaas_endpoint:
6162
self.vefaas_endpoint = self._get_vefaas_endpoint()
6263

63-
if not self.vefaas_endpoint.startswith(
64-
"http"
65-
) and not self.vefaas_endpoint.startswith("https"):
64+
if (
65+
self.vefaas_endpoint
66+
and not self.vefaas_endpoint.startswith("http")
67+
and not self.vefaas_endpoint.startswith("https")
68+
):
6669
raise ValueError(
6770
f"Invalid endpoint: {vefaas_endpoint}. The endpoint must start with `http` or `https`."
6871
)
@@ -92,12 +95,13 @@ def _get_vefaas_endpoint(
9295
raise ValueError(
9396
f"VeFaaS CloudAPP with application_id `{self.vefaas_application_id}` or application_name `{self.vefaas_application_name}` not found."
9497
)
95-
cloud_resource = json.loads(app["CloudResource"])
9698

9799
try:
100+
cloud_resource = json.loads(app["CloudResource"])
98101
vefaas_endpoint = cloud_resource["framework"]["url"]["system_url"]
99102
except Exception as e:
100-
raise ValueError(f"VeFaaS cloudAPP could not get endpoint. Error: {e}")
103+
logger.warning(f"VeFaaS cloudAPP could not get endpoint. Error: {e}")
104+
vefaas_endpoint = ""
101105
return vefaas_endpoint
102106

103107
def _get_vefaas_application_id_by_name(self) -> str:
@@ -167,7 +171,18 @@ def delete_self(
167171

168172
vefaas_client = VeFaaS(access_key=volcengine_ak, secret_key=volcengine_sk)
169173
vefaas_client.delete(self.vefaas_application_id)
170-
print(f"Cloud app {self.vefaas_application_id} is deleting...")
174+
print(
175+
f"Cloud app {self.vefaas_application_id} delete request has been sent to VeFaaS"
176+
)
177+
while True:
178+
try:
179+
id = self._get_vefaas_application_id_by_name()
180+
if not id:
181+
break
182+
time.sleep(3)
183+
except Exception as _:
184+
break
185+
print("Delete application done.")
171186

172187
async def message_send(
173188
self, message: str, session_id: str, user_id: str, timeout: float = 600.0

veadk/consts.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@
1515
from veadk.version import VERSION
1616

1717
DEFAULT_MODEL_AGENT_NAME = "doubao-seed-1-6-250615"
18-
DEFALUT_MODEL_AGENT_PROVIDER = "openai"
18+
DEFAULT_MODEL_AGENT_PROVIDER = "openai"
1919
DEFAULT_MODEL_AGENT_API_BASE = "https://ark.cn-beijing.volces.com/api/v3/"
2020
DEFAULT_MODEL_EXTRA_HEADERS = {"veadk-source": "veadk", "veadk-version": VERSION}
21+
22+
DEFAULT_APMPLUS_OTEL_EXPORTER_ENDPOINT = "http://apmplus-cn-beijing.volces.com:4317"
23+
DEFAULT_APMPLUS_OTEL_EXPORTER_SERVICE_NAME = "veadk_tracing"
24+
25+
DEFAULT_COZELOOP_OTEL_EXPORTER_ENDPOINT = (
26+
"https://api.coze.cn/v1/loop/opentelemetry/v1/traces"
27+
)
28+
29+
DEFAULT_TLS_OTEL_EXPORTER_ENDPOINT = "https://tls-cn-beijing.volces.com:4318/v1/traces"
30+
DEFAULT_TLS_OTEL_EXPORTER_REGION = "cn-beijing"
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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.cloud.cloud_app import CloudApp
16+
17+
def main() -> None:
18+
cloud_app = CloudApp(vefaas_application_name="{{cookiecutter.vefaas_application_name}}")
19+
cloud_app.delete_self()
20+
21+
22+
if __name__ == "__main__":
23+
main()

veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from starlette.routing import Route
2727

2828
from google.adk.a2a.utils.agent_card_builder import AgentCardBuilder
29+
from a2a.types import AgentProvider
2930

3031
from veadk.a2a.ve_a2a_server import init_app
3132
from veadk.runner import Runner
@@ -46,7 +47,9 @@
4647
agent = agent_run_config.agent
4748
short_term_memory = agent_run_config.short_term_memory
4849

49-
agent_card_builder = AgentCardBuilder(agent=agent)
50+
VEFAAS_REGION = os.getenv("APP_REGION", "cn-beijing")
51+
VEFAAS_FUNC_ID = os.getenv("_FAAS_FUNC_ID", "")
52+
agent_card_builder = AgentCardBuilder(agent=agent, provider=AgentProvider(organization="Volcengine Agent Development Kit (VeADK)", url=f"https://console.volcengine.com/vefaas/region:vefaas+{VEFAAS_REGION}/function/detail/{VEFAAS_FUNC_ID}"))
5053

5154

5255
def load_tracer() -> None:

0 commit comments

Comments
 (0)