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,649 @@
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/__endpoint_async_template.py
10
+
11
+ Agent Runtime 端点资源 / Agent Runtime Endpoint Resource
12
+
13
+ 此模块定义 Agent Runtime 端点的高级API。
14
+ This module defines the high-level API for Agent Runtime Endpoint.
15
+ """
16
+
17
+ from typing import List, Optional
18
+
19
+ from typing_extensions import Self, Unpack
20
+
21
+ from agentrun.agent_runtime.api.data import AgentRuntimeDataAPI, InvokeArgs
22
+ from agentrun.agent_runtime.model import (
23
+ AgentRuntimeEndpointCreateInput,
24
+ AgentRuntimeEndpointImmutableProps,
25
+ AgentRuntimeEndpointListInput,
26
+ AgentRuntimeEndpointMutableProps,
27
+ AgentRuntimeEndpointSystemProps,
28
+ AgentRuntimeEndpointUpdateInput,
29
+ )
30
+ from agentrun.utils.config import Config
31
+ from agentrun.utils.resource import ResourceBase
32
+
33
+
34
+ class AgentRuntimeEndpoint(
35
+ AgentRuntimeEndpointMutableProps,
36
+ AgentRuntimeEndpointImmutableProps,
37
+ AgentRuntimeEndpointSystemProps,
38
+ ResourceBase,
39
+ ):
40
+ """智能体运行时端点信息 / Agent Runtime Endpoint Information
41
+
42
+ 提供端点的创建、删除、更新、查询功能。
43
+ Provides create, delete, update, and query functions for endpoints.
44
+ """
45
+
46
+ @classmethod
47
+ def __get_client(cls, config: Optional[Config] = None):
48
+ """获取客户端实例 / Get client instance
49
+
50
+ Returns:
51
+ AgentRuntimeClient: 客户端实例 / Client instance
52
+ """
53
+ from agentrun.agent_runtime.client import AgentRuntimeClient
54
+
55
+ return AgentRuntimeClient(config=config)
56
+
57
+ @classmethod
58
+ async def create_by_id_async(
59
+ cls,
60
+ agent_runtime_id: str,
61
+ input: AgentRuntimeEndpointCreateInput,
62
+ config: Optional[Config] = None,
63
+ ):
64
+ """根据 ID 异步创建端点 / Create endpoint by ID asynchronously
65
+
66
+ Args:
67
+ agent_runtime_id: Agent Runtime ID
68
+ input: 端点创建配置 / Endpoint creation configuration
69
+ config: 配置对象,可选 / Configuration object, optional
70
+
71
+ Returns:
72
+ AgentRuntimeEndpoint: 创建的端点对象 / Created endpoint object
73
+
74
+ Raises:
75
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
76
+ ResourceNotExistError: Agent Runtime 不存在 / Agent Runtime does not exist
77
+ HTTPError: HTTP 请求错误 / HTTP request error
78
+ """
79
+ cli = cls.__get_client()
80
+ return await cli.create_endpoint_async(
81
+ agent_runtime_id,
82
+ input,
83
+ config=config,
84
+ )
85
+
86
+ @classmethod
87
+ def create_by_id(
88
+ cls,
89
+ agent_runtime_id: str,
90
+ input: AgentRuntimeEndpointCreateInput,
91
+ config: Optional[Config] = None,
92
+ ):
93
+ """根据 ID 同步创建端点 / Create endpoint by ID asynchronously
94
+
95
+ Args:
96
+ agent_runtime_id: Agent Runtime ID
97
+ input: 端点创建配置 / Endpoint creation configuration
98
+ config: 配置对象,可选 / Configuration object, optional
99
+
100
+ Returns:
101
+ AgentRuntimeEndpoint: 创建的端点对象 / Created endpoint object
102
+
103
+ Raises:
104
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
105
+ ResourceNotExistError: Agent Runtime 不存在 / Agent Runtime does not exist
106
+ HTTPError: HTTP 请求错误 / HTTP request error
107
+ """
108
+ cli = cls.__get_client()
109
+ return cli.create_endpoint(
110
+ agent_runtime_id,
111
+ input,
112
+ config=config,
113
+ )
114
+
115
+ @classmethod
116
+ async def delete_by_id_async(
117
+ cls,
118
+ agent_runtime_id: str,
119
+ endpoint_id: str,
120
+ config: Optional[Config] = None,
121
+ ):
122
+ """根据 ID 异步删除端点 / Delete endpoint by ID asynchronously
123
+
124
+ Args:
125
+ agent_runtime_id: Agent Runtime ID
126
+ endpoint_id: 端点 ID / Endpoint ID
127
+ config: 配置对象,可选 / Configuration object, optional
128
+
129
+ Returns:
130
+ AgentRuntimeEndpoint: 删除的端点对象 / Deleted endpoint object
131
+
132
+ Raises:
133
+ ResourceNotExistError: 资源不存在 / Resource does not exist
134
+ HTTPError: HTTP 请求错误 / HTTP request error
135
+ """
136
+ cli = cls.__get_client()
137
+ return await cli.delete_endpoint_async(
138
+ agent_runtime_id,
139
+ endpoint_id,
140
+ config=config,
141
+ )
142
+
143
+ @classmethod
144
+ def delete_by_id(
145
+ cls,
146
+ agent_runtime_id: str,
147
+ endpoint_id: str,
148
+ config: Optional[Config] = None,
149
+ ):
150
+ """根据 ID 同步删除端点 / Delete endpoint by ID asynchronously
151
+
152
+ Args:
153
+ agent_runtime_id: Agent Runtime ID
154
+ endpoint_id: 端点 ID / Endpoint ID
155
+ config: 配置对象,可选 / Configuration object, optional
156
+
157
+ Returns:
158
+ AgentRuntimeEndpoint: 删除的端点对象 / Deleted endpoint object
159
+
160
+ Raises:
161
+ ResourceNotExistError: 资源不存在 / Resource does not exist
162
+ HTTPError: HTTP 请求错误 / HTTP request error
163
+ """
164
+ cli = cls.__get_client()
165
+ return cli.delete_endpoint(
166
+ agent_runtime_id,
167
+ endpoint_id,
168
+ config=config,
169
+ )
170
+
171
+ @classmethod
172
+ async def update_by_id_async(
173
+ cls,
174
+ agent_runtime_id: str,
175
+ endpoint_id: str,
176
+ input: AgentRuntimeEndpointUpdateInput,
177
+ config: Optional[Config] = None,
178
+ ):
179
+ """根据 ID 异步更新端点 / Update endpoint by ID asynchronously
180
+
181
+ Args:
182
+ agent_runtime_id: Agent Runtime ID
183
+ endpoint_id: 端点 ID / Endpoint ID
184
+ input: 端点更新配置 / Endpoint update configuration
185
+ config: 配置对象,可选 / Configuration object, optional
186
+
187
+ Returns:
188
+ AgentRuntimeEndpoint: 更新后的端点对象 / Updated endpoint object
189
+
190
+ Raises:
191
+ ResourceNotExistError: 资源不存在 / Resource does not exist
192
+ HTTPError: HTTP 请求错误 / HTTP request error
193
+ """
194
+ cli = cls.__get_client()
195
+ return await cli.update_endpoint_async(
196
+ agent_runtime_id,
197
+ endpoint_id,
198
+ input,
199
+ config=config,
200
+ )
201
+
202
+ @classmethod
203
+ def update_by_id(
204
+ cls,
205
+ agent_runtime_id: str,
206
+ endpoint_id: str,
207
+ input: AgentRuntimeEndpointUpdateInput,
208
+ config: Optional[Config] = None,
209
+ ):
210
+ """根据 ID 同步更新端点 / Update endpoint by ID asynchronously
211
+
212
+ Args:
213
+ agent_runtime_id: Agent Runtime ID
214
+ endpoint_id: 端点 ID / Endpoint ID
215
+ input: 端点更新配置 / Endpoint update configuration
216
+ config: 配置对象,可选 / Configuration object, optional
217
+
218
+ Returns:
219
+ AgentRuntimeEndpoint: 更新后的端点对象 / Updated endpoint object
220
+
221
+ Raises:
222
+ ResourceNotExistError: 资源不存在 / Resource does not exist
223
+ HTTPError: HTTP 请求错误 / HTTP request error
224
+ """
225
+ cli = cls.__get_client()
226
+ return cli.update_endpoint(
227
+ agent_runtime_id,
228
+ endpoint_id,
229
+ input,
230
+ config=config,
231
+ )
232
+
233
+ @classmethod
234
+ async def get_by_id_async(
235
+ cls,
236
+ agent_runtime_id: str,
237
+ endpoint_id: str,
238
+ config: Optional[Config] = None,
239
+ ):
240
+ """根据 ID 异步获取端点 / Get endpoint by ID asynchronously
241
+
242
+ Args:
243
+ agent_runtime_id: Agent Runtime ID
244
+ endpoint_id: 端点 ID / Endpoint ID
245
+ config: 配置对象,可选 / Configuration object, optional
246
+
247
+ Returns:
248
+ AgentRuntimeEndpoint: 端点对象 / Endpoint object
249
+
250
+ Raises:
251
+ ResourceNotExistError: 资源不存在 / Resource does not exist
252
+ HTTPError: HTTP 请求错误 / HTTP request error
253
+ """
254
+ cli = cls.__get_client()
255
+ return await cli.get_endpoint_async(
256
+ agent_runtime_id,
257
+ endpoint_id,
258
+ config=config,
259
+ )
260
+
261
+ @classmethod
262
+ def get_by_id(
263
+ cls,
264
+ agent_runtime_id: str,
265
+ endpoint_id: str,
266
+ config: Optional[Config] = None,
267
+ ):
268
+ """根据 ID 同步获取端点 / Get endpoint by ID asynchronously
269
+
270
+ Args:
271
+ agent_runtime_id: Agent Runtime ID
272
+ endpoint_id: 端点 ID / Endpoint ID
273
+ config: 配置对象,可选 / Configuration object, optional
274
+
275
+ Returns:
276
+ AgentRuntimeEndpoint: 端点对象 / Endpoint object
277
+
278
+ Raises:
279
+ ResourceNotExistError: 资源不存在 / Resource does not exist
280
+ HTTPError: HTTP 请求错误 / HTTP request error
281
+ """
282
+ cli = cls.__get_client()
283
+ return cli.get_endpoint(
284
+ agent_runtime_id,
285
+ endpoint_id,
286
+ config=config,
287
+ )
288
+
289
+ @classmethod
290
+ async def list_by_id_async(
291
+ cls, agent_runtime_id: str, config: Optional[Config] = None
292
+ ):
293
+ """根据 Agent Runtime ID 异步列出所有端点 / List all endpoints by Agent Runtime ID asynchronously
294
+
295
+ 此方法会自动分页获取所有端点并去重。
296
+ This method automatically paginates to get all endpoints and deduplicates them.
297
+
298
+ Args:
299
+ agent_runtime_id: Agent Runtime ID
300
+ config: 配置对象,可选 / Configuration object, optional
301
+
302
+ Returns:
303
+ List[AgentRuntimeEndpoint]: 端点对象列表 / List of endpoint objects
304
+
305
+ Raises:
306
+ HTTPError: HTTP 请求错误 / HTTP request error
307
+ """
308
+ cli = cls.__get_client()
309
+
310
+ endpoints: List[AgentRuntimeEndpoint] = []
311
+ page = 1
312
+ page_size = 50
313
+ while True:
314
+ result = await cli.list_endpoints_async(
315
+ agent_runtime_id,
316
+ AgentRuntimeEndpointListInput(
317
+ page_number=page,
318
+ page_size=page_size,
319
+ ),
320
+ config=config,
321
+ )
322
+ page += 1
323
+ endpoints.extend(result) # type: ignore
324
+ if len(result) < page_size:
325
+ break
326
+
327
+ endpoint_id_set = set()
328
+ results: List[AgentRuntimeEndpoint] = []
329
+ for endpoint in endpoints:
330
+ if endpoint.agent_runtime_endpoint_id not in endpoint_id_set:
331
+ endpoint_id_set.add(endpoint.agent_runtime_endpoint_id)
332
+ results.append(endpoint)
333
+
334
+ return results
335
+
336
+ @classmethod
337
+ def list_by_id(cls, agent_runtime_id: str, config: Optional[Config] = None):
338
+ """根据 Agent Runtime ID 同步列出所有端点 / List all endpoints by Agent Runtime ID asynchronously
339
+
340
+ 此方法会自动分页获取所有端点并去重。
341
+ This method automatically paginates to get all endpoints and deduplicates them.
342
+
343
+ Args:
344
+ agent_runtime_id: Agent Runtime ID
345
+ config: 配置对象,可选 / Configuration object, optional
346
+
347
+ Returns:
348
+ List[AgentRuntimeEndpoint]: 端点对象列表 / List of endpoint objects
349
+
350
+ Raises:
351
+ HTTPError: HTTP 请求错误 / HTTP request error
352
+ """
353
+ cli = cls.__get_client()
354
+
355
+ endpoints: List[AgentRuntimeEndpoint] = []
356
+ page = 1
357
+ page_size = 50
358
+ while True:
359
+ result = cli.list_endpoints(
360
+ agent_runtime_id,
361
+ AgentRuntimeEndpointListInput(
362
+ page_number=page,
363
+ page_size=page_size,
364
+ ),
365
+ config=config,
366
+ )
367
+ page += 1
368
+ endpoints.extend(result) # type: ignore
369
+ if len(result) < page_size:
370
+ break
371
+
372
+ endpoint_id_set = set()
373
+ results: List[AgentRuntimeEndpoint] = []
374
+ for endpoint in endpoints:
375
+ if endpoint.agent_runtime_endpoint_id not in endpoint_id_set:
376
+ endpoint_id_set.add(endpoint.agent_runtime_endpoint_id)
377
+ results.append(endpoint)
378
+
379
+ return results
380
+
381
+ async def delete_async(
382
+ self, config: Optional[Config] = None
383
+ ) -> "AgentRuntimeEndpoint":
384
+ """异步删除当前端点 / Delete current endpoint asynchronously
385
+
386
+ Args:
387
+ config: 配置对象,可选 / Configuration object, optional
388
+
389
+ Returns:
390
+ AgentRuntimeEndpoint: 删除后的端点对象(self) / Deleted endpoint object (self)
391
+
392
+ Raises:
393
+ ValueError: 当 agent_runtime_id 或 agent_runtime_endpoint_id 为空时 / When agent_runtime_id or agent_runtime_endpoint_id is None
394
+ ResourceNotExistError: 资源不存在 / Resource does not exist
395
+ HTTPError: HTTP 请求错误 / HTTP request error
396
+ """
397
+ if (
398
+ self.agent_runtime_id is None
399
+ or self.agent_runtime_endpoint_id is None
400
+ ):
401
+ raise ValueError(
402
+ "agent_runtime_id and agent_runtime_endpoint_id are required to"
403
+ " delete an Agent Runtime Endpoint"
404
+ )
405
+
406
+ result = await self.delete_by_id_async(
407
+ self.agent_runtime_id, self.agent_runtime_endpoint_id, config=config
408
+ )
409
+ self.update_self(result)
410
+ return self
411
+
412
+ def delete(self, config: Optional[Config] = None) -> "AgentRuntimeEndpoint":
413
+ """同步删除当前端点 / Delete current endpoint asynchronously
414
+
415
+ Args:
416
+ config: 配置对象,可选 / Configuration object, optional
417
+
418
+ Returns:
419
+ AgentRuntimeEndpoint: 删除后的端点对象(self) / Deleted endpoint object (self)
420
+
421
+ Raises:
422
+ ValueError: 当 agent_runtime_id 或 agent_runtime_endpoint_id 为空时 / When agent_runtime_id or agent_runtime_endpoint_id is None
423
+ ResourceNotExistError: 资源不存在 / Resource does not exist
424
+ HTTPError: HTTP 请求错误 / HTTP request error
425
+ """
426
+ if (
427
+ self.agent_runtime_id is None
428
+ or self.agent_runtime_endpoint_id is None
429
+ ):
430
+ raise ValueError(
431
+ "agent_runtime_id and agent_runtime_endpoint_id are required to"
432
+ " delete an Agent Runtime Endpoint"
433
+ )
434
+
435
+ result = self.delete_by_id(
436
+ self.agent_runtime_id, self.agent_runtime_endpoint_id, config=config
437
+ )
438
+ self.update_self(result)
439
+ return self
440
+
441
+ async def update_async(
442
+ self,
443
+ input: AgentRuntimeEndpointUpdateInput,
444
+ config: Optional[Config] = None,
445
+ ) -> Self:
446
+ """异步更新当前端点 / Update current endpoint asynchronously
447
+
448
+ Args:
449
+ input: 端点更新配置 / Endpoint update configuration
450
+ config: 配置对象,可选 / Configuration object, optional
451
+
452
+ Returns:
453
+ Self: 更新后的端点对象(self) / Updated endpoint object (self)
454
+
455
+ Raises:
456
+ ValueError: 当 agent_runtime_id 或 agent_runtime_endpoint_id 为空时 / When agent_runtime_id or agent_runtime_endpoint_id is None
457
+ ResourceNotExistError: 资源不存在 / Resource does not exist
458
+ HTTPError: HTTP 请求错误 / HTTP request error
459
+ """
460
+ if (
461
+ self.agent_runtime_id is None
462
+ or self.agent_runtime_endpoint_id is None
463
+ ):
464
+ raise ValueError(
465
+ "agent_runtime_id and agent_runtime_endpoint_id are required to"
466
+ " update an Agent Runtime Endpoint"
467
+ )
468
+
469
+ result = await self.update_by_id_async(
470
+ self.agent_runtime_id,
471
+ self.agent_runtime_endpoint_id,
472
+ input=input,
473
+ config=config,
474
+ )
475
+ self.update_self(result)
476
+ return self
477
+
478
+ def update(
479
+ self,
480
+ input: AgentRuntimeEndpointUpdateInput,
481
+ config: Optional[Config] = None,
482
+ ) -> Self:
483
+ """同步更新当前端点 / Update current endpoint asynchronously
484
+
485
+ Args:
486
+ input: 端点更新配置 / Endpoint update configuration
487
+ config: 配置对象,可选 / Configuration object, optional
488
+
489
+ Returns:
490
+ Self: 更新后的端点对象(self) / Updated endpoint object (self)
491
+
492
+ Raises:
493
+ ValueError: 当 agent_runtime_id 或 agent_runtime_endpoint_id 为空时 / When agent_runtime_id or agent_runtime_endpoint_id is None
494
+ ResourceNotExistError: 资源不存在 / Resource does not exist
495
+ HTTPError: HTTP 请求错误 / HTTP request error
496
+ """
497
+ if (
498
+ self.agent_runtime_id is None
499
+ or self.agent_runtime_endpoint_id is None
500
+ ):
501
+ raise ValueError(
502
+ "agent_runtime_id and agent_runtime_endpoint_id are required to"
503
+ " update an Agent Runtime Endpoint"
504
+ )
505
+
506
+ result = self.update_by_id(
507
+ self.agent_runtime_id,
508
+ self.agent_runtime_endpoint_id,
509
+ input=input,
510
+ config=config,
511
+ )
512
+ self.update_self(result)
513
+ return self
514
+
515
+ async def get_async(self, config: Optional[Config] = None):
516
+ """异步获取当前端点信息 / Get current endpoint information asynchronously
517
+
518
+ Args:
519
+ config: 配置对象,可选 / Configuration object, optional
520
+
521
+ Returns:
522
+ AgentRuntimeEndpoint: 获取后的端点对象(self) / Retrieved endpoint object (self)
523
+
524
+ Raises:
525
+ ValueError: 当 agent_runtime_id 或 agent_runtime_endpoint_id 为空时 / When agent_runtime_id or agent_runtime_endpoint_id is None
526
+ ResourceNotExistError: 资源不存在 / Resource does not exist
527
+ HTTPError: HTTP 请求错误 / HTTP request error
528
+ """
529
+ if (
530
+ self.agent_runtime_id is None
531
+ or self.agent_runtime_endpoint_id is None
532
+ ):
533
+ raise ValueError(
534
+ "agent_runtime_id and agent_runtime_endpoint_id are required to"
535
+ " get an Agent Runtime Endpoint"
536
+ )
537
+
538
+ result = await self.get_by_id_async(
539
+ self.agent_runtime_id, self.agent_runtime_endpoint_id
540
+ )
541
+ self.update_self(result)
542
+ return self
543
+
544
+ def get(self, config: Optional[Config] = None):
545
+ """同步获取当前端点信息 / Get current endpoint information asynchronously
546
+
547
+ Args:
548
+ config: 配置对象,可选 / Configuration object, optional
549
+
550
+ Returns:
551
+ AgentRuntimeEndpoint: 获取后的端点对象(self) / Retrieved endpoint object (self)
552
+
553
+ Raises:
554
+ ValueError: 当 agent_runtime_id 或 agent_runtime_endpoint_id 为空时 / When agent_runtime_id or agent_runtime_endpoint_id is None
555
+ ResourceNotExistError: 资源不存在 / Resource does not exist
556
+ HTTPError: HTTP 请求错误 / HTTP request error
557
+ """
558
+ if (
559
+ self.agent_runtime_id is None
560
+ or self.agent_runtime_endpoint_id is None
561
+ ):
562
+ raise ValueError(
563
+ "agent_runtime_id and agent_runtime_endpoint_id are required to"
564
+ " get an Agent Runtime Endpoint"
565
+ )
566
+
567
+ result = self.get_by_id(
568
+ self.agent_runtime_id, self.agent_runtime_endpoint_id
569
+ )
570
+ self.update_self(result)
571
+ return self
572
+
573
+ async def refresh_async(self, config: Optional[Config] = None):
574
+ """刷新当前端点信息 / Refresh current endpoint information
575
+
576
+ 这是 get_async 的别名方法。
577
+ This is an alias method for get_async.
578
+
579
+ Args:
580
+ config: 配置对象,可选 / Configuration object, optional
581
+
582
+ Returns:
583
+ AgentRuntimeEndpoint: 刷新后的端点对象(self) / Refreshed endpoint object (self)
584
+
585
+ Raises:
586
+ ValueError: 当 agent_runtime_id 或 agent_runtime_endpoint_id 为空时 / When agent_runtime_id or agent_runtime_endpoint_id is None
587
+ ResourceNotExistError: 资源不存在 / Resource does not exist
588
+ HTTPError: HTTP 请求错误 / HTTP request error
589
+ """
590
+ return await self.get_async(config=config)
591
+
592
+ def refresh(self, config: Optional[Config] = None):
593
+ """刷新当前端点信息 / Refresh current endpoint information
594
+
595
+ 这是 get 的别名方法。
596
+ This is an alias method for get.
597
+
598
+ Args:
599
+ config: 配置对象,可选 / Configuration object, optional
600
+
601
+ Returns:
602
+ AgentRuntimeEndpoint: 刷新后的端点对象(self) / Refreshed endpoint object (self)
603
+
604
+ Raises:
605
+ ValueError: 当 agent_runtime_id 或 agent_runtime_endpoint_id 为空时 / When agent_runtime_id or agent_runtime_endpoint_id is None
606
+ ResourceNotExistError: 资源不存在 / Resource does not exist
607
+ HTTPError: HTTP 请求错误 / HTTP request error
608
+ """
609
+ return self.get(config=config)
610
+
611
+ async def invoke_openai_async(self, **kwargs: Unpack[InvokeArgs]):
612
+ cfg = Config.with_configs(self._config, kwargs.get("config"))
613
+ kwargs["config"] = cfg
614
+
615
+ if self.__data_api is None:
616
+ if not self.__agent_runtime_name:
617
+ client = self.__get_client(cfg)
618
+ ar = await client.get_async(
619
+ id=self.agent_runtime_id or "", config=cfg
620
+ )
621
+ self.__agent_runtime_name = ar.agent_runtime_name
622
+
623
+ self.__data_api = AgentRuntimeDataAPI(
624
+ agent_runtime_name=self.__agent_runtime_name or "",
625
+ agent_runtime_endpoint_name=self.agent_runtime_endpoint_name
626
+ or "",
627
+ config=cfg,
628
+ )
629
+
630
+ return await self.__data_api.invoke_openai_async(**kwargs)
631
+
632
+ def invoke_openai(self, **kwargs: Unpack[InvokeArgs]):
633
+ cfg = Config.with_configs(self._config, kwargs.get("config"))
634
+ kwargs["config"] = cfg
635
+
636
+ if self.__data_api is None:
637
+ if not self.__agent_runtime_name:
638
+ client = self.__get_client(cfg)
639
+ ar = client.get(id=self.agent_runtime_id or "", config=cfg)
640
+ self.__agent_runtime_name = ar.agent_runtime_name
641
+
642
+ self.__data_api = AgentRuntimeDataAPI(
643
+ agent_runtime_name=self.__agent_runtime_name or "",
644
+ agent_runtime_endpoint_name=self.agent_runtime_endpoint_name
645
+ or "",
646
+ config=cfg,
647
+ )
648
+
649
+ return self.__data_api.invoke_openai(**kwargs)