agentrun-inner-test 0.0.62__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of agentrun-inner-test might be problematic. Click here for more details.

Files changed (154) hide show
  1. agentrun/__init__.py +358 -0
  2. agentrun/agent_runtime/__client_async_template.py +466 -0
  3. agentrun/agent_runtime/__endpoint_async_template.py +345 -0
  4. agentrun/agent_runtime/__init__.py +53 -0
  5. agentrun/agent_runtime/__runtime_async_template.py +477 -0
  6. agentrun/agent_runtime/api/__data_async_template.py +58 -0
  7. agentrun/agent_runtime/api/__init__.py +6 -0
  8. agentrun/agent_runtime/api/control.py +1362 -0
  9. agentrun/agent_runtime/api/data.py +98 -0
  10. agentrun/agent_runtime/client.py +868 -0
  11. agentrun/agent_runtime/endpoint.py +649 -0
  12. agentrun/agent_runtime/model.py +362 -0
  13. agentrun/agent_runtime/runtime.py +904 -0
  14. agentrun/credential/__client_async_template.py +177 -0
  15. agentrun/credential/__credential_async_template.py +216 -0
  16. agentrun/credential/__init__.py +28 -0
  17. agentrun/credential/api/__init__.py +5 -0
  18. agentrun/credential/api/control.py +606 -0
  19. agentrun/credential/client.py +319 -0
  20. agentrun/credential/credential.py +381 -0
  21. agentrun/credential/model.py +248 -0
  22. agentrun/integration/__init__.py +21 -0
  23. agentrun/integration/agentscope/__init__.py +13 -0
  24. agentrun/integration/agentscope/adapter.py +17 -0
  25. agentrun/integration/agentscope/builtin.py +88 -0
  26. agentrun/integration/agentscope/message_adapter.py +185 -0
  27. agentrun/integration/agentscope/model_adapter.py +60 -0
  28. agentrun/integration/agentscope/tool_adapter.py +59 -0
  29. agentrun/integration/builtin/__init__.py +18 -0
  30. agentrun/integration/builtin/knowledgebase.py +137 -0
  31. agentrun/integration/builtin/model.py +93 -0
  32. agentrun/integration/builtin/sandbox.py +1234 -0
  33. agentrun/integration/builtin/toolset.py +47 -0
  34. agentrun/integration/crewai/__init__.py +13 -0
  35. agentrun/integration/crewai/adapter.py +9 -0
  36. agentrun/integration/crewai/builtin.py +88 -0
  37. agentrun/integration/crewai/model_adapter.py +31 -0
  38. agentrun/integration/crewai/tool_adapter.py +26 -0
  39. agentrun/integration/google_adk/__init__.py +13 -0
  40. agentrun/integration/google_adk/adapter.py +15 -0
  41. agentrun/integration/google_adk/builtin.py +88 -0
  42. agentrun/integration/google_adk/message_adapter.py +144 -0
  43. agentrun/integration/google_adk/model_adapter.py +46 -0
  44. agentrun/integration/google_adk/tool_adapter.py +235 -0
  45. agentrun/integration/langchain/__init__.py +31 -0
  46. agentrun/integration/langchain/adapter.py +15 -0
  47. agentrun/integration/langchain/builtin.py +94 -0
  48. agentrun/integration/langchain/message_adapter.py +141 -0
  49. agentrun/integration/langchain/model_adapter.py +37 -0
  50. agentrun/integration/langchain/tool_adapter.py +50 -0
  51. agentrun/integration/langgraph/__init__.py +36 -0
  52. agentrun/integration/langgraph/adapter.py +20 -0
  53. agentrun/integration/langgraph/agent_converter.py +1073 -0
  54. agentrun/integration/langgraph/builtin.py +88 -0
  55. agentrun/integration/pydantic_ai/__init__.py +13 -0
  56. agentrun/integration/pydantic_ai/adapter.py +13 -0
  57. agentrun/integration/pydantic_ai/builtin.py +88 -0
  58. agentrun/integration/pydantic_ai/model_adapter.py +44 -0
  59. agentrun/integration/pydantic_ai/tool_adapter.py +19 -0
  60. agentrun/integration/utils/__init__.py +112 -0
  61. agentrun/integration/utils/adapter.py +560 -0
  62. agentrun/integration/utils/canonical.py +164 -0
  63. agentrun/integration/utils/converter.py +134 -0
  64. agentrun/integration/utils/model.py +110 -0
  65. agentrun/integration/utils/tool.py +1759 -0
  66. agentrun/knowledgebase/__client_async_template.py +173 -0
  67. agentrun/knowledgebase/__init__.py +53 -0
  68. agentrun/knowledgebase/__knowledgebase_async_template.py +438 -0
  69. agentrun/knowledgebase/api/__data_async_template.py +414 -0
  70. agentrun/knowledgebase/api/__init__.py +19 -0
  71. agentrun/knowledgebase/api/control.py +606 -0
  72. agentrun/knowledgebase/api/data.py +624 -0
  73. agentrun/knowledgebase/client.py +311 -0
  74. agentrun/knowledgebase/knowledgebase.py +748 -0
  75. agentrun/knowledgebase/model.py +270 -0
  76. agentrun/memory_collection/__client_async_template.py +178 -0
  77. agentrun/memory_collection/__init__.py +37 -0
  78. agentrun/memory_collection/__memory_collection_async_template.py +457 -0
  79. agentrun/memory_collection/api/__init__.py +5 -0
  80. agentrun/memory_collection/api/control.py +610 -0
  81. agentrun/memory_collection/client.py +323 -0
  82. agentrun/memory_collection/memory_collection.py +844 -0
  83. agentrun/memory_collection/model.py +162 -0
  84. agentrun/model/__client_async_template.py +357 -0
  85. agentrun/model/__init__.py +57 -0
  86. agentrun/model/__model_proxy_async_template.py +270 -0
  87. agentrun/model/__model_service_async_template.py +267 -0
  88. agentrun/model/api/__init__.py +6 -0
  89. agentrun/model/api/control.py +1173 -0
  90. agentrun/model/api/data.py +196 -0
  91. agentrun/model/client.py +674 -0
  92. agentrun/model/model.py +235 -0
  93. agentrun/model/model_proxy.py +439 -0
  94. agentrun/model/model_service.py +438 -0
  95. agentrun/sandbox/__aio_sandbox_async_template.py +523 -0
  96. agentrun/sandbox/__browser_sandbox_async_template.py +110 -0
  97. agentrun/sandbox/__client_async_template.py +491 -0
  98. agentrun/sandbox/__code_interpreter_sandbox_async_template.py +463 -0
  99. agentrun/sandbox/__init__.py +69 -0
  100. agentrun/sandbox/__sandbox_async_template.py +463 -0
  101. agentrun/sandbox/__template_async_template.py +152 -0
  102. agentrun/sandbox/aio_sandbox.py +912 -0
  103. agentrun/sandbox/api/__aio_data_async_template.py +335 -0
  104. agentrun/sandbox/api/__browser_data_async_template.py +140 -0
  105. agentrun/sandbox/api/__code_interpreter_data_async_template.py +206 -0
  106. agentrun/sandbox/api/__init__.py +19 -0
  107. agentrun/sandbox/api/__sandbox_data_async_template.py +107 -0
  108. agentrun/sandbox/api/aio_data.py +551 -0
  109. agentrun/sandbox/api/browser_data.py +172 -0
  110. agentrun/sandbox/api/code_interpreter_data.py +396 -0
  111. agentrun/sandbox/api/control.py +1051 -0
  112. agentrun/sandbox/api/playwright_async.py +492 -0
  113. agentrun/sandbox/api/playwright_sync.py +492 -0
  114. agentrun/sandbox/api/sandbox_data.py +154 -0
  115. agentrun/sandbox/browser_sandbox.py +185 -0
  116. agentrun/sandbox/client.py +925 -0
  117. agentrun/sandbox/code_interpreter_sandbox.py +823 -0
  118. agentrun/sandbox/model.py +384 -0
  119. agentrun/sandbox/sandbox.py +848 -0
  120. agentrun/sandbox/template.py +217 -0
  121. agentrun/server/__init__.py +191 -0
  122. agentrun/server/agui_normalizer.py +180 -0
  123. agentrun/server/agui_protocol.py +797 -0
  124. agentrun/server/invoker.py +309 -0
  125. agentrun/server/model.py +427 -0
  126. agentrun/server/openai_protocol.py +535 -0
  127. agentrun/server/protocol.py +140 -0
  128. agentrun/server/server.py +208 -0
  129. agentrun/toolset/__client_async_template.py +62 -0
  130. agentrun/toolset/__init__.py +51 -0
  131. agentrun/toolset/__toolset_async_template.py +204 -0
  132. agentrun/toolset/api/__init__.py +17 -0
  133. agentrun/toolset/api/control.py +262 -0
  134. agentrun/toolset/api/mcp.py +100 -0
  135. agentrun/toolset/api/openapi.py +1251 -0
  136. agentrun/toolset/client.py +102 -0
  137. agentrun/toolset/model.py +321 -0
  138. agentrun/toolset/toolset.py +271 -0
  139. agentrun/utils/__data_api_async_template.py +721 -0
  140. agentrun/utils/__init__.py +5 -0
  141. agentrun/utils/__resource_async_template.py +158 -0
  142. agentrun/utils/config.py +270 -0
  143. agentrun/utils/control_api.py +105 -0
  144. agentrun/utils/data_api.py +1121 -0
  145. agentrun/utils/exception.py +151 -0
  146. agentrun/utils/helper.py +108 -0
  147. agentrun/utils/log.py +77 -0
  148. agentrun/utils/model.py +168 -0
  149. agentrun/utils/resource.py +291 -0
  150. agentrun_inner_test-0.0.62.dist-info/METADATA +265 -0
  151. agentrun_inner_test-0.0.62.dist-info/RECORD +154 -0
  152. agentrun_inner_test-0.0.62.dist-info/WHEEL +5 -0
  153. agentrun_inner_test-0.0.62.dist-info/licenses/LICENSE +201 -0
  154. agentrun_inner_test-0.0.62.dist-info/top_level.txt +1 -0
@@ -0,0 +1,904 @@
1
+ """
2
+ This file is auto generated by the code generation script.
3
+ Do not modify this file manually.
4
+ Use the `make codegen` command to regenerate.
5
+
6
+ 当前文件为自动生成的控制 API 客户端代码。请勿手动修改此文件。
7
+ 使用 `make codegen` 命令重新生成。
8
+
9
+ source: agentrun/agent_runtime/__runtime_async_template.py
10
+
11
+ Agent Runtime 高层 API / Agent Runtime High-Level API
12
+
13
+ 此模块定义 Agent Runtime 资源的高级API。
14
+ This module defines the high-level API for Agent Runtime resources.
15
+ """
16
+
17
+ import time # noqa: F401
18
+ from typing import Dict, List, Optional
19
+
20
+ from typing_extensions import Unpack
21
+
22
+ from agentrun.agent_runtime.api.data import AgentRuntimeDataAPI, InvokeArgs
23
+ from agentrun.utils.config import Config
24
+ from agentrun.utils.model import PageableInput
25
+ from agentrun.utils.resource import ResourceBase
26
+
27
+ from .endpoint import AgentRuntimeEndpoint
28
+ from .model import (
29
+ AgentRuntimeCreateInput,
30
+ AgentRuntimeEndpointCreateInput,
31
+ AgentRuntimeEndpointUpdateInput,
32
+ AgentRuntimeImmutableProps,
33
+ AgentRuntimeListInput,
34
+ AgentRuntimeMutableProps,
35
+ AgentRuntimeSystemProps,
36
+ AgentRuntimeUpdateInput,
37
+ AgentRuntimeVersion,
38
+ AgentRuntimeVersionListInput,
39
+ )
40
+
41
+
42
+ class AgentRuntime(
43
+ AgentRuntimeMutableProps,
44
+ AgentRuntimeImmutableProps,
45
+ AgentRuntimeSystemProps,
46
+ ResourceBase,
47
+ ):
48
+ """Agent Runtime 资源 / Agent Runtime Resource
49
+
50
+ 提供 Agent Runtime 的完整生命周期管理,包括创建、删除、更新、查询,
51
+ 以及端点和版本管理。
52
+ Provides complete lifecycle management for Agent Runtime, including create,
53
+ delete, update, query, and endpoint/version management.
54
+ """
55
+
56
+ @classmethod
57
+ def __get_client(cls):
58
+ """获取客户端实例 / Get client instance
59
+
60
+ Returns:
61
+ AgentRuntimeClient: 客户端实例 / Client instance
62
+ """
63
+ from .client import AgentRuntimeClient
64
+
65
+ return AgentRuntimeClient()
66
+
67
+ @classmethod
68
+ async def create_async(
69
+ cls, input: AgentRuntimeCreateInput, config: Optional[Config] = None
70
+ ):
71
+ """异步创建 Agent Runtime / Create Agent Runtime asynchronously
72
+
73
+ Args:
74
+ input: Agent Runtime 创建配置 / Agent Runtime creation configuration
75
+ config: 配置对象,可选 / Configuration object, optional
76
+
77
+ Returns:
78
+ AgentRuntime: 创建的 Agent Runtime 对象 / Created Agent Runtime object
79
+
80
+ Raises:
81
+ ValueError: 配置参数错误 / Configuration parameter error
82
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
83
+ HTTPError: HTTP 请求错误 / HTTP request error
84
+ """
85
+ return await cls.__get_client().create_async(input, config=config)
86
+
87
+ @classmethod
88
+ def create(
89
+ cls, input: AgentRuntimeCreateInput, config: Optional[Config] = None
90
+ ):
91
+ """同步创建 Agent Runtime / Create Agent Runtime asynchronously
92
+
93
+ Args:
94
+ input: Agent Runtime 创建配置 / Agent Runtime creation configuration
95
+ config: 配置对象,可选 / Configuration object, optional
96
+
97
+ Returns:
98
+ AgentRuntime: 创建的 Agent Runtime 对象 / Created Agent Runtime object
99
+
100
+ Raises:
101
+ ValueError: 配置参数错误 / Configuration parameter error
102
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
103
+ HTTPError: HTTP 请求错误 / HTTP request error
104
+ """
105
+ return cls.__get_client().create(input, config=config)
106
+
107
+ @classmethod
108
+ async def delete_by_id_async(cls, id: str, config: Optional[Config] = None):
109
+ """根据 ID 异步删除 Agent Runtime / Delete Agent Runtime by ID asynchronously
110
+
111
+ 此方法会先删除所有关联的端点,然后再删除 Agent Runtime。
112
+ This method will first delete all associated endpoints, then delete the Agent Runtime.
113
+
114
+ Args:
115
+ id: Agent Runtime ID
116
+ config: 配置对象,可选 / Configuration object, optional
117
+
118
+ Returns:
119
+ AgentRuntime: 删除的 Agent Runtime 对象 / Deleted Agent Runtime object
120
+
121
+ Raises:
122
+ ResourceNotExistError: 资源不存在 / Resource does not exist
123
+ HTTPError: HTTP 请求错误 / HTTP request error
124
+ """
125
+ cli = cls.__get_client()
126
+
127
+ # 删除所有的 endpoint / Delete all endpoints
128
+ endpoints = await cli.list_endpoints_async(id, config=config)
129
+ for endpoint in endpoints:
130
+ await endpoint.delete_async(config=config)
131
+
132
+ # 等待所有端点删除完成 / Wait for all endpoints to be deleted
133
+ while len(await cli.list_endpoints_async(id, config=config)) > 0:
134
+ import asyncio
135
+
136
+ await asyncio.sleep(1)
137
+
138
+ return await cli.delete_async(
139
+ id,
140
+ config=config,
141
+ )
142
+
143
+ @classmethod
144
+ def delete_by_id(cls, id: str, config: Optional[Config] = None):
145
+ """根据 ID 同步删除 Agent Runtime / Delete Agent Runtime by ID asynchronously
146
+
147
+ 此方法会先删除所有关联的端点,然后再删除 Agent Runtime。
148
+ This method will first delete all associated endpoints, then delete the Agent Runtime.
149
+
150
+ Args:
151
+ id: Agent Runtime ID
152
+ config: 配置对象,可选 / Configuration object, optional
153
+
154
+ Returns:
155
+ AgentRuntime: 删除的 Agent Runtime 对象 / Deleted Agent Runtime object
156
+
157
+ Raises:
158
+ ResourceNotExistError: 资源不存在 / Resource does not exist
159
+ HTTPError: HTTP 请求错误 / HTTP request error
160
+ """
161
+ cli = cls.__get_client()
162
+
163
+ # 删除所有的 endpoint / Delete all endpoints
164
+ endpoints = cli.list_endpoints(id, config=config)
165
+ for endpoint in endpoints:
166
+ endpoint.delete(config=config)
167
+
168
+ # 等待所有端点删除完成 / Wait for all endpoints to be deleted
169
+ while len(cli.list_endpoints(id, config=config)) > 0:
170
+
171
+ time.sleep(1)
172
+
173
+ return cli.delete(
174
+ id,
175
+ config=config,
176
+ )
177
+
178
+ @classmethod
179
+ async def update_by_id_async(
180
+ cls,
181
+ id: str,
182
+ input: AgentRuntimeUpdateInput,
183
+ config: Optional[Config] = None,
184
+ ):
185
+ """根据 ID 异步更新 Agent Runtime / Update Agent Runtime by ID asynchronously
186
+
187
+ Args:
188
+ id: Agent Runtime ID
189
+ input: Agent Runtime 更新配置 / Agent Runtime update configuration
190
+ config: 配置对象,可选 / Configuration object, optional
191
+
192
+ Returns:
193
+ AgentRuntime: 更新后的 Agent Runtime 对象 / Updated Agent Runtime object
194
+
195
+ Raises:
196
+ ResourceNotExistError: 资源不存在 / Resource does not exist
197
+ HTTPError: HTTP 请求错误 / HTTP request error
198
+ """
199
+ return await cls.__get_client().update_async(id, input, config=config)
200
+
201
+ @classmethod
202
+ def update_by_id(
203
+ cls,
204
+ id: str,
205
+ input: AgentRuntimeUpdateInput,
206
+ config: Optional[Config] = None,
207
+ ):
208
+ """根据 ID 同步更新 Agent Runtime / Update Agent Runtime by ID asynchronously
209
+
210
+ Args:
211
+ id: Agent Runtime ID
212
+ input: Agent Runtime 更新配置 / Agent Runtime update configuration
213
+ config: 配置对象,可选 / Configuration object, optional
214
+
215
+ Returns:
216
+ AgentRuntime: 更新后的 Agent Runtime 对象 / Updated Agent Runtime object
217
+
218
+ Raises:
219
+ ResourceNotExistError: 资源不存在 / Resource does not exist
220
+ HTTPError: HTTP 请求错误 / HTTP request error
221
+ """
222
+ return cls.__get_client().update(id, input, config=config)
223
+
224
+ @classmethod
225
+ async def get_by_id_async(cls, id: str, config: Optional[Config] = None):
226
+ """根据 ID 异步获取 Agent Runtime / Get Agent Runtime by ID asynchronously
227
+
228
+ Args:
229
+ id: Agent Runtime ID
230
+ config: 配置对象,可选 / Configuration object, optional
231
+
232
+ Returns:
233
+ AgentRuntime: Agent Runtime 对象 / Agent Runtime object
234
+
235
+ Raises:
236
+ ResourceNotExistError: 资源不存在 / Resource does not exist
237
+ HTTPError: HTTP 请求错误 / HTTP request error
238
+ """
239
+ return await cls.__get_client().get_async(id, config=config)
240
+
241
+ @classmethod
242
+ def get_by_id(cls, id: str, config: Optional[Config] = None):
243
+ """根据 ID 同步获取 Agent Runtime / Get Agent Runtime by ID asynchronously
244
+
245
+ Args:
246
+ id: Agent Runtime ID
247
+ config: 配置对象,可选 / Configuration object, optional
248
+
249
+ Returns:
250
+ AgentRuntime: Agent Runtime 对象 / Agent Runtime object
251
+
252
+ Raises:
253
+ ResourceNotExistError: 资源不存在 / Resource does not exist
254
+ HTTPError: HTTP 请求错误 / HTTP request error
255
+ """
256
+ return cls.__get_client().get(id, config=config)
257
+
258
+ @classmethod
259
+ async def _list_page_async(
260
+ cls, page_input: PageableInput, config: Config | None = None, **kwargs
261
+ ):
262
+ return await cls.__get_client().list_async(
263
+ input=AgentRuntimeListInput(
264
+ **kwargs,
265
+ **page_input.model_dump(),
266
+ ),
267
+ config=config,
268
+ )
269
+
270
+ @classmethod
271
+ def _list_page(
272
+ cls, page_input: PageableInput, config: Config | None = None, **kwargs
273
+ ):
274
+ return cls.__get_client().list(
275
+ input=AgentRuntimeListInput(
276
+ **kwargs,
277
+ **page_input.model_dump(),
278
+ ),
279
+ config=config,
280
+ )
281
+
282
+ @classmethod
283
+ async def list_all_async(
284
+ cls,
285
+ *,
286
+ agent_runtime_name: Optional[str] = None,
287
+ tags: Optional[str] = None,
288
+ search_mode: Optional[str] = None,
289
+ config: Optional[Config] = None,
290
+ ) -> List["AgentRuntime"]:
291
+ return await cls._list_all_async(
292
+ lambda ar: ar.agent_runtime_id or "",
293
+ config=config,
294
+ agent_runtime_name=agent_runtime_name,
295
+ tags=tags,
296
+ search_mode=search_mode,
297
+ )
298
+
299
+ @classmethod
300
+ def list_all(
301
+ cls,
302
+ *,
303
+ agent_runtime_name: Optional[str] = None,
304
+ tags: Optional[str] = None,
305
+ search_mode: Optional[str] = None,
306
+ config: Optional[Config] = None,
307
+ ) -> List["AgentRuntime"]:
308
+ return cls._list_all(
309
+ lambda ar: ar.agent_runtime_id or "",
310
+ config=config,
311
+ agent_runtime_name=agent_runtime_name,
312
+ tags=tags,
313
+ search_mode=search_mode,
314
+ )
315
+
316
+ @classmethod
317
+ async def list_async(cls, config: Optional[Config] = None):
318
+ """异步列出所有 Agent Runtimes / List all Agent Runtimes asynchronously
319
+
320
+ 此方法会自动分页获取所有 Agent Runtimes 并去重。
321
+ This method automatically paginates to get all Agent Runtimes and deduplicates them.
322
+
323
+ Args:
324
+ config: 配置对象,可选 / Configuration object, optional
325
+
326
+ Returns:
327
+ List[AgentRuntime]: Agent Runtime 对象列表 / List of Agent Runtime objects
328
+
329
+ Raises:
330
+ HTTPError: HTTP 请求错误 / HTTP request error
331
+ """
332
+ cli = cls.__get_client()
333
+
334
+ runtimes: List[AgentRuntime] = []
335
+ page = 1
336
+ page_size = 50
337
+ while True:
338
+ result = await cli.list_async(
339
+ AgentRuntimeListInput(
340
+ page_number=page,
341
+ page_size=page_size,
342
+ ),
343
+ config=config,
344
+ )
345
+ page += 1
346
+ runtimes.extend(result) # type: ignore
347
+ if len(result) < page_size:
348
+ break
349
+
350
+ # 去重 / Deduplicate
351
+ runtime_id_set = set()
352
+ results: List[AgentRuntime] = []
353
+ for runtime in runtimes:
354
+ if runtime.agent_runtime_id not in runtime_id_set:
355
+ runtime_id_set.add(runtime.agent_runtime_id)
356
+ results.append(runtime)
357
+
358
+ return results
359
+
360
+ @classmethod
361
+ def list(cls, config: Optional[Config] = None):
362
+ """同步列出所有 Agent Runtimes / List all Agent Runtimes asynchronously
363
+
364
+ 此方法会自动分页获取所有 Agent Runtimes 并去重。
365
+ This method automatically paginates to get all Agent Runtimes and deduplicates them.
366
+
367
+ Args:
368
+ config: 配置对象,可选 / Configuration object, optional
369
+
370
+ Returns:
371
+ List[AgentRuntime]: Agent Runtime 对象列表 / List of Agent Runtime objects
372
+
373
+ Raises:
374
+ HTTPError: HTTP 请求错误 / HTTP request error
375
+ """
376
+ cli = cls.__get_client()
377
+
378
+ runtimes: List[AgentRuntime] = []
379
+ page = 1
380
+ page_size = 50
381
+ while True:
382
+ result = cli.list(
383
+ AgentRuntimeListInput(
384
+ page_number=page,
385
+ page_size=page_size,
386
+ ),
387
+ config=config,
388
+ )
389
+ page += 1
390
+ runtimes.extend(result) # type: ignore
391
+ if len(result) < page_size:
392
+ break
393
+
394
+ # 去重 / Deduplicate
395
+ runtime_id_set = set()
396
+ results: List[AgentRuntime] = []
397
+ for runtime in runtimes:
398
+ if runtime.agent_runtime_id not in runtime_id_set:
399
+ runtime_id_set.add(runtime.agent_runtime_id)
400
+ results.append(runtime)
401
+
402
+ return results
403
+
404
+ @classmethod
405
+ async def create_endpoint_by_id_async(
406
+ cls,
407
+ agent_runtime_id: str,
408
+ input: AgentRuntimeEndpointCreateInput,
409
+ config: Optional[Config] = None,
410
+ ) -> AgentRuntimeEndpoint:
411
+ return await AgentRuntimeEndpoint.create_by_id_async(
412
+ agent_runtime_id,
413
+ input,
414
+ config=config,
415
+ )
416
+
417
+ @classmethod
418
+ def create_endpoint_by_id(
419
+ cls,
420
+ agent_runtime_id: str,
421
+ input: AgentRuntimeEndpointCreateInput,
422
+ config: Optional[Config] = None,
423
+ ) -> AgentRuntimeEndpoint:
424
+ return AgentRuntimeEndpoint.create_by_id(
425
+ agent_runtime_id,
426
+ input,
427
+ config=config,
428
+ )
429
+
430
+ @classmethod
431
+ async def delete_endpoint_by_id_async(
432
+ cls,
433
+ agent_runtime_id: str,
434
+ endpoint_id: str,
435
+ config: Optional[Config] = None,
436
+ ) -> AgentRuntimeEndpoint:
437
+ return await AgentRuntimeEndpoint.delete_by_id_async(
438
+ agent_runtime_id,
439
+ endpoint_id,
440
+ config=config,
441
+ )
442
+
443
+ @classmethod
444
+ def delete_endpoint_by_id(
445
+ cls,
446
+ agent_runtime_id: str,
447
+ endpoint_id: str,
448
+ config: Optional[Config] = None,
449
+ ) -> AgentRuntimeEndpoint:
450
+ return AgentRuntimeEndpoint.delete_by_id(
451
+ agent_runtime_id,
452
+ endpoint_id,
453
+ config=config,
454
+ )
455
+
456
+ @classmethod
457
+ async def update_endpoint_by_id_async(
458
+ cls,
459
+ agent_runtime_id: str,
460
+ endpoint_id: str,
461
+ input: AgentRuntimeEndpointUpdateInput,
462
+ config: Optional[Config] = None,
463
+ ) -> AgentRuntimeEndpoint:
464
+ return await AgentRuntimeEndpoint.update_by_id_async(
465
+ agent_runtime_id,
466
+ endpoint_id,
467
+ input,
468
+ config=config,
469
+ )
470
+
471
+ @classmethod
472
+ def update_endpoint_by_id(
473
+ cls,
474
+ agent_runtime_id: str,
475
+ endpoint_id: str,
476
+ input: AgentRuntimeEndpointUpdateInput,
477
+ config: Optional[Config] = None,
478
+ ) -> AgentRuntimeEndpoint:
479
+ return AgentRuntimeEndpoint.update_by_id(
480
+ agent_runtime_id,
481
+ endpoint_id,
482
+ input,
483
+ config=config,
484
+ )
485
+
486
+ @classmethod
487
+ async def get_endpoint_by_id_async(
488
+ cls,
489
+ agent_runtime_id: str,
490
+ endpoint_id: str,
491
+ config: Optional[Config] = None,
492
+ ) -> AgentRuntimeEndpoint:
493
+ return await AgentRuntimeEndpoint.get_by_id_async(
494
+ agent_runtime_id,
495
+ endpoint_id,
496
+ config=config,
497
+ )
498
+
499
+ @classmethod
500
+ def get_endpoint_by_id(
501
+ cls,
502
+ agent_runtime_id: str,
503
+ endpoint_id: str,
504
+ config: Optional[Config] = None,
505
+ ) -> AgentRuntimeEndpoint:
506
+ return AgentRuntimeEndpoint.get_by_id(
507
+ agent_runtime_id,
508
+ endpoint_id,
509
+ config=config,
510
+ )
511
+
512
+ @classmethod
513
+ async def list_endpoints_by_id_async(
514
+ cls, agent_runtime_id: str, config: Optional[Config] = None
515
+ ) -> List[AgentRuntimeEndpoint]:
516
+ return await AgentRuntimeEndpoint.list_by_id_async(
517
+ agent_runtime_id,
518
+ config=config,
519
+ )
520
+
521
+ @classmethod
522
+ def list_endpoints_by_id(
523
+ cls, agent_runtime_id: str, config: Optional[Config] = None
524
+ ) -> List[AgentRuntimeEndpoint]:
525
+ return AgentRuntimeEndpoint.list_by_id(
526
+ agent_runtime_id,
527
+ config=config,
528
+ )
529
+
530
+ @classmethod
531
+ async def list_versions_by_id_async(
532
+ cls,
533
+ agent_runtime_id: str,
534
+ config: Optional[Config] = None,
535
+ ):
536
+ cli = cls.__get_client()
537
+
538
+ versions: List[AgentRuntimeVersion] = []
539
+ page = 1
540
+ page_size = 50
541
+ while True:
542
+ result = await cli.list_versions_async(
543
+ agent_runtime_id,
544
+ AgentRuntimeVersionListInput(
545
+ page_number=page,
546
+ page_size=page_size,
547
+ ),
548
+ config=config,
549
+ )
550
+ page += 1
551
+ versions.extend(result)
552
+ if len(result) < page_size:
553
+ break
554
+
555
+ version_id_set = set()
556
+ results: List[AgentRuntimeVersion] = []
557
+ for version in versions:
558
+ if version.agent_runtime_version not in version_id_set:
559
+ version_id_set.add(version.agent_runtime_version)
560
+ results.append(version)
561
+
562
+ return results
563
+
564
+ @classmethod
565
+ def list_versions_by_id(
566
+ cls,
567
+ agent_runtime_id: str,
568
+ config: Optional[Config] = None,
569
+ ):
570
+ cli = cls.__get_client()
571
+
572
+ versions: List[AgentRuntimeVersion] = []
573
+ page = 1
574
+ page_size = 50
575
+ while True:
576
+ result = cli.list_versions(
577
+ agent_runtime_id,
578
+ AgentRuntimeVersionListInput(
579
+ page_number=page,
580
+ page_size=page_size,
581
+ ),
582
+ config=config,
583
+ )
584
+ page += 1
585
+ versions.extend(result)
586
+ if len(result) < page_size:
587
+ break
588
+
589
+ version_id_set = set()
590
+ results: List[AgentRuntimeVersion] = []
591
+ for version in versions:
592
+ if version.agent_runtime_version not in version_id_set:
593
+ version_id_set.add(version.agent_runtime_version)
594
+ results.append(version)
595
+
596
+ return results
597
+
598
+ async def delete_async(self, config: Optional[Config] = None):
599
+ if self.agent_runtime_id is None:
600
+ raise ValueError(
601
+ "agent_runtime_id is required to delete an Agent Runtime"
602
+ )
603
+
604
+ result = await self.delete_by_id_async(
605
+ self.agent_runtime_id, config=config
606
+ )
607
+ self.update_self(result)
608
+ return self
609
+
610
+ def delete(self, config: Optional[Config] = None):
611
+ if self.agent_runtime_id is None:
612
+ raise ValueError(
613
+ "agent_runtime_id is required to delete an Agent Runtime"
614
+ )
615
+
616
+ result = self.delete_by_id(self.agent_runtime_id, config=config)
617
+ self.update_self(result)
618
+ return self
619
+
620
+ async def update_async(
621
+ self, input: AgentRuntimeUpdateInput, config: Optional[Config] = None
622
+ ):
623
+ if self.agent_runtime_id is None:
624
+ raise ValueError(
625
+ "agent_runtime_id is required to delete an Agent Runtime"
626
+ )
627
+
628
+ result = await self.update_by_id_async(
629
+ self.agent_runtime_id, input=input, config=config
630
+ )
631
+ self.update_self(result)
632
+ return self
633
+
634
+ def update(
635
+ self, input: AgentRuntimeUpdateInput, config: Optional[Config] = None
636
+ ):
637
+ if self.agent_runtime_id is None:
638
+ raise ValueError(
639
+ "agent_runtime_id is required to delete an Agent Runtime"
640
+ )
641
+
642
+ result = self.update_by_id(
643
+ self.agent_runtime_id, input=input, config=config
644
+ )
645
+ self.update_self(result)
646
+ return self
647
+
648
+ async def get_async(self, config: Optional[Config] = None):
649
+ if self.agent_runtime_id is None:
650
+ raise ValueError(
651
+ "agent_runtime_id is required to get an Agent Runtime"
652
+ )
653
+
654
+ result = await self.get_by_id_async(
655
+ self.agent_runtime_id, config=config
656
+ )
657
+ self.update_self(result)
658
+ return self
659
+
660
+ def get(self, config: Optional[Config] = None):
661
+ if self.agent_runtime_id is None:
662
+ raise ValueError(
663
+ "agent_runtime_id is required to get an Agent Runtime"
664
+ )
665
+
666
+ result = self.get_by_id(self.agent_runtime_id, config=config)
667
+ self.update_self(result)
668
+ return self
669
+
670
+ async def refresh_async(self, config: Optional[Config] = None):
671
+ return await self.get_async(config=config)
672
+
673
+ def refresh(self, config: Optional[Config] = None):
674
+ return self.get(config=config)
675
+
676
+ async def create_endpoint_async(
677
+ self,
678
+ input: AgentRuntimeEndpointCreateInput,
679
+ config: Optional[Config] = None,
680
+ ):
681
+ if self.agent_runtime_id is None:
682
+ raise ValueError(
683
+ "agent_runtime_id is required to create an Agent Runtime"
684
+ " Endpoint"
685
+ )
686
+
687
+ return await self.create_endpoint_by_id_async(
688
+ self.agent_runtime_id, input=input, config=config
689
+ )
690
+
691
+ def create_endpoint(
692
+ self,
693
+ input: AgentRuntimeEndpointCreateInput,
694
+ config: Optional[Config] = None,
695
+ ):
696
+ if self.agent_runtime_id is None:
697
+ raise ValueError(
698
+ "agent_runtime_id is required to create an Agent Runtime"
699
+ " Endpoint"
700
+ )
701
+
702
+ return self.create_endpoint_by_id(
703
+ self.agent_runtime_id, input=input, config=config
704
+ )
705
+
706
+ async def delete_endpoint_async(
707
+ self,
708
+ endpoint_id: str,
709
+ config: Optional[Config] = None,
710
+ ):
711
+ if self.agent_runtime_id is None:
712
+ raise ValueError(
713
+ "agent_runtime_id is required to delete an Agent Runtime"
714
+ " Endpoint"
715
+ )
716
+
717
+ return await self.delete_endpoint_by_id_async(
718
+ self.agent_runtime_id, endpoint_id, config=config
719
+ )
720
+
721
+ def delete_endpoint(
722
+ self,
723
+ endpoint_id: str,
724
+ config: Optional[Config] = None,
725
+ ):
726
+ if self.agent_runtime_id is None:
727
+ raise ValueError(
728
+ "agent_runtime_id is required to delete an Agent Runtime"
729
+ " Endpoint"
730
+ )
731
+
732
+ return self.delete_endpoint_by_id(
733
+ self.agent_runtime_id, endpoint_id, config=config
734
+ )
735
+
736
+ async def update_endpoint_async(
737
+ self,
738
+ endpoint_id: str,
739
+ endpoint: AgentRuntimeEndpointUpdateInput,
740
+ config: Optional[Config] = None,
741
+ ) -> AgentRuntimeEndpoint:
742
+ if self.agent_runtime_id is None:
743
+ raise ValueError(
744
+ "agent_runtime_id is required to update an Agent Runtime"
745
+ " Endpoint"
746
+ )
747
+
748
+ return await self.update_endpoint_by_id_async(
749
+ self.agent_runtime_id,
750
+ endpoint_id,
751
+ endpoint,
752
+ config=config,
753
+ )
754
+
755
+ def update_endpoint(
756
+ self,
757
+ endpoint_id: str,
758
+ endpoint: AgentRuntimeEndpointUpdateInput,
759
+ config: Optional[Config] = None,
760
+ ) -> AgentRuntimeEndpoint:
761
+ if self.agent_runtime_id is None:
762
+ raise ValueError(
763
+ "agent_runtime_id is required to update an Agent Runtime"
764
+ " Endpoint"
765
+ )
766
+
767
+ return self.update_endpoint_by_id(
768
+ self.agent_runtime_id,
769
+ endpoint_id,
770
+ endpoint,
771
+ config=config,
772
+ )
773
+
774
+ async def get_endpoint_async(
775
+ self,
776
+ endpoint_id: str,
777
+ config: Optional[Config] = None,
778
+ ) -> AgentRuntimeEndpoint:
779
+ if self.agent_runtime_id is None:
780
+ raise ValueError(
781
+ "agent_runtime_id is required to get an Agent Runtime Endpoint"
782
+ )
783
+
784
+ return await self.get_endpoint_by_id_async(
785
+ self.agent_runtime_id,
786
+ endpoint_id,
787
+ config=config,
788
+ )
789
+
790
+ def get_endpoint(
791
+ self,
792
+ endpoint_id: str,
793
+ config: Optional[Config] = None,
794
+ ) -> AgentRuntimeEndpoint:
795
+ if self.agent_runtime_id is None:
796
+ raise ValueError(
797
+ "agent_runtime_id is required to get an Agent Runtime Endpoint"
798
+ )
799
+
800
+ return self.get_endpoint_by_id(
801
+ self.agent_runtime_id,
802
+ endpoint_id,
803
+ config=config,
804
+ )
805
+
806
+ async def list_endpoints_async(
807
+ self,
808
+ config: Optional[Config] = None,
809
+ ) -> List[AgentRuntimeEndpoint]:
810
+ if self.agent_runtime_id is None:
811
+ raise ValueError(
812
+ "agent_runtime_id is required to list Agent Runtime Endpoints"
813
+ )
814
+
815
+ return await self.list_endpoints_by_id_async(
816
+ self.agent_runtime_id,
817
+ config=config,
818
+ )
819
+
820
+ def list_endpoints(
821
+ self,
822
+ config: Optional[Config] = None,
823
+ ) -> List[AgentRuntimeEndpoint]:
824
+ if self.agent_runtime_id is None:
825
+ raise ValueError(
826
+ "agent_runtime_id is required to list Agent Runtime Endpoints"
827
+ )
828
+
829
+ return self.list_endpoints_by_id(
830
+ self.agent_runtime_id,
831
+ config=config,
832
+ )
833
+
834
+ async def list_versions_async(
835
+ self,
836
+ config: Optional[Config] = None,
837
+ ) -> List[AgentRuntimeVersion]:
838
+ if self.agent_runtime_id is None:
839
+ raise ValueError(
840
+ "agent_runtime_id is required to list Agent Runtime Versions"
841
+ )
842
+
843
+ return await self.list_versions_by_id_async(
844
+ self.agent_runtime_id,
845
+ config=config,
846
+ )
847
+
848
+ def list_versions(
849
+ self,
850
+ config: Optional[Config] = None,
851
+ ) -> List[AgentRuntimeVersion]:
852
+ if self.agent_runtime_id is None:
853
+ raise ValueError(
854
+ "agent_runtime_id is required to list Agent Runtime Versions"
855
+ )
856
+
857
+ return self.list_versions_by_id(
858
+ self.agent_runtime_id,
859
+ config=config,
860
+ )
861
+
862
+ async def invoke_openai_async(
863
+ self,
864
+ agent_runtime_endpoint_name: str = "Default",
865
+ **kwargs: Unpack[InvokeArgs],
866
+ ):
867
+ cfg = Config.with_configs(self._config, kwargs.get("config"))
868
+ kwargs["config"] = cfg
869
+
870
+ if not self.__data_api:
871
+ self.__data_api: Dict[str, AgentRuntimeDataAPI] = {}
872
+
873
+ if self.__data_api[agent_runtime_endpoint_name] is None:
874
+ self.__data_api[agent_runtime_endpoint_name] = AgentRuntimeDataAPI(
875
+ agent_runtime_name=self.agent_runtime_name or "",
876
+ agent_runtime_endpoint_name=agent_runtime_endpoint_name or "",
877
+ config=cfg,
878
+ )
879
+
880
+ return await self.__data_api[
881
+ agent_runtime_endpoint_name
882
+ ].invoke_openai_async(**kwargs)
883
+
884
+ def invoke_openai(
885
+ self,
886
+ agent_runtime_endpoint_name: str = "Default",
887
+ **kwargs: Unpack[InvokeArgs],
888
+ ):
889
+ cfg = Config.with_configs(self._config, kwargs.get("config"))
890
+ kwargs["config"] = cfg
891
+
892
+ if not self.__data_api:
893
+ self.__data_api: Dict[str, AgentRuntimeDataAPI] = {}
894
+
895
+ if self.__data_api[agent_runtime_endpoint_name] is None:
896
+ self.__data_api[agent_runtime_endpoint_name] = AgentRuntimeDataAPI(
897
+ agent_runtime_name=self.agent_runtime_name or "",
898
+ agent_runtime_endpoint_name=agent_runtime_endpoint_name or "",
899
+ config=cfg,
900
+ )
901
+
902
+ return self.__data_api[agent_runtime_endpoint_name].invoke_openai(
903
+ **kwargs
904
+ )