agentrun-inner-test 0.0.46__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.
Files changed (135) hide show
  1. agentrun/__init__.py +325 -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 +12 -0
  24. agentrun/integration/agentscope/adapter.py +17 -0
  25. agentrun/integration/agentscope/builtin.py +65 -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 +16 -0
  30. agentrun/integration/builtin/model.py +93 -0
  31. agentrun/integration/builtin/sandbox.py +1234 -0
  32. agentrun/integration/builtin/toolset.py +47 -0
  33. agentrun/integration/crewai/__init__.py +12 -0
  34. agentrun/integration/crewai/adapter.py +9 -0
  35. agentrun/integration/crewai/builtin.py +65 -0
  36. agentrun/integration/crewai/model_adapter.py +31 -0
  37. agentrun/integration/crewai/tool_adapter.py +26 -0
  38. agentrun/integration/google_adk/__init__.py +12 -0
  39. agentrun/integration/google_adk/adapter.py +15 -0
  40. agentrun/integration/google_adk/builtin.py +65 -0
  41. agentrun/integration/google_adk/message_adapter.py +144 -0
  42. agentrun/integration/google_adk/model_adapter.py +46 -0
  43. agentrun/integration/google_adk/tool_adapter.py +235 -0
  44. agentrun/integration/langchain/__init__.py +30 -0
  45. agentrun/integration/langchain/adapter.py +15 -0
  46. agentrun/integration/langchain/builtin.py +71 -0
  47. agentrun/integration/langchain/message_adapter.py +141 -0
  48. agentrun/integration/langchain/model_adapter.py +37 -0
  49. agentrun/integration/langchain/tool_adapter.py +50 -0
  50. agentrun/integration/langgraph/__init__.py +35 -0
  51. agentrun/integration/langgraph/adapter.py +20 -0
  52. agentrun/integration/langgraph/agent_converter.py +1073 -0
  53. agentrun/integration/langgraph/builtin.py +65 -0
  54. agentrun/integration/pydantic_ai/__init__.py +12 -0
  55. agentrun/integration/pydantic_ai/adapter.py +13 -0
  56. agentrun/integration/pydantic_ai/builtin.py +65 -0
  57. agentrun/integration/pydantic_ai/model_adapter.py +44 -0
  58. agentrun/integration/pydantic_ai/tool_adapter.py +19 -0
  59. agentrun/integration/utils/__init__.py +112 -0
  60. agentrun/integration/utils/adapter.py +560 -0
  61. agentrun/integration/utils/canonical.py +164 -0
  62. agentrun/integration/utils/converter.py +134 -0
  63. agentrun/integration/utils/model.py +110 -0
  64. agentrun/integration/utils/tool.py +1759 -0
  65. agentrun/model/__client_async_template.py +357 -0
  66. agentrun/model/__init__.py +57 -0
  67. agentrun/model/__model_proxy_async_template.py +270 -0
  68. agentrun/model/__model_service_async_template.py +267 -0
  69. agentrun/model/api/__init__.py +6 -0
  70. agentrun/model/api/control.py +1173 -0
  71. agentrun/model/api/data.py +196 -0
  72. agentrun/model/client.py +674 -0
  73. agentrun/model/model.py +235 -0
  74. agentrun/model/model_proxy.py +439 -0
  75. agentrun/model/model_service.py +438 -0
  76. agentrun/sandbox/__aio_sandbox_async_template.py +523 -0
  77. agentrun/sandbox/__browser_sandbox_async_template.py +110 -0
  78. agentrun/sandbox/__client_async_template.py +491 -0
  79. agentrun/sandbox/__code_interpreter_sandbox_async_template.py +463 -0
  80. agentrun/sandbox/__init__.py +69 -0
  81. agentrun/sandbox/__sandbox_async_template.py +463 -0
  82. agentrun/sandbox/__template_async_template.py +152 -0
  83. agentrun/sandbox/aio_sandbox.py +905 -0
  84. agentrun/sandbox/api/__aio_data_async_template.py +335 -0
  85. agentrun/sandbox/api/__browser_data_async_template.py +140 -0
  86. agentrun/sandbox/api/__code_interpreter_data_async_template.py +206 -0
  87. agentrun/sandbox/api/__init__.py +19 -0
  88. agentrun/sandbox/api/__sandbox_data_async_template.py +107 -0
  89. agentrun/sandbox/api/aio_data.py +551 -0
  90. agentrun/sandbox/api/browser_data.py +172 -0
  91. agentrun/sandbox/api/code_interpreter_data.py +396 -0
  92. agentrun/sandbox/api/control.py +1051 -0
  93. agentrun/sandbox/api/playwright_async.py +492 -0
  94. agentrun/sandbox/api/playwright_sync.py +492 -0
  95. agentrun/sandbox/api/sandbox_data.py +154 -0
  96. agentrun/sandbox/browser_sandbox.py +185 -0
  97. agentrun/sandbox/client.py +925 -0
  98. agentrun/sandbox/code_interpreter_sandbox.py +823 -0
  99. agentrun/sandbox/model.py +397 -0
  100. agentrun/sandbox/sandbox.py +848 -0
  101. agentrun/sandbox/template.py +217 -0
  102. agentrun/server/__init__.py +191 -0
  103. agentrun/server/agui_normalizer.py +180 -0
  104. agentrun/server/agui_protocol.py +797 -0
  105. agentrun/server/invoker.py +309 -0
  106. agentrun/server/model.py +427 -0
  107. agentrun/server/openai_protocol.py +535 -0
  108. agentrun/server/protocol.py +140 -0
  109. agentrun/server/server.py +208 -0
  110. agentrun/toolset/__client_async_template.py +62 -0
  111. agentrun/toolset/__init__.py +51 -0
  112. agentrun/toolset/__toolset_async_template.py +204 -0
  113. agentrun/toolset/api/__init__.py +17 -0
  114. agentrun/toolset/api/control.py +262 -0
  115. agentrun/toolset/api/mcp.py +100 -0
  116. agentrun/toolset/api/openapi.py +1251 -0
  117. agentrun/toolset/client.py +102 -0
  118. agentrun/toolset/model.py +321 -0
  119. agentrun/toolset/toolset.py +270 -0
  120. agentrun/utils/__data_api_async_template.py +720 -0
  121. agentrun/utils/__init__.py +5 -0
  122. agentrun/utils/__resource_async_template.py +158 -0
  123. agentrun/utils/config.py +258 -0
  124. agentrun/utils/control_api.py +78 -0
  125. agentrun/utils/data_api.py +1120 -0
  126. agentrun/utils/exception.py +151 -0
  127. agentrun/utils/helper.py +108 -0
  128. agentrun/utils/log.py +77 -0
  129. agentrun/utils/model.py +168 -0
  130. agentrun/utils/resource.py +291 -0
  131. agentrun_inner_test-0.0.46.dist-info/METADATA +263 -0
  132. agentrun_inner_test-0.0.46.dist-info/RECORD +135 -0
  133. agentrun_inner_test-0.0.46.dist-info/WHEEL +5 -0
  134. agentrun_inner_test-0.0.46.dist-info/licenses/LICENSE +201 -0
  135. agentrun_inner_test-0.0.46.dist-info/top_level.txt +1 -0
