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,162 @@
1
+ """MemoryCollection 模型定义 / MemoryCollection Model Definitions
2
+
3
+ 定义记忆集合相关的数据模型和枚举。
4
+ Defines data models and enumerations related to memory collections.
5
+ """
6
+
7
+ from typing import List, Optional
8
+
9
+ from agentrun.utils.config import Config
10
+ from agentrun.utils.model import BaseModel, PageableInput
11
+
12
+
13
+ class EmbedderConfigConfig(BaseModel):
14
+ """嵌入模型内部配置 / Embedder Inner Configuration"""
15
+
16
+ model: Optional[str] = None
17
+ """模型名称"""
18
+
19
+
20
+ class EmbedderConfig(BaseModel):
21
+ """嵌入模型配置 / Embedder Configuration"""
22
+
23
+ config: Optional[EmbedderConfigConfig] = None
24
+ """配置"""
25
+ model_service_name: Optional[str] = None
26
+ """模型服务名称"""
27
+
28
+
29
+ class LLMConfigConfig(BaseModel):
30
+ """LLM 内部配置 / LLM Inner Configuration"""
31
+
32
+ model: Optional[str] = None
33
+ """模型名称"""
34
+
35
+
36
+ class LLMConfig(BaseModel):
37
+ """LLM 配置 / LLM Configuration"""
38
+
39
+ config: Optional[LLMConfigConfig] = None
40
+ """配置"""
41
+ model_service_name: Optional[str] = None
42
+ """模型服务名称"""
43
+
44
+
45
+ class NetworkConfiguration(BaseModel):
46
+ """网络配置 / Network Configuration"""
47
+
48
+ vpc_id: Optional[str] = None
49
+ """VPC ID"""
50
+ vswitch_ids: Optional[List[str]] = None
51
+ """交换机 ID 列表"""
52
+ security_group_id: Optional[str] = None
53
+ """安全组 ID"""
54
+ network_mode: Optional[str] = None
55
+ """网络模式"""
56
+
57
+
58
+ class VectorStoreConfigConfig(BaseModel):
59
+ """向量存储内部配置 / Vector Store Inner Configuration"""
60
+
61
+ endpoint: Optional[str] = None
62
+ """端点"""
63
+ instance_name: Optional[str] = None
64
+ """实例名称"""
65
+ collection_name: Optional[str] = None
66
+ """集合名称"""
67
+ vector_dimension: Optional[int] = None
68
+ """向量维度"""
69
+
70
+
71
+ class VectorStoreConfig(BaseModel):
72
+ """向量存储配置 / Vector Store Configuration"""
73
+
74
+ provider: Optional[str] = None
75
+ """提供商"""
76
+ config: Optional[VectorStoreConfigConfig] = None
77
+ """配置"""
78
+
79
+
80
+ class MemoryCollectionMutableProps(BaseModel):
81
+ """MemoryCollection 可变属性"""
82
+
83
+ description: Optional[str] = None
84
+ """描述"""
85
+ embedder_config: Optional[EmbedderConfig] = None
86
+ """嵌入模型配置"""
87
+ execution_role_arn: Optional[str] = None
88
+ """执行角色 ARN"""
89
+ llm_config: Optional[LLMConfig] = None
90
+ """LLM 配置"""
91
+ network_configuration: Optional[NetworkConfiguration] = None
92
+ """网络配置"""
93
+ vector_store_config: Optional[VectorStoreConfig] = None
94
+ """向量存储配置"""
95
+
96
+
97
+ class MemoryCollectionImmutableProps(BaseModel):
98
+ """MemoryCollection 不可变属性"""
99
+
100
+ memory_collection_name: Optional[str] = None
101
+ """Memory Collection 名称"""
102
+ type: Optional[str] = None
103
+ """类型"""
104
+
105
+
106
+ class MemoryCollectionSystemProps(BaseModel):
107
+ """MemoryCollection 系统属性"""
108
+
109
+ memory_collection_id: Optional[str] = None
110
+ """Memory Collection ID"""
111
+ created_at: Optional[str] = None
112
+ """创建时间"""
113
+ last_updated_at: Optional[str] = None
114
+ """最后更新时间"""
115
+
116
+
117
+ class MemoryCollectionCreateInput(
118
+ MemoryCollectionImmutableProps, MemoryCollectionMutableProps
119
+ ):
120
+ """MemoryCollection 创建输入参数"""
121
+
122
+ pass
123
+
124
+
125
+ class MemoryCollectionUpdateInput(MemoryCollectionMutableProps):
126
+ """MemoryCollection 更新输入参数"""
127
+
128
+ pass
129
+
130
+
131
+ class MemoryCollectionListInput(PageableInput):
132
+ """MemoryCollection 列表查询输入参数"""
133
+
134
+ memory_collection_name: Optional[str] = None
135
+ """Memory Collection 名称"""
136
+
137
+
138
+ class MemoryCollectionListOutput(BaseModel):
139
+ """MemoryCollection 列表输出"""
140
+
141
+ memory_collection_id: Optional[str] = None
142
+ memory_collection_name: Optional[str] = None
143
+ description: Optional[str] = None
144
+ type: Optional[str] = None
145
+ created_at: Optional[str] = None
146
+ last_updated_at: Optional[str] = None
147
+
148
+ async def to_memory_collection_async(self, config: Optional[Config] = None):
149
+ """转换为完整的 MemoryCollection 对象(异步)"""
150
+ from .client import MemoryCollectionClient
151
+
152
+ return await MemoryCollectionClient(config).get_async(
153
+ self.memory_collection_name or "", config=config
154
+ )
155
+
156
+ def to_memory_collection(self, config: Optional[Config] = None):
157
+ """转换为完整的 MemoryCollection 对象"""
158
+ from .client import MemoryCollectionClient
159
+
160
+ return MemoryCollectionClient(config).get(
161
+ self.memory_collection_name or "", config=config
162
+ )
@@ -0,0 +1,357 @@
1
+ """Model Service 客户端 / Model Service Client
2
+
3
+ 此模块提供模型服务和模型代理的客户端API。
4
+ This module provides the client API for model services and model proxies.
5
+ """
6
+
7
+ from typing import List, Literal, Optional, overload, Union
8
+
9
+ from alibabacloud_agentrun20250910.models import (
10
+ CreateModelProxyInput,
11
+ CreateModelServiceInput,
12
+ ListModelProxiesRequest,
13
+ ListModelServicesRequest,
14
+ UpdateModelProxyInput,
15
+ UpdateModelServiceInput,
16
+ )
17
+ import pydash
18
+
19
+ from agentrun.utils.config import Config
20
+ from agentrun.utils.exception import HTTPError
21
+
22
+ from .api.control import ModelControlAPI
23
+ from .model import (
24
+ BackendType,
25
+ ModelProxyCreateInput,
26
+ ModelProxyListInput,
27
+ ModelProxyUpdateInput,
28
+ ModelServiceCreateInput,
29
+ ModelServiceListInput,
30
+ ModelServiceUpdateInput,
31
+ ProxyMode,
32
+ )
33
+ from .model_proxy import ModelProxy
34
+ from .model_service import ModelService
35
+
36
+
37
+ class ModelClient:
38
+ """Model Service 客户端 / Model Service Client
39
+
40
+ 提供模型服务和模型代理的创建、删除、更新和查询功能。
41
+ Provides create, delete, update and query functions for model services and model proxies.
42
+ """
43
+
44
+ def __init__(self, config: Optional[Config] = None):
45
+ """初始化客户端 / Initialize client
46
+
47
+ Args:
48
+ config: 配置对象,可选 / Configuration object, optional
49
+ """
50
+ self.__control_api = ModelControlAPI(config)
51
+
52
+ @overload
53
+ async def create_async(
54
+ self, input: ModelServiceCreateInput, config: Optional[Config] = None
55
+ ) -> ModelService:
56
+ ...
57
+
58
+ @overload
59
+ async def create_async(
60
+ self, input: ModelProxyCreateInput, config: Optional[Config] = None
61
+ ) -> ModelProxy:
62
+ ...
63
+
64
+ async def create_async(
65
+ self,
66
+ input: Union[ModelServiceCreateInput, ModelProxyCreateInput],
67
+ config: Optional[Config] = None,
68
+ ):
69
+ """创建模型服务(异步)
70
+
71
+ Args:
72
+ input: 模型服务输入参数
73
+ config: 配置
74
+
75
+ Returns:
76
+ model: 创建的对象
77
+ """
78
+ try:
79
+ if isinstance(input, ModelProxyCreateInput):
80
+ if not input.proxy_mode:
81
+ input.proxy_mode = (
82
+ ProxyMode.MULTI
83
+ if len(pydash.get(input, "proxy_config.endpoints", []))
84
+ > 1
85
+ else ProxyMode.SINGLE
86
+ )
87
+
88
+ result = await self.__control_api.create_model_proxy_async(
89
+ CreateModelProxyInput().from_map(input.model_dump()),
90
+ config=config,
91
+ )
92
+ return ModelProxy.from_inner_object(result)
93
+ else:
94
+ result = await self.__control_api.create_model_service_async(
95
+ CreateModelServiceInput().from_map(input.model_dump()),
96
+ config=config,
97
+ )
98
+ return ModelService.from_inner_object(result)
99
+ except HTTPError as e:
100
+ raise e.to_resource_error(
101
+ "Model",
102
+ (
103
+ input.model_proxy_name
104
+ if isinstance(input, ModelProxyCreateInput)
105
+ else input.model_service_name
106
+ ),
107
+ ) from e
108
+
109
+ @overload
110
+ async def delete_async(
111
+ self,
112
+ name: str,
113
+ backend_type: Literal[BackendType.PROXY],
114
+ config: Optional[Config] = None,
115
+ ) -> ModelProxy:
116
+ ...
117
+
118
+ @overload
119
+ async def delete_async(
120
+ self,
121
+ name: str,
122
+ backend_type: Literal[BackendType.SERVICE],
123
+ config: Optional[Config] = None,
124
+ ) -> ModelService:
125
+ ...
126
+
127
+ @overload
128
+ async def delete_async(
129
+ self,
130
+ name: str,
131
+ backend_type: None = None,
132
+ config: Optional[Config] = None,
133
+ ) -> Union[ModelProxy, ModelService]:
134
+ ...
135
+
136
+ async def delete_async(
137
+ self,
138
+ name: str,
139
+ backend_type: Optional[BackendType] = None,
140
+ config: Optional[Config] = None,
141
+ ):
142
+ """删除模型服务(异步)
143
+
144
+ Args:
145
+ model_service_name: 模型服务名称
146
+ config: 配置
147
+
148
+ Raises:
149
+ ResourceNotExistError: 模型服务不存在
150
+ """
151
+
152
+ error: Optional[HTTPError] = None
153
+ if backend_type == BackendType.PROXY or backend_type is None:
154
+ try:
155
+ result = await self.__control_api.delete_model_proxy_async(
156
+ model_proxy_name=name, config=config
157
+ )
158
+ return ModelProxy.from_inner_object(result)
159
+ except HTTPError as e:
160
+ error = e
161
+
162
+ if backend_type == BackendType.PROXY and error is not None:
163
+ raise error.to_resource_error("Model", name) from error
164
+
165
+ try:
166
+ result = await self.__control_api.delete_model_service_async(
167
+ model_service_name=name, config=config
168
+ )
169
+ return ModelService.from_inner_object(result)
170
+ except HTTPError as e:
171
+ raise e.to_resource_error("Model", name) from error
172
+
173
+ @overload
174
+ async def update_async(
175
+ self,
176
+ name: str,
177
+ input: ModelServiceUpdateInput,
178
+ config: Optional[Config] = None,
179
+ ) -> ModelService:
180
+ ...
181
+
182
+ @overload
183
+ async def update_async(
184
+ self,
185
+ name: str,
186
+ input: ModelProxyUpdateInput,
187
+ config: Optional[Config] = None,
188
+ ) -> ModelProxy:
189
+ ...
190
+
191
+ async def update_async(
192
+ self,
193
+ name: str,
194
+ input: Union[ModelServiceUpdateInput, ModelProxyUpdateInput],
195
+ config: Optional[Config] = None,
196
+ ):
197
+ """更新模型服务(异步)
198
+
199
+ Args:
200
+ model_service_name: 模型服务名称
201
+ input: 模型服务更新输入参数
202
+ config: 配置
203
+
204
+ Returns:
205
+ ModelService: 更新后的模型服务对象
206
+
207
+ Raises:
208
+ ResourceNotExistError: 模型服务不存在
209
+ """
210
+
211
+ if isinstance(input, ModelProxyUpdateInput):
212
+ try:
213
+ if not input.proxy_mode:
214
+ input.proxy_mode = (
215
+ ProxyMode.MULTI
216
+ if len(pydash.get(input, "proxy_config.endpoints", []))
217
+ > 1
218
+ else ProxyMode.SINGLE
219
+ )
220
+ result = await self.__control_api.update_model_proxy_async(
221
+ model_proxy_name=name,
222
+ input=UpdateModelProxyInput().from_map(input.model_dump()),
223
+ config=config,
224
+ )
225
+ return ModelProxy.from_inner_object(result)
226
+ except HTTPError as e:
227
+ raise e.to_resource_error("Model", name) from e
228
+
229
+ else:
230
+ try:
231
+ result = await self.__control_api.update_model_service_async(
232
+ model_service_name=name,
233
+ input=UpdateModelServiceInput().from_map(
234
+ input.model_dump()
235
+ ),
236
+ config=config,
237
+ )
238
+ return ModelService.from_inner_object(result)
239
+ except HTTPError as e:
240
+ raise e.to_resource_error("Model", name) from e
241
+
242
+ @overload
243
+ async def get_async(
244
+ self,
245
+ name: str,
246
+ backend_type: Literal[BackendType.SERVICE],
247
+ config: Optional[Config] = None,
248
+ ) -> ModelService:
249
+ ...
250
+
251
+ @overload
252
+ async def get_async(
253
+ self,
254
+ name: str,
255
+ backend_type: Literal[BackendType.PROXY],
256
+ config: Optional[Config] = None,
257
+ ) -> ModelProxy:
258
+ ...
259
+
260
+ @overload
261
+ async def get_async(
262
+ self,
263
+ name: str,
264
+ backend_type: None = None,
265
+ config: Optional[Config] = None,
266
+ ) -> Union[ModelService, ModelProxy]:
267
+ ...
268
+
269
+ async def get_async(
270
+ self,
271
+ name: str,
272
+ backend_type: Optional[BackendType] = None,
273
+ config: Optional[Config] = None,
274
+ ):
275
+ """获取模型服务(异步)
276
+
277
+ Args:
278
+ model_service_name: 模型服务名称
279
+ config: 配置
280
+
281
+ Returns:
282
+ ModelService: 模型服务对象
283
+
284
+ Raises:
285
+ ResourceNotExistError: 模型服务不存在
286
+ """
287
+
288
+ error: Optional[HTTPError] = None
289
+ if backend_type == BackendType.PROXY or backend_type is None:
290
+ try:
291
+ result = await self.__control_api.get_model_proxy_async(
292
+ model_proxy_name=name, config=config
293
+ )
294
+ return ModelProxy.from_inner_object(result)
295
+ except HTTPError as e:
296
+ error = e
297
+
298
+ if backend_type == BackendType.PROXY and error is not None:
299
+ raise error.to_resource_error("Model", name) from error
300
+
301
+ try:
302
+ result = await self.__control_api.get_model_service_async(
303
+ model_service_name=name, config=config
304
+ )
305
+ return ModelService.from_inner_object(result)
306
+ except HTTPError as e:
307
+ raise e.to_resource_error("Model", name) from e
308
+
309
+ @overload
310
+ async def list_async(
311
+ self,
312
+ input: ModelProxyListInput,
313
+ config: Optional[Config] = None,
314
+ ) -> List[ModelProxy]:
315
+ ...
316
+
317
+ @overload
318
+ async def list_async(
319
+ self,
320
+ input: ModelServiceListInput,
321
+ config: Optional[Config] = None,
322
+ ) -> List[ModelService]:
323
+ ...
324
+
325
+ async def list_async(
326
+ self,
327
+ input: Union[ModelServiceListInput, ModelProxyListInput],
328
+ config: Optional[Config] = None,
329
+ ):
330
+ """列出模型服务(异步)
331
+
332
+ Args:
333
+ input: 分页查询参数
334
+ config: 配置
335
+
336
+ Returns:
337
+ List[ModelService]: 模型服务列表
338
+ """
339
+
340
+ if isinstance(input, ModelProxyListInput):
341
+ result = await self.__control_api.list_model_proxies_async(
342
+ ListModelProxiesRequest().from_map(input.model_dump()),
343
+ config=config,
344
+ )
345
+ return [
346
+ ModelProxy.from_inner_object(item)
347
+ for item in result.items or []
348
+ ]
349
+ else:
350
+ result = await self.__control_api.list_model_services_async(
351
+ ListModelServicesRequest().from_map(input.model_dump()),
352
+ config=config,
353
+ )
354
+ return [
355
+ ModelService.from_inner_object(item)
356
+ for item in result.items or []
357
+ ]
@@ -0,0 +1,57 @@
1
+ """Model Service 模块 / Model Service Module"""
2
+
3
+ from .api import ModelCompletionAPI, ModelControlAPI, ModelDataAPI
4
+ from .client import ModelClient
5
+ from .model import (
6
+ BackendType,
7
+ ModelFeatures,
8
+ ModelInfoConfig,
9
+ ModelParameterRule,
10
+ ModelProperties,
11
+ ModelProxyCreateInput,
12
+ ModelProxyListInput,
13
+ ModelProxyUpdateInput,
14
+ ModelServiceCreateInput,
15
+ ModelServiceListInput,
16
+ ModelServiceUpdateInput,
17
+ ModelType,
18
+ Provider,
19
+ ProviderSettings,
20
+ ProxyConfig,
21
+ ProxyConfigEndpoint,
22
+ ProxyConfigFallback,
23
+ ProxyConfigPolicies,
24
+ )
25
+ from .model_proxy import ModelProxy
26
+ from .model_service import ModelService
27
+
28
+ __all__ = [
29
+ # base
30
+ "ModelClient",
31
+ "ModelService",
32
+ "ModelProxy",
33
+ "ModelControlAPI",
34
+ "ModelCompletionAPI",
35
+ "ModelDataAPI",
36
+ # enum
37
+ "BackendType",
38
+ "ModelType",
39
+ "Provider",
40
+ # inner model
41
+ "ProviderSettings",
42
+ "ModelFeatures",
43
+ "ModelProperties",
44
+ "ModelParameterRule",
45
+ "ModelInfoConfig",
46
+ "ProxyConfigEndpoint",
47
+ "ProxyConfigFallback",
48
+ "ProxyConfigPolicies",
49
+ "ProxyConfig",
50
+ # api model
51
+ "ModelServiceCreateInput",
52
+ "ModelServiceUpdateInput",
53
+ "ModelServiceListInput",
54
+ "ModelProxyCreateInput",
55
+ "ModelProxyUpdateInput",
56
+ "ModelProxyListInput",
57
+ ]