-
Notifications
You must be signed in to change notification settings - Fork 4
feat(endpoint): implement pagination methods for AgentRuntimeEndpoint #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
| AgentRuntimeEndpointUpdateInput, | ||
| ) | ||
| from agentrun.utils.config import Config | ||
| from agentrun.utils.model import PageableInput | ||
| from agentrun.utils.resource import ResourceBase | ||
|
|
||
|
|
||
|
|
@@ -286,6 +287,84 @@ def get_by_id( | |
| config=config, | ||
| ) | ||
|
|
||
| @classmethod | ||
| async def _list_page_async( | ||
| cls, | ||
| page_input: PageableInput, | ||
| config: Optional[Config] = None, | ||
| **kwargs, | ||
|
Comment on lines
+291
to
+295
|
||
| ) -> List["AgentRuntimeEndpoint"]: | ||
| """分页列出端点 / List endpoints by page | ||
|
|
||
| 此方法是 ResourceBase 要求实现的抽象方法,用于支持分页查询。 | ||
| This method is an abstract method required by ResourceBase to support pagination. | ||
|
|
||
| Args: | ||
| page_input: 分页参数 / Pagination parameters | ||
| config: 配置对象,可选 / Configuration object, optional | ||
| **kwargs: 其他参数,必须包含 agent_runtime_id / Other parameters, must include agent_runtime_id | ||
|
|
||
| Returns: | ||
| List[AgentRuntimeEndpoint]: 端点对象列表 / List of endpoint objects | ||
|
|
||
| Raises: | ||
| ValueError: 当 agent_runtime_id 未提供时 / When agent_runtime_id is not provided | ||
| HTTPError: HTTP 请求错误 / HTTP request error | ||
| """ | ||
| agent_runtime_id = kwargs.get("agent_runtime_id") | ||
| if not agent_runtime_id: | ||
| raise ValueError( | ||
| "agent_runtime_id is required for listing endpoints" | ||
| ) | ||
|
|
||
| return await cls.__get_client().list_endpoints_async( | ||
| agent_runtime_id, | ||
| AgentRuntimeEndpointListInput( | ||
| page_number=page_input.page_number, | ||
| page_size=page_input.page_size, | ||
| ), | ||
| config=config, | ||
| ) | ||
|
|
||
|
Comment on lines
+290
to
+328
|
||
| @classmethod | ||
| def _list_page( | ||
| cls, | ||
| page_input: PageableInput, | ||
| config: Optional[Config] = None, | ||
| **kwargs, | ||
|
Comment on lines
+330
to
+334
|
||
| ) -> List["AgentRuntimeEndpoint"]: | ||
| """分页列出端点 / List endpoints by page | ||
|
|
||
| 此方法是 ResourceBase 要求实现的抽象方法,用于支持分页查询。 | ||
| This method is an abstract method required by ResourceBase to support pagination. | ||
|
|
||
| Args: | ||
| page_input: 分页参数 / Pagination parameters | ||
| config: 配置对象,可选 / Configuration object, optional | ||
| **kwargs: 其他参数,必须包含 agent_runtime_id / Other parameters, must include agent_runtime_id | ||
|
|
||
| Returns: | ||
| List[AgentRuntimeEndpoint]: 端点对象列表 / List of endpoint objects | ||
|
|
||
| Raises: | ||
| ValueError: 当 agent_runtime_id 未提供时 / When agent_runtime_id is not provided | ||
| HTTPError: HTTP 请求错误 / HTTP request error | ||
| """ | ||
| agent_runtime_id = kwargs.get("agent_runtime_id") | ||
| if not agent_runtime_id: | ||
| raise ValueError( | ||
| "agent_runtime_id is required for listing endpoints" | ||
| ) | ||
|
|
||
| return cls.__get_client().list_endpoints( | ||
| agent_runtime_id, | ||
| AgentRuntimeEndpointListInput( | ||
| page_number=page_input.page_number, | ||
| page_size=page_input.page_size, | ||
| ), | ||
| config=config, | ||
| ) | ||
|
|
||
| @classmethod | ||
| async def list_by_id_async( | ||
| cls, agent_runtime_id: str, config: Optional[Config] = None | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -468,3 +468,115 @@ def test_invoke_openai(self, mock_client_class, mock_data_api_class): | |||||
| def test_invoke_openai_async(self, mock_client_class, mock_data_api_class): | ||||||
| """测试 invoke_openai_async - 跳过因为私有属性问题""" | ||||||
| pass | ||||||
|
|
||||||
|
|
||||||
| class TestAgentRuntimeEndpointAbstractMethods: | ||||||
| """测试 AgentRuntimeEndpoint 抽象方法实现 | ||||||
|
|
||||||
| 此测试类用于验证 AgentRuntimeEndpoint 正确实现了 ResourceBase 要求的抽象方法。 | ||||||
| 这是为了防止类似于 Issue #XXX 的问题再次发生,确保 from_inner_object 能够正常实例化对象。 | ||||||
|
||||||
| 这是为了防止类似于 Issue #XXX 的问题再次发生,确保 from_inner_object 能够正常实例化对象。 | |
| 这是为了防止问题再次发生,确保 from_inner_object 能够正常实例化对象。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type hint for the config parameter is inconsistent with other resources in the codebase. In agentrun/agent_runtime/runtime.py and agentrun/credential/credential.py, the _list_page_async methods use "Config | None" instead of "Optional[Config]". While both are functionally equivalent, using "Config | None" maintains consistency with the established pattern in similar resource classes.