@@ -0,0 +1,868 @@
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/__client_async_template.py
10
+
11
+ Agent Runtime 客户端 / Agent Runtime Client
12
+
13
+ 此模块提供 Agent Runtime 的客户端API,用于管理智能体运行时。
14
+ This module provides the client API for Agent Runtime to manage agent runtimes.
15
+ """
16
+
17
+ from typing import List, Optional
18
+
19
+ from alibabacloud_agentrun20250910.models import (
20
+ CreateAgentRuntimeEndpointInput,
21
+ CreateAgentRuntimeInput,
22
+ GetAgentRuntimeRequest,
23
+ ListAgentRuntimeEndpointsRequest,
24
+ ListAgentRuntimesRequest,
25
+ ListAgentRuntimeVersionsRequest,
26
+ UpdateAgentRuntimeEndpointInput,
27
+ UpdateAgentRuntimeInput,
28
+ )
29
+ from typing_extensions import Unpack
30
+
31
+ from agentrun.agent_runtime.api.data import InvokeArgs
32
+ from agentrun.agent_runtime.model import (
33
+ AgentRuntimeArtifact,
34
+ AgentRuntimeCreateInput,
35
+ AgentRuntimeEndpointCreateInput,
36
+ AgentRuntimeEndpointListInput,
37
+ AgentRuntimeEndpointUpdateInput,
38
+ AgentRuntimeListInput,
39
+ AgentRuntimeUpdateInput,
40
+ AgentRuntimeVersion,
41
+ AgentRuntimeVersionListInput,
42
+ NetworkConfig,
43
+ )
44
+ from agentrun.agent_runtime.runtime import AgentRuntime
45
+ from agentrun.utils.config import Config
46
+ from agentrun.utils.exception import HTTPError
47
+
48
+ from .api import AgentRuntimeControlAPI, AgentRuntimeDataAPI
49
+ from .endpoint import AgentRuntimeEndpoint
50
+
51
+
52
+ class AgentRuntimeClient:
53
+ """Agent Runtime 客户端 / Agent Runtime Client
54
+
55
+ 提供 Agent Runtime 的创建、删除、更新、查询和端点管理功能。
56
+ Provides create, delete, update, query and endpoint management functions for Agent Runtime.
57
+ """
58
+
59
+ def __init__(self, config: Optional[Config] = None):
60
+ """初始化客户端 / Initialize client
61
+
62
+ Args:
63
+ config: 配置对象,可选 / Configuration object, optional
64
+ """
65
+ self.config = config
66
+ self.__control_api = AgentRuntimeControlAPI(config)
67
+
68
+ async def create_async(
69
+ self, input: AgentRuntimeCreateInput, config: Optional[Config] = None
70
+ ) -> AgentRuntime:
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: 当既未提供代码配置也未提供容器配置时 / When neither code nor container configuration is provided
82
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
83
+ ResourceNotExistError: 资源不存在 / Resource does not exist
84
+ HTTPError: HTTP 请求错误 / HTTP request error
85
+ """
86
+ if input.network_configuration is None:
87
+ input.network_configuration = NetworkConfig()
88
+
89
+ if input.artifact_type is None:
90
+ if input.code_configuration is not None:
91
+ input.artifact_type = AgentRuntimeArtifact.CODE
92
+ elif input.container_configuration is not None:
93
+ input.artifact_type = AgentRuntimeArtifact.CONTAINER
94
+ else:
95
+ raise ValueError(
96
+ "Either code_configuration or image_configuration must be"
97
+ " provided."
98
+ )
99
+
100
+ try:
101
+ result = await self.__control_api.create_agent_runtime_async(
102
+ CreateAgentRuntimeInput().from_map(input.model_dump()),
103
+ config=config,
104
+ )
105
+ except HTTPError as e:
106
+ raise e.to_resource_error(
107
+ "AgentRuntime", input.agent_runtime_name
108
+ ) from e
109
+ return AgentRuntime.from_inner_object(result)
110
+
111
+ def create(
112
+ self, input: AgentRuntimeCreateInput, config: Optional[Config] = None
113
+ ) -> AgentRuntime:
114
+ """同步创建 Agent Runtime / Create Agent Runtime asynchronously
115
+
116
+ Args:
117
+ input: Agent Runtime 创建配置 / Agent Runtime creation configuration
118
+ config: 配置对象,可选 / Configuration object, optional
119
+
120
+ Returns:
121
+ AgentRuntime: 创建的 Agent Runtime 对象 / Created Agent Runtime object
122
+
123
+ Raises:
124
+ ValueError: 当既未提供代码配置也未提供容器配置时 / When neither code nor container configuration is provided
125
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
126
+ ResourceNotExistError: 资源不存在 / Resource does not exist
127
+ HTTPError: HTTP 请求错误 / HTTP request error
128
+ """
129
+ if input.network_configuration is None:
130
+ input.network_configuration = NetworkConfig()
131
+
132
+ if input.artifact_type is None:
133
+ if input.code_configuration is not None:
134
+ input.artifact_type = AgentRuntimeArtifact.CODE
135
+ elif input.container_configuration is not None:
136
+ input.artifact_type = AgentRuntimeArtifact.CONTAINER
137
+ else:
138
+ raise ValueError(
139
+ "Either code_configuration or image_configuration must be"
140
+ " provided."
141
+ )
142
+
143
+ try:
144
+ result = self.__control_api.create_agent_runtime(
145
+ CreateAgentRuntimeInput().from_map(input.model_dump()),
146
+ config=config,
147
+ )
148
+ except HTTPError as e:
149
+ raise e.to_resource_error(
150
+ "AgentRuntime", input.agent_runtime_name
151
+ ) from e
152
+ return AgentRuntime.from_inner_object(result)
153
+
154
+ async def delete_async(
155
+ self, id: str, config: Optional[Config] = None
156
+ ) -> AgentRuntime:
157
+ """异步删除 Agent Runtime / Delete Agent Runtime asynchronously
158
+
159
+ Args:
160
+ id: Agent Runtime ID
161
+ config: 配置对象,可选 / Configuration object, optional
162
+
163
+ Returns:
164
+ AgentRuntime: 删除的 Agent Runtime 对象 / Deleted Agent Runtime object
165
+
166
+ Raises:
167
+ ResourceNotExistError: 资源不存在 / Resource does not exist
168
+ HTTPError: HTTP 请求错误 / HTTP request error
169
+ """
170
+ try:
171
+ result = await self.__control_api.delete_agent_runtime_async(
172
+ id, config=config
173
+ )
174
+ return AgentRuntime.from_inner_object(result)
175
+ except HTTPError as e:
176
+ raise e.to_resource_error("AgentRuntime", id) from e
177
+
178
+ def delete(self, id: str, config: Optional[Config] = None) -> AgentRuntime:
179
+ """同步删除 Agent Runtime / Delete Agent Runtime asynchronously
180
+
181
+ Args:
182
+ id: Agent Runtime ID
183
+ config: 配置对象,可选 / Configuration object, optional
184
+
185
+ Returns:
186
+ AgentRuntime: 删除的 Agent Runtime 对象 / Deleted Agent Runtime object
187
+
188
+ Raises:
189
+ ResourceNotExistError: 资源不存在 / Resource does not exist
190
+ HTTPError: HTTP 请求错误 / HTTP request error
191
+ """
192
+ try:
193
+ result = self.__control_api.delete_agent_runtime(id, config=config)
194
+ return AgentRuntime.from_inner_object(result)
195
+ except HTTPError as e:
196
+ raise e.to_resource_error("AgentRuntime", id) from e
197
+
198
+ async def update_async(
199
+ self,
200
+ id: str,
201
+ input: AgentRuntimeUpdateInput,
202
+ config: Optional[Config] = None,
203
+ ) -> AgentRuntime:
204
+ """异步更新 Agent Runtime / Update Agent Runtime asynchronously
205
+
206
+ Args:
207
+ id: Agent Runtime ID
208
+ input: Agent Runtime 更新配置 / Agent Runtime update configuration
209
+ config: 配置对象,可选 / Configuration object, optional
210
+
211
+ Returns:
212
+ AgentRuntime: 更新后的 Agent Runtime 对象 / Updated Agent Runtime object
213
+
214
+ Raises:
215
+ ResourceNotExistError: 资源不存在 / Resource does not exist
216
+ HTTPError: HTTP 请求错误 / HTTP request error
217
+ """
218
+ try:
219
+ result = await self.__control_api.update_agent_runtime_async(
220
+ id,
221
+ UpdateAgentRuntimeInput().from_map(input.model_dump()),
222
+ config=config,
223
+ )
224
+ return AgentRuntime.from_inner_object(result)
225
+ except HTTPError as e:
226
+ raise e.to_resource_error("AgentRuntime", id) from e
227
+
228
+ def update(
229
+ self,
230
+ id: str,
231
+ input: AgentRuntimeUpdateInput,
232
+ config: Optional[Config] = None,
233
+ ) -> AgentRuntime:
234
+ """同步更新 Agent Runtime / Update Agent Runtime asynchronously
235
+
236
+ Args:
237
+ id: Agent Runtime ID
238
+ input: Agent Runtime 更新配置 / Agent Runtime update configuration
239
+ config: 配置对象,可选 / Configuration object, optional
240
+
241
+ Returns:
242
+ AgentRuntime: 更新后的 Agent Runtime 对象 / Updated Agent Runtime object
243
+
244
+ Raises:
245
+ ResourceNotExistError: 资源不存在 / Resource does not exist
246
+ HTTPError: HTTP 请求错误 / HTTP request error
247
+ """
248
+ try:
249
+ result = self.__control_api.update_agent_runtime(
250
+ id,
251
+ UpdateAgentRuntimeInput().from_map(input.model_dump()),
252
+ config=config,
253
+ )
254
+ return AgentRuntime.from_inner_object(result)
255
+ except HTTPError as e:
256
+ raise e.to_resource_error("AgentRuntime", id) from e
257
+
258
+ async def get_async(
259
+ self,
260
+ id: str,
261
+ config: Optional[Config] = None,
262
+ ) -> AgentRuntime:
263
+ """异步获取 Agent Runtime / Get Agent Runtime asynchronously
264
+
265
+ Args:
266
+ id: Agent Runtime ID
267
+ config: 配置对象,可选 / Configuration object, optional
268
+
269
+ Returns:
270
+ AgentRuntime: Agent Runtime 对象 / Agent Runtime object
271
+
272
+ Raises:
273
+ ResourceNotExistError: 资源不存在 / Resource does not exist
274
+ HTTPError: HTTP 请求错误 / HTTP request error
275
+ """
276
+ try:
277
+ result = await self.__control_api.get_agent_runtime_async(
278
+ id, GetAgentRuntimeRequest(), config=config
279
+ )
280
+ return AgentRuntime.from_inner_object(result)
281
+ except HTTPError as e:
282
+ raise e.to_resource_error("AgentRuntime", id) from e
283
+
284
+ def get(
285
+ self,
286
+ id: str,
287
+ config: Optional[Config] = None,
288
+ ) -> AgentRuntime:
289
+ """同步获取 Agent Runtime / Get Agent Runtime asynchronously
290
+
291
+ Args:
292
+ id: Agent Runtime ID
293
+ config: 配置对象,可选 / Configuration object, optional
294
+
295
+ Returns:
296
+ AgentRuntime: Agent Runtime 对象 / Agent Runtime object
297
+
298
+ Raises:
299
+ ResourceNotExistError: 资源不存在 / Resource does not exist
300
+ HTTPError: HTTP 请求错误 / HTTP request error
301
+ """
302
+ try:
303
+ result = self.__control_api.get_agent_runtime(
304
+ id, GetAgentRuntimeRequest(), config=config
305
+ )
306
+ return AgentRuntime.from_inner_object(result)
307
+ except HTTPError as e:
308
+ raise e.to_resource_error("AgentRuntime", id) from e
309
+
310
+ async def list_async(
311
+ self,
312
+ input: Optional[AgentRuntimeListInput] = None,
313
+ config: Optional[Config] = None,
314
+ ) -> List[AgentRuntime]:
315
+ """异步列出 Agent Runtimes / List Agent Runtimes asynchronously
316
+
317
+ Args:
318
+ input: 列表查询配置,可选 / List query configuration, optional
319
+ config: 配置对象,可选 / Configuration object, optional
320
+
321
+ Returns:
322
+ List[AgentRuntime]: Agent Runtime 对象列表 / List of Agent Runtime objects
323
+
324
+ Raises:
325
+ HTTPError: HTTP 请求错误 / HTTP request error
326
+ """
327
+ try:
328
+ if input is None:
329
+ input = AgentRuntimeListInput()
330
+
331
+ results = await self.__control_api.list_agent_runtimes_async(
332
+ ListAgentRuntimesRequest().from_map(input.model_dump()),
333
+ config=config,
334
+ )
335
+ return [
336
+ AgentRuntime.from_inner_object(item) for item in results.items
337
+ ]
338
+ except HTTPError as e:
339
+ raise e.to_resource_error("AgentRuntime") from e
340
+
341
+ def list(
342
+ self,
343
+ input: Optional[AgentRuntimeListInput] = None,
344
+ config: Optional[Config] = None,
345
+ ) -> List[AgentRuntime]:
346
+ """同步列出 Agent Runtimes / List Agent Runtimes asynchronously
347
+
348
+ Args:
349
+ input: 列表查询配置,可选 / List query configuration, optional
350
+ config: 配置对象,可选 / Configuration object, optional
351
+
352
+ Returns:
353
+ List[AgentRuntime]: Agent Runtime 对象列表 / List of Agent Runtime objects
354
+
355
+ Raises:
356
+ HTTPError: HTTP 请求错误 / HTTP request error
357
+ """
358
+ try:
359
+ if input is None:
360
+ input = AgentRuntimeListInput()
361
+
362
+ results = self.__control_api.list_agent_runtimes(
363
+ ListAgentRuntimesRequest().from_map(input.model_dump()),
364
+ config=config,
365
+ )
366
+ return [
367
+ AgentRuntime.from_inner_object(item) for item in results.items
368
+ ]
369
+ except HTTPError as e:
370
+ raise e.to_resource_error("AgentRuntime") from e
371
+
372
+ async def create_endpoint_async(
373
+ self,
374
+ agent_runtime_id: str,
375
+ endpoint: AgentRuntimeEndpointCreateInput,
376
+ config: Optional[Config] = None,
377
+ ) -> AgentRuntimeEndpoint:
378
+ """异步创建 Agent Runtime 端点 / Create Agent Runtime Endpoint asynchronously
379
+
380
+ Args:
381
+ agent_runtime_id: Agent Runtime ID
382
+ endpoint: 端点创建配置 / Endpoint creation configuration
383
+ config: 配置对象,可选 / Configuration object, optional
384
+
385
+ Returns:
386
+ AgentRuntimeEndpoint: 创建的端点对象 / Created endpoint object
387
+
388
+ Raises:
389
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
390
+ ResourceNotExistError: Agent Runtime 不存在 / Agent Runtime does not exist
391
+ HTTPError: HTTP 请求错误 / HTTP request error
392
+ """
393
+ try:
394
+ result = (
395
+ await self.__control_api.create_agent_runtime_endpoint_async(
396
+ agent_runtime_id,
397
+ CreateAgentRuntimeEndpointInput().from_map(
398
+ endpoint.model_dump()
399
+ ),
400
+ config=config,
401
+ )
402
+ )
403
+ except HTTPError as e:
404
+ raise e.to_resource_error(
405
+ "AgentRuntimeEndpoint",
406
+ "/".join([
407
+ agent_runtime_id,
408
+ endpoint.agent_runtime_endpoint_name or "",
409
+ ]),
410
+ ) from e
411
+
412
+ return AgentRuntimeEndpoint.from_inner_object(result)
413
+
414
+ def create_endpoint(
415
+ self,
416
+ agent_runtime_id: str,
417
+ endpoint: AgentRuntimeEndpointCreateInput,
418
+ config: Optional[Config] = None,
419
+ ) -> AgentRuntimeEndpoint:
420
+ """同步创建 Agent Runtime 端点 / Create Agent Runtime Endpoint asynchronously
421
+
422
+ Args:
423
+ agent_runtime_id: Agent Runtime ID
424
+ endpoint: 端点创建配置 / Endpoint creation configuration
425
+ config: 配置对象,可选 / Configuration object, optional
426
+
427
+ Returns:
428
+ AgentRuntimeEndpoint: 创建的端点对象 / Created endpoint object
429
+
430
+ Raises:
431
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
432
+ ResourceNotExistError: Agent Runtime 不存在 / Agent Runtime does not exist
433
+ HTTPError: HTTP 请求错误 / HTTP request error
434
+ """
435
+ try:
436
+ result = self.__control_api.create_agent_runtime_endpoint(
437
+ agent_runtime_id,
438
+ CreateAgentRuntimeEndpointInput().from_map(
439
+ endpoint.model_dump()
440
+ ),
441
+ config=config,
442
+ )
443
+ except HTTPError as e:
444
+ raise e.to_resource_error(
445
+ "AgentRuntimeEndpoint",
446
+ "/".join([
447
+ agent_runtime_id,
448
+ endpoint.agent_runtime_endpoint_name or "",
449
+ ]),
450
+ ) from e
451
+
452
+ return AgentRuntimeEndpoint.from_inner_object(result)
453
+
454
+ async def delete_endpoint_async(
455
+ self,
456
+ agent_runtime_id: str,
457
+ endpoint_id: str,
458
+ config: Optional[Config] = None,
459
+ ) -> AgentRuntimeEndpoint:
460
+ """异步删除 Agent Runtime 端点 / Delete Agent Runtime Endpoint asynchronously
461
+
462
+ Args:
463
+ agent_runtime_id: Agent Runtime ID
464
+ endpoint_id: 端点 ID / Endpoint ID
465
+ config: 配置对象,可选 / Configuration object, optional
466
+
467
+ Returns:
468
+ AgentRuntimeEndpoint: 删除的端点对象 / Deleted endpoint object
469
+
470
+ Raises:
471
+ ResourceNotExistError: 资源不存在 / Resource does not exist
472
+ HTTPError: HTTP 请求错误 / HTTP request error
473
+ """
474
+ try:
475
+ result = (
476
+ await self.__control_api.delete_agent_runtime_endpoint_async(
477
+ agent_runtime_id,
478
+ endpoint_id,
479
+ config=config,
480
+ )
481
+ )
482
+ except HTTPError as e:
483
+ raise e.to_resource_error(
484
+ "AgentRuntimeEndpoint",
485
+ "/".join([
486
+ agent_runtime_id,
487
+ endpoint_id,
488
+ ]),
489
+ ) from e
490
+
491
+ return AgentRuntimeEndpoint.from_inner_object(result)
492
+
493
+ def delete_endpoint(
494
+ self,
495
+ agent_runtime_id: str,
496
+ endpoint_id: str,
497
+ config: Optional[Config] = None,
498
+ ) -> AgentRuntimeEndpoint:
499
+ """同步删除 Agent Runtime 端点 / Delete Agent Runtime Endpoint asynchronously
500
+
501
+ Args:
502
+ agent_runtime_id: Agent Runtime ID
503
+ endpoint_id: 端点 ID / Endpoint ID
504
+ config: 配置对象,可选 / Configuration object, optional
505
+
506
+ Returns:
507
+ AgentRuntimeEndpoint: 删除的端点对象 / Deleted endpoint object
508
+
509
+ Raises:
510
+ ResourceNotExistError: 资源不存在 / Resource does not exist
511
+ HTTPError: HTTP 请求错误 / HTTP request error
512
+ """
513
+ try:
514
+ result = self.__control_api.delete_agent_runtime_endpoint(
515
+ agent_runtime_id,
516
+ endpoint_id,
517
+ config=config,
518
+ )
519
+ except HTTPError as e:
520
+ raise e.to_resource_error(
521
+ "AgentRuntimeEndpoint",
522
+ "/".join([
523
+ agent_runtime_id,
524
+ endpoint_id,
525
+ ]),
526
+ ) from e
527
+
528
+ return AgentRuntimeEndpoint.from_inner_object(result)
529
+
530
+ async def update_endpoint_async(
531
+ self,
532
+ agent_runtime_id: str,
533
+ endpoint_id: str,
534
+ endpoint: AgentRuntimeEndpointUpdateInput,
535
+ config: Optional[Config] = None,
536
+ ) -> AgentRuntimeEndpoint:
537
+ """异步更新 Agent Runtime 端点 / Update Agent Runtime Endpoint asynchronously
538
+
539
+ Args:
540
+ agent_runtime_id: Agent Runtime ID
541
+ endpoint_id: 端点 ID / Endpoint ID
542
+ endpoint: 端点更新配置 / Endpoint update configuration
543
+ config: 配置对象,可选 / Configuration object, optional
544
+
545
+ Returns:
546
+ AgentRuntimeEndpoint: 更新后的端点对象 / Updated endpoint object
547
+
548
+ Raises:
549
+ ResourceNotExistError: 资源不存在 / Resource does not exist
550
+ HTTPError: HTTP 请求错误 / HTTP request error
551
+ """
552
+ try:
553
+ result = (
554
+ await self.__control_api.update_agent_runtime_endpoint_async(
555
+ agent_runtime_id,
556
+ endpoint_id,
557
+ UpdateAgentRuntimeEndpointInput().from_map(
558
+ endpoint.model_dump()
559
+ ),
560
+ config=config,
561
+ )
562
+ )
563
+ except HTTPError as e:
564
+ raise e.to_resource_error(
565
+ "AgentRuntimeEndpoint",
566
+ "/".join([
567
+ agent_runtime_id,
568
+ endpoint_id,
569
+ ]),
570
+ ) from e
571
+
572
+ return AgentRuntimeEndpoint.from_inner_object(result)
573
+
574
+ def update_endpoint(
575
+ self,
576
+ agent_runtime_id: str,
577
+ endpoint_id: str,
578
+ endpoint: AgentRuntimeEndpointUpdateInput,
579
+ config: Optional[Config] = None,
580
+ ) -> AgentRuntimeEndpoint:
581
+ """同步更新 Agent Runtime 端点 / Update Agent Runtime Endpoint asynchronously
582
+
583
+ Args:
584
+ agent_runtime_id: Agent Runtime ID
585
+ endpoint_id: 端点 ID / Endpoint ID
586
+ endpoint: 端点更新配置 / Endpoint update configuration
587
+ config: 配置对象,可选 / Configuration object, optional
588
+
589
+ Returns:
590
+ AgentRuntimeEndpoint: 更新后的端点对象 / Updated endpoint object
591
+
592
+ Raises:
593
+ ResourceNotExistError: 资源不存在 / Resource does not exist
594
+ HTTPError: HTTP 请求错误 / HTTP request error
595
+ """
596
+ try:
597
+ result = self.__control_api.update_agent_runtime_endpoint(
598
+ agent_runtime_id,
599
+ endpoint_id,
600
+ UpdateAgentRuntimeEndpointInput().from_map(
601
+ endpoint.model_dump()
602
+ ),
603
+ config=config,
604
+ )
605
+ except HTTPError as e:
606
+ raise e.to_resource_error(
607
+ "AgentRuntimeEndpoint",
608
+ "/".join([
609
+ agent_runtime_id,
610
+ endpoint_id,
611
+ ]),
612
+ ) from e
613
+
614
+ return AgentRuntimeEndpoint.from_inner_object(result)
615
+
616
+ async def get_endpoint_async(
617
+ self,
618
+ agent_runtime_id: str,
619
+ endpoint_id: str,
620
+ config: Optional[Config] = None,
621
+ ) -> AgentRuntimeEndpoint:
622
+ """异步获取 Agent Runtime 端点 / Get Agent Runtime Endpoint asynchronously
623
+
624
+ Args:
625
+ agent_runtime_id: Agent Runtime ID
626
+ endpoint_id: 端点 ID / Endpoint ID
627
+ config: 配置对象,可选 / Configuration object, optional
628
+
629
+ Returns:
630
+ AgentRuntimeEndpoint: 端点对象 / Endpoint object
631
+
632
+ Raises:
633
+ ResourceNotExistError: 资源不存在 / Resource does not exist
634
+ HTTPError: HTTP 请求错误 / HTTP request error
635
+ """
636
+ try:
637
+ result = await self.__control_api.get_agent_runtime_endpoint_async(
638
+ agent_runtime_id,
639
+ endpoint_id,
640
+ config=config,
641
+ )
642
+ except HTTPError as e:
643
+ raise e.to_resource_error(
644
+ "AgentRuntimeEndpoint",
645
+ "/".join([
646
+ agent_runtime_id,
647
+ endpoint_id,
648
+ ]),
649
+ ) from e
650
+
651
+ return AgentRuntimeEndpoint.from_inner_object(result)
652
+
653
+ def get_endpoint(
654
+ self,
655
+ agent_runtime_id: str,
656
+ endpoint_id: str,
657
+ config: Optional[Config] = None,
658
+ ) -> AgentRuntimeEndpoint:
659
+ """同步获取 Agent Runtime 端点 / Get Agent Runtime Endpoint asynchronously
660
+
661
+ Args:
662
+ agent_runtime_id: Agent Runtime ID
663
+ endpoint_id: 端点 ID / Endpoint ID
664
+ config: 配置对象,可选 / Configuration object, optional
665
+
666
+ Returns:
667
+ AgentRuntimeEndpoint: 端点对象 / Endpoint object
668
+
669
+ Raises:
670
+ ResourceNotExistError: 资源不存在 / Resource does not exist
671
+ HTTPError: HTTP 请求错误 / HTTP request error
672
+ """
673
+ try:
674
+ result = self.__control_api.get_agent_runtime_endpoint(
675
+ agent_runtime_id,
676
+ endpoint_id,
677
+ config=config,
678
+ )
679
+ except HTTPError as e:
680
+ raise e.to_resource_error(
681
+ "AgentRuntimeEndpoint",
682
+ "/".join([
683
+ agent_runtime_id,
684
+ endpoint_id,
685
+ ]),
686
+ ) from e
687
+
688
+ return AgentRuntimeEndpoint.from_inner_object(result)
689
+
690
+ async def list_endpoints_async(
691
+ self,
692
+ agent_runtime_id: str,
693
+ input: Optional[AgentRuntimeEndpointListInput] = None,
694
+ config: Optional[Config] = None,
695
+ ) -> List[AgentRuntimeEndpoint]:
696
+ """异步列出 Agent Runtime 端点 / List Agent Runtime Endpoints asynchronously
697
+
698
+ Args:
699
+ agent_runtime_id: Agent Runtime ID
700
+ input: 列表查询配置,可选 / List query configuration, optional
701
+ config: 配置对象,可选 / Configuration object, optional
702
+
703
+ Returns:
704
+ List[AgentRuntimeEndpoint]: 端点对象列表 / List of endpoint objects
705
+
706
+ Raises:
707
+ HTTPError: HTTP 请求错误 / HTTP request error
708
+ """
709
+ try:
710
+ if input is None:
711
+ input = AgentRuntimeEndpointListInput()
712
+
713
+ results = (
714
+ await self.__control_api.list_agent_runtime_endpoints_async(
715
+ agent_runtime_id,
716
+ ListAgentRuntimeEndpointsRequest().from_map(
717
+ input.model_dump()
718
+ ),
719
+ config=config,
720
+ )
721
+ )
722
+ return [
723
+ AgentRuntimeEndpoint.from_inner_object(item)
724
+ for item in results.items
725
+ ]
726
+ except HTTPError as e:
727
+ raise e.to_resource_error("AgentRuntime", agent_runtime_id) from e
728
+
729
+ def list_endpoints(
730
+ self,
731
+ agent_runtime_id: str,
732
+ input: Optional[AgentRuntimeEndpointListInput] = None,
733
+ config: Optional[Config] = None,
734
+ ) -> List[AgentRuntimeEndpoint]:
735
+ """同步列出 Agent Runtime 端点 / List Agent Runtime Endpoints asynchronously
736
+
737
+ Args:
738
+ agent_runtime_id: Agent Runtime ID
739
+ input: 列表查询配置,可选 / List query configuration, optional
740
+ config: 配置对象,可选 / Configuration object, optional
741
+
742
+ Returns:
743
+ List[AgentRuntimeEndpoint]: 端点对象列表 / List of endpoint objects
744
+
745
+ Raises:
746
+ HTTPError: HTTP 请求错误 / HTTP request error
747
+ """
748
+ try:
749
+ if input is None:
750
+ input = AgentRuntimeEndpointListInput()
751
+
752
+ results = self.__control_api.list_agent_runtime_endpoints(
753
+ agent_runtime_id,
754
+ ListAgentRuntimeEndpointsRequest().from_map(input.model_dump()),
755
+ config=config,
756
+ )
757
+ return [
758
+ AgentRuntimeEndpoint.from_inner_object(item)
759
+ for item in results.items
760
+ ]
761
+ except HTTPError as e:
762
+ raise e.to_resource_error("AgentRuntime", agent_runtime_id) from e
763
+
764
+ async def list_versions_async(
765
+ self,
766
+ agent_runtime_id: str,
767
+ input: Optional[AgentRuntimeVersionListInput] = None,
768
+ config: Optional[Config] = None,
769
+ ) -> List[AgentRuntimeVersion]:
770
+ """异步列出 Agent Runtime 版本 / List Agent Runtime Versions asynchronously
771
+
772
+ Args:
773
+ agent_runtime_id: Agent Runtime ID
774
+ input: 列表查询配置,可选 / List query configuration, optional
775
+ config: 配置对象,可选 / Configuration object, optional
776
+
777
+ Returns:
778
+ List[AgentRuntimeVersion]: 版本对象列表 / List of version objects
779
+
780
+ Raises:
781
+ HTTPError: HTTP 请求错误 / HTTP request error
782
+ """
783
+ try:
784
+ if input is None:
785
+ input = AgentRuntimeVersionListInput()
786
+
787
+ results = (
788
+ await self.__control_api.list_agent_runtime_versions_async(
789
+ agent_runtime_id,
790
+ ListAgentRuntimeVersionsRequest().from_map(
791
+ input.model_dump()
792
+ ),
793
+ config=config,
794
+ )
795
+ )
796
+ return [
797
+ AgentRuntimeVersion.from_inner_object(item)
798
+ for item in results.items
799
+ ]
800
+ except HTTPError as e:
801
+ raise e.to_resource_error("AgentRuntime", agent_runtime_id) from e
802
+
803
+ def list_versions(
804
+ self,
805
+ agent_runtime_id: str,
806
+ input: Optional[AgentRuntimeVersionListInput] = None,
807
+ config: Optional[Config] = None,
808
+ ) -> List[AgentRuntimeVersion]:
809
+ """同步列出 Agent Runtime 版本 / List Agent Runtime Versions asynchronously
810
+
811
+ Args:
812
+ agent_runtime_id: Agent Runtime ID
813
+ input: 列表查询配置,可选 / List query configuration, optional
814
+ config: 配置对象,可选 / Configuration object, optional
815
+
816
+ Returns:
817
+ List[AgentRuntimeVersion]: 版本对象列表 / List of version objects
818
+
819
+ Raises:
820
+ HTTPError: HTTP 请求错误 / HTTP request error
821
+ """
822
+ try:
823
+ if input is None:
824
+ input = AgentRuntimeVersionListInput()
825
+
826
+ results = self.__control_api.list_agent_runtime_versions(
827
+ agent_runtime_id,
828
+ ListAgentRuntimeVersionsRequest().from_map(input.model_dump()),
829
+ config=config,
830
+ )
831
+ return [
832
+ AgentRuntimeVersion.from_inner_object(item)
833
+ for item in results.items
834
+ ]
835
+ except HTTPError as e:
836
+ raise e.to_resource_error("AgentRuntime", agent_runtime_id) from e
837
+
838
+ async def invoke_openai_async(
839
+ self,
840
+ agent_runtime_name: str,
841
+ agent_runtime_endpoint_name: str = "Default",
842
+ **kwargs: Unpack[InvokeArgs],
843
+ ):
844
+ cfg = Config.with_configs(self.config, kwargs.get("config"))
845
+ kwargs["config"] = cfg
846
+
847
+ data_api = AgentRuntimeDataAPI(
848
+ agent_runtime_name=agent_runtime_name,
849
+ agent_runtime_endpoint_name=agent_runtime_endpoint_name,
850
+ config=cfg,
851
+ )
852
+ return await data_api.invoke_openai_async(**kwargs)
853
+
854
+ def invoke_openai(
855
+ self,
856
+ agent_runtime_name: str,
857
+ agent_runtime_endpoint_name: str = "Default",
858
+ **kwargs: Unpack[InvokeArgs],
859
+ ):
860
+ cfg = Config.with_configs(self.config, kwargs.get("config"))
861
+ kwargs["config"] = cfg
862
+
863
+ data_api = AgentRuntimeDataAPI(
864
+ agent_runtime_name=agent_runtime_name,
865
+ agent_runtime_endpoint_name=agent_runtime_endpoint_name,
866
+ config=cfg,
867
+ )
868
+ return data_api.invoke_openai(**kwargs)