Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions agentrun/agent_runtime/__endpoint_async_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async def create_by_id_async(
ResourceNotExistError: Agent Runtime 不存在 / Agent Runtime does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return await cli.create_endpoint_async(
agent_runtime_id,
input,
Expand Down Expand Up @@ -95,7 +95,7 @@ async def delete_by_id_async(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return await cli.delete_endpoint_async(
agent_runtime_id,
endpoint_id,
Expand Down Expand Up @@ -125,7 +125,7 @@ async def update_by_id_async(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return await cli.update_endpoint_async(
agent_runtime_id,
endpoint_id,
Expand Down Expand Up @@ -154,7 +154,7 @@ async def get_by_id_async(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return await cli.get_endpoint_async(
agent_runtime_id,
endpoint_id,
Expand Down Expand Up @@ -191,7 +191,7 @@ async def _list_page_async(
"agent_runtime_id is required for listing endpoints"
)

return await cls.__get_client().list_endpoints_async(
return await cls.__get_client(config).list_endpoints_async(
agent_runtime_id,
AgentRuntimeEndpointListInput(
page_number=page_input.page_number,
Expand Down Expand Up @@ -219,7 +219,7 @@ async def list_by_id_async(
Raises:
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)

endpoints: List[AgentRuntimeEndpoint] = []
page = 1
Expand Down Expand Up @@ -339,7 +339,9 @@ async def get_async(self, config: Optional[Config] = None):
)

result = await self.get_by_id_async(
self.agent_runtime_id, self.agent_runtime_endpoint_id
self.agent_runtime_id,
self.agent_runtime_endpoint_id,
config=config,
)
self.update_self(result)
return self
Expand Down
23 changes: 14 additions & 9 deletions agentrun/agent_runtime/__runtime_async_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,18 @@ class AgentRuntime(
_data_api: Dict[str, AgentRuntimeDataAPI] = {}

@classmethod
def __get_client(cls):
def __get_client(cls, config: Optional[Config] = None):
"""获取客户端实例 / Get client instance

Args:
config: 配置对象,可选 / Configuration object, optional

Returns:
AgentRuntimeClient: 客户端实例 / Client instance
"""
from .client import AgentRuntimeClient

return AgentRuntimeClient()
return AgentRuntimeClient(config=config)

@classmethod
async def create_async(
Expand All @@ -74,7 +77,7 @@ async def create_async(
ResourceAlreadyExistError: 资源已存在 / Resource already exists
HTTPError: HTTP 请求错误 / HTTP request error
"""
return await cls.__get_client().create_async(input, config=config)
return await cls.__get_client(config).create_async(input, config=config)

@classmethod
async def delete_by_id_async(cls, id: str, config: Optional[Config] = None):
Expand All @@ -94,7 +97,7 @@ async def delete_by_id_async(cls, id: str, config: Optional[Config] = None):
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)

# 删除所有的 endpoint / Delete all endpoints
endpoints = await cli.list_endpoints_async(id, config=config)
Expand Down Expand Up @@ -133,7 +136,9 @@ async def update_by_id_async(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
return await cls.__get_client().update_async(id, input, config=config)
return await cls.__get_client(config).update_async(
id, input, config=config
)

@classmethod
async def get_by_id_async(cls, id: str, config: Optional[Config] = None):
Expand All @@ -150,13 +155,13 @@ async def get_by_id_async(cls, id: str, config: Optional[Config] = None):
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
return await cls.__get_client().get_async(id, config=config)
return await cls.__get_client(config).get_async(id, config=config)

@classmethod
async def _list_page_async(
cls, page_input: PageableInput, config: Config | None = None, **kwargs
):
return await cls.__get_client().list_async(
return await cls.__get_client(config).list_async(
input=AgentRuntimeListInput(
**kwargs,
**page_input.model_dump(),
Expand Down Expand Up @@ -197,7 +202,7 @@ async def list_async(cls, config: Optional[Config] = None):
Raises:
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)

runtimes: List[AgentRuntime] = []
page = 1
Expand Down Expand Up @@ -294,7 +299,7 @@ async def list_versions_by_id_async(
agent_runtime_id: str,
config: Optional[Config] = None,
):
cli = cls.__get_client()
cli = cls.__get_client(config)

versions: List[AgentRuntimeVersion] = []
page = 1
Expand Down
32 changes: 18 additions & 14 deletions agentrun/agent_runtime/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ async def create_by_id_async(
ResourceNotExistError: Agent Runtime 不存在 / Agent Runtime does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return await cli.create_endpoint_async(
agent_runtime_id,
input,
Expand Down Expand Up @@ -106,7 +106,7 @@ def create_by_id(
ResourceNotExistError: Agent Runtime 不存在 / Agent Runtime does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return cli.create_endpoint(
agent_runtime_id,
input,
Expand Down Expand Up @@ -134,7 +134,7 @@ async def delete_by_id_async(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return await cli.delete_endpoint_async(
agent_runtime_id,
endpoint_id,
Expand Down Expand Up @@ -162,7 +162,7 @@ def delete_by_id(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return cli.delete_endpoint(
agent_runtime_id,
endpoint_id,
Expand Down Expand Up @@ -192,7 +192,7 @@ async def update_by_id_async(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return await cli.update_endpoint_async(
agent_runtime_id,
endpoint_id,
Expand Down Expand Up @@ -223,7 +223,7 @@ def update_by_id(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return cli.update_endpoint(
agent_runtime_id,
endpoint_id,
Expand Down Expand Up @@ -252,7 +252,7 @@ async def get_by_id_async(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return await cli.get_endpoint_async(
agent_runtime_id,
endpoint_id,
Expand Down Expand Up @@ -280,7 +280,7 @@ def get_by_id(
ResourceNotExistError: 资源不存在 / Resource does not exist
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)
return cli.get_endpoint(
agent_runtime_id,
endpoint_id,
Expand Down Expand Up @@ -317,7 +317,7 @@ async def _list_page_async(
"agent_runtime_id is required for listing endpoints"
)

return await cls.__get_client().list_endpoints_async(
return await cls.__get_client(config).list_endpoints_async(
agent_runtime_id,
AgentRuntimeEndpointListInput(
page_number=page_input.page_number,
Expand Down Expand Up @@ -356,7 +356,7 @@ def _list_page(
"agent_runtime_id is required for listing endpoints"
)

return cls.__get_client().list_endpoints(
return cls.__get_client(config).list_endpoints(
agent_runtime_id,
AgentRuntimeEndpointListInput(
page_number=page_input.page_number,
Expand Down Expand Up @@ -384,7 +384,7 @@ async def list_by_id_async(
Raises:
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)

endpoints: List[AgentRuntimeEndpoint] = []
page = 1
Expand Down Expand Up @@ -429,7 +429,7 @@ def list_by_id(cls, agent_runtime_id: str, config: Optional[Config] = None):
Raises:
HTTPError: HTTP 请求错误 / HTTP request error
"""
cli = cls.__get_client()
cli = cls.__get_client(config)

endpoints: List[AgentRuntimeEndpoint] = []
page = 1
Expand Down Expand Up @@ -615,7 +615,9 @@ async def get_async(self, config: Optional[Config] = None):
)

result = await self.get_by_id_async(
self.agent_runtime_id, self.agent_runtime_endpoint_id
self.agent_runtime_id,
self.agent_runtime_endpoint_id,
config=config,
)
self.update_self(result)
return self
Expand Down Expand Up @@ -644,7 +646,9 @@ def get(self, config: Optional[Config] = None):
)

result = self.get_by_id(
self.agent_runtime_id, self.agent_runtime_endpoint_id
self.agent_runtime_id,
self.agent_runtime_endpoint_id,
config=config,
)
self.update_self(result)
return self
Expand Down
Loading
Loading