diff --git a/veadk/cloud/cloud_app.py b/veadk/cloud/cloud_app.py index 29e9d983..e737c7f1 100644 --- a/veadk/cloud/cloud_app.py +++ b/veadk/cloud/cloud_app.py @@ -13,6 +13,7 @@ # limitations under the License. import json +import time from typing import Any from uuid import uuid4 @@ -60,9 +61,11 @@ def __init__( if not vefaas_endpoint: self.vefaas_endpoint = self._get_vefaas_endpoint() - if not self.vefaas_endpoint.startswith( - "http" - ) and not self.vefaas_endpoint.startswith("https"): + if ( + self.vefaas_endpoint + and not self.vefaas_endpoint.startswith("http") + and not self.vefaas_endpoint.startswith("https") + ): raise ValueError( f"Invalid endpoint: {vefaas_endpoint}. The endpoint must start with `http` or `https`." ) @@ -92,12 +95,13 @@ def _get_vefaas_endpoint( raise ValueError( f"VeFaaS CloudAPP with application_id `{self.vefaas_application_id}` or application_name `{self.vefaas_application_name}` not found." ) - cloud_resource = json.loads(app["CloudResource"]) try: + cloud_resource = json.loads(app["CloudResource"]) vefaas_endpoint = cloud_resource["framework"]["url"]["system_url"] except Exception as e: - raise ValueError(f"VeFaaS cloudAPP could not get endpoint. Error: {e}") + logger.warning(f"VeFaaS cloudAPP could not get endpoint. Error: {e}") + vefaas_endpoint = "" return vefaas_endpoint def _get_vefaas_application_id_by_name(self) -> str: @@ -167,7 +171,18 @@ def delete_self( vefaas_client = VeFaaS(access_key=volcengine_ak, secret_key=volcengine_sk) vefaas_client.delete(self.vefaas_application_id) - print(f"Cloud app {self.vefaas_application_id} is deleting...") + print( + f"Cloud app {self.vefaas_application_id} delete request has been sent to VeFaaS" + ) + while True: + try: + id = self._get_vefaas_application_id_by_name() + if not id: + break + time.sleep(3) + except Exception as _: + break + print("Delete application done.") async def message_send( self, message: str, session_id: str, user_id: str, timeout: float = 600.0 diff --git a/veadk/consts.py b/veadk/consts.py index b1ceb88d..5c5ac71a 100644 --- a/veadk/consts.py +++ b/veadk/consts.py @@ -15,6 +15,16 @@ from veadk.version import VERSION DEFAULT_MODEL_AGENT_NAME = "doubao-seed-1-6-250615" -DEFALUT_MODEL_AGENT_PROVIDER = "openai" +DEFAULT_MODEL_AGENT_PROVIDER = "openai" DEFAULT_MODEL_AGENT_API_BASE = "https://ark.cn-beijing.volces.com/api/v3/" DEFAULT_MODEL_EXTRA_HEADERS = {"veadk-source": "veadk", "veadk-version": VERSION} + +DEFAULT_APMPLUS_OTEL_EXPORTER_ENDPOINT = "http://apmplus-cn-beijing.volces.com:4317" +DEFAULT_APMPLUS_OTEL_EXPORTER_SERVICE_NAME = "veadk_tracing" + +DEFAULT_COZELOOP_OTEL_EXPORTER_ENDPOINT = ( + "https://api.coze.cn/v1/loop/opentelemetry/v1/traces" +) + +DEFAULT_TLS_OTEL_EXPORTER_ENDPOINT = "https://tls-cn-beijing.volces.com:4318/v1/traces" +DEFAULT_TLS_OTEL_EXPORTER_REGION = "cn-beijing" diff --git a/veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/clean.py b/veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/clean.py new file mode 100644 index 00000000..ceba3f39 --- /dev/null +++ b/veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/clean.py @@ -0,0 +1,23 @@ +# Copyright (c) 2025 Beijing Volcano Engine Technology Co., Ltd. and/or its affiliates. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from veadk.cloud.cloud_app import CloudApp + +def main() -> None: + cloud_app = CloudApp(vefaas_application_name="{{cookiecutter.vefaas_application_name}}") + cloud_app.delete_self() + + +if __name__ == "__main__": + main() \ No newline at end of file diff --git a/veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py b/veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py index 27d2000e..8176c59f 100644 --- a/veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py +++ b/veadk/integrations/ve_faas/template/{{cookiecutter.local_dir_name}}/src/app.py @@ -26,6 +26,7 @@ from starlette.routing import Route from google.adk.a2a.utils.agent_card_builder import AgentCardBuilder +from a2a.types import AgentProvider from veadk.a2a.ve_a2a_server import init_app from veadk.runner import Runner @@ -46,7 +47,9 @@ agent = agent_run_config.agent short_term_memory = agent_run_config.short_term_memory -agent_card_builder = AgentCardBuilder(agent=agent) +VEFAAS_REGION = os.getenv("APP_REGION", "cn-beijing") +VEFAAS_FUNC_ID = os.getenv("_FAAS_FUNC_ID", "") +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}")) def load_tracer() -> None: