1515from typing import Any
1616from uuid import uuid4
1717
18+ import json
1819import httpx
1920from a2a .client import A2ACardResolver , A2AClient
2021from a2a .types import AgentCard , Message , MessageSendParams , SendMessageRequest
@@ -36,9 +37,9 @@ class CloudApp:
3637
3738 def __init__ (
3839 self ,
39- vefaas_application_name : str ,
40- vefaas_endpoint : str ,
41- vefaas_application_id : str ,
40+ vefaas_application_name : str = "" ,
41+ vefaas_endpoint : str = "" ,
42+ vefaas_application_id : str = "" ,
4243 use_agent_card : bool = False ,
4344 ):
4445 self .vefaas_endpoint = vefaas_endpoint
@@ -73,18 +74,24 @@ def __init__(
7374
7475 self .httpx_client = httpx .AsyncClient ()
7576
76- def _get_vefaas_endpoint (self ) -> str :
77- vefaas_endpoint = ""
78-
79- if self .vefaas_application_id :
80- # TODO(zakahan): get endpoint from vefaas
81- vefaas_endpoint = ...
82- return vefaas_endpoint
77+ def _get_vefaas_endpoint (
78+ self ,
79+ volcengine_ak : str = getenv ("VOLCENGINE_ACCESS_KEY" ),
80+ volcengine_sk : str = getenv ("VOLCENGINE_SECRET_KEY" ),
81+ ) -> str :
82+ from veadk .cli .services .vefaas .vefaas import VeFaaS
8383
84- if self .vefaas_application_name :
85- # TODO(zakahan): get endpoint from vefaas
86- vefaas_endpoint = ...
87- return vefaas_endpoint
84+ vefaas_client = VeFaaS (access_key = volcengine_ak , secret_key = volcengine_sk )
85+ app = vefaas_client .get_application_details (
86+ app_id = self .vefaas_application_id ,
87+ app_name = self .vefaas_application_name ,
88+ )
89+ cloud_resource = json .loads (app ["CloudResource" ])
90+ try :
91+ vefaas_endpoint = cloud_resource ["framework" ]["url" ]["system_url" ]
92+ except Exception as e :
93+ raise ValueError (f"VeFaaS cloudAPP could not get endpoint. Error: { e } " )
94+ return vefaas_endpoint
8895
8996 def _get_vefaas_application_id_by_name (self ) -> str :
9097 if not self .vefaas_application_name :
0 commit comments