agentrun-inner-test 0.0.56__py3-none-any.whl → 0.0.64__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.
@@ -0,0 +1,323 @@
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/memory_collection/__client_async_template.py
10
+
11
+ MemoryCollection 客户端 / MemoryCollection Client
12
+
13
+ 此模块提供记忆集合管理的客户端API。
14
+ This module provides the client API for memory collection management.
15
+ """
16
+
17
+ from typing import Optional
18
+
19
+ from alibabacloud_agentrun20250910.models import (
20
+ CreateMemoryCollectionInput,
21
+ ListMemoryCollectionsRequest,
22
+ UpdateMemoryCollectionInput,
23
+ )
24
+
25
+ from agentrun.utils.config import Config
26
+ from agentrun.utils.exception import HTTPError
27
+
28
+ from .api.control import MemoryCollectionControlAPI
29
+ from .memory_collection import MemoryCollection
30
+ from .model import (
31
+ MemoryCollectionCreateInput,
32
+ MemoryCollectionListInput,
33
+ MemoryCollectionListOutput,
34
+ MemoryCollectionUpdateInput,
35
+ )
36
+
37
+
38
+ class MemoryCollectionClient:
39
+ """MemoryCollection 客户端 / MemoryCollection Client
40
+
41
+ 提供记忆集合的创建、删除、更新和查询功能。
42
+ Provides create, delete, update and query functions for memory collections.
43
+ """
44
+
45
+ def __init__(self, config: Optional[Config] = None):
46
+ """初始化客户端 / Initialize client
47
+
48
+ Args:
49
+ config: 配置对象,可选 / Configuration object, optional
50
+ """
51
+ self.__control_api = MemoryCollectionControlAPI(config)
52
+
53
+ async def create_async(
54
+ self,
55
+ input: MemoryCollectionCreateInput,
56
+ config: Optional[Config] = None,
57
+ ):
58
+ """创建记忆集合(异步) / Create memory collection asynchronously
59
+
60
+ Args:
61
+ input: 记忆集合输入参数 / Memory collection input parameters
62
+ config: 配置对象,可选 / Configuration object, optional
63
+
64
+ Returns:
65
+ MemoryCollection: 创建的记忆集合对象 / Created memory collection object
66
+
67
+ Raises:
68
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
69
+ HTTPError: HTTP 请求错误 / HTTP request error
70
+ """
71
+ try:
72
+ result = await self.__control_api.create_memory_collection_async(
73
+ CreateMemoryCollectionInput().from_map(input.model_dump()),
74
+ config=config,
75
+ )
76
+
77
+ return MemoryCollection.from_inner_object(result)
78
+ except HTTPError as e:
79
+ raise e.to_resource_error(
80
+ "MemoryCollection", input.memory_collection_name
81
+ ) from e
82
+
83
+ def create(
84
+ self,
85
+ input: MemoryCollectionCreateInput,
86
+ config: Optional[Config] = None,
87
+ ):
88
+ """创建记忆集合(同步) / Create memory collection synchronously
89
+
90
+ Args:
91
+ input: 记忆集合输入参数 / Memory collection input parameters
92
+ config: 配置对象,可选 / Configuration object, optional
93
+
94
+ Returns:
95
+ MemoryCollection: 创建的记忆集合对象 / Created memory collection object
96
+
97
+ Raises:
98
+ ResourceAlreadyExistError: 资源已存在 / Resource already exists
99
+ HTTPError: HTTP 请求错误 / HTTP request error
100
+ """
101
+ try:
102
+ result = self.__control_api.create_memory_collection(
103
+ CreateMemoryCollectionInput().from_map(input.model_dump()),
104
+ config=config,
105
+ )
106
+
107
+ return MemoryCollection.from_inner_object(result)
108
+ except HTTPError as e:
109
+ raise e.to_resource_error(
110
+ "MemoryCollection", input.memory_collection_name
111
+ ) from e
112
+
113
+ async def delete_async(
114
+ self, memory_collection_name: str, config: Optional[Config] = None
115
+ ):
116
+ """删除记忆集合(异步)
117
+
118
+ Args:
119
+ memory_collection_name: 记忆集合名称
120
+ config: 配置
121
+
122
+ Raises:
123
+ ResourceNotExistError: 记忆集合不存在
124
+ """
125
+ try:
126
+ result = await self.__control_api.delete_memory_collection_async(
127
+ memory_collection_name, config=config
128
+ )
129
+
130
+ return MemoryCollection.from_inner_object(result)
131
+
132
+ except HTTPError as e:
133
+ raise e.to_resource_error(
134
+ "MemoryCollection", memory_collection_name
135
+ ) from e
136
+
137
+ def delete(
138
+ self, memory_collection_name: str, config: Optional[Config] = None
139
+ ):
140
+ """删除记忆集合(同步)
141
+
142
+ Args:
143
+ memory_collection_name: 记忆集合名称
144
+ config: 配置
145
+
146
+ Raises:
147
+ ResourceNotExistError: 记忆集合不存在
148
+ """
149
+ try:
150
+ result = self.__control_api.delete_memory_collection(
151
+ memory_collection_name, config=config
152
+ )
153
+
154
+ return MemoryCollection.from_inner_object(result)
155
+
156
+ except HTTPError as e:
157
+ raise e.to_resource_error(
158
+ "MemoryCollection", memory_collection_name
159
+ ) from e
160
+
161
+ async def update_async(
162
+ self,
163
+ memory_collection_name: str,
164
+ input: MemoryCollectionUpdateInput,
165
+ config: Optional[Config] = None,
166
+ ):
167
+ """更新记忆集合(异步)
168
+
169
+ Args:
170
+ memory_collection_name: 记忆集合名称
171
+ input: 记忆集合更新输入参数
172
+ config: 配置
173
+
174
+ Returns:
175
+ MemoryCollection: 更新后的记忆集合对象
176
+
177
+ Raises:
178
+ ResourceNotExistError: 记忆集合不存在
179
+ """
180
+ try:
181
+ result = await self.__control_api.update_memory_collection_async(
182
+ memory_collection_name,
183
+ UpdateMemoryCollectionInput().from_map(input.model_dump()),
184
+ config=config,
185
+ )
186
+
187
+ return MemoryCollection.from_inner_object(result)
188
+ except HTTPError as e:
189
+ raise e.to_resource_error(
190
+ "MemoryCollection", memory_collection_name
191
+ ) from e
192
+
193
+ def update(
194
+ self,
195
+ memory_collection_name: str,
196
+ input: MemoryCollectionUpdateInput,
197
+ config: Optional[Config] = None,
198
+ ):
199
+ """更新记忆集合(同步)
200
+
201
+ Args:
202
+ memory_collection_name: 记忆集合名称
203
+ input: 记忆集合更新输入参数
204
+ config: 配置
205
+
206
+ Returns:
207
+ MemoryCollection: 更新后的记忆集合对象
208
+
209
+ Raises:
210
+ ResourceNotExistError: 记忆集合不存在
211
+ """
212
+ try:
213
+ result = self.__control_api.update_memory_collection(
214
+ memory_collection_name,
215
+ UpdateMemoryCollectionInput().from_map(input.model_dump()),
216
+ config=config,
217
+ )
218
+
219
+ return MemoryCollection.from_inner_object(result)
220
+ except HTTPError as e:
221
+ raise e.to_resource_error(
222
+ "MemoryCollection", memory_collection_name
223
+ ) from e
224
+
225
+ async def get_async(
226
+ self, memory_collection_name: str, config: Optional[Config] = None
227
+ ):
228
+ """获取记忆集合(异步)
229
+
230
+ Args:
231
+ memory_collection_name: 记忆集合名称
232
+ config: 配置
233
+
234
+ Returns:
235
+ MemoryCollection: 记忆集合对象
236
+
237
+ Raises:
238
+ ResourceNotExistError: 记忆集合不存在
239
+ """
240
+ try:
241
+ result = await self.__control_api.get_memory_collection_async(
242
+ memory_collection_name, config=config
243
+ )
244
+ return MemoryCollection.from_inner_object(result)
245
+ except HTTPError as e:
246
+ raise e.to_resource_error(
247
+ "MemoryCollection", memory_collection_name
248
+ ) from e
249
+
250
+ def get(self, memory_collection_name: str, config: Optional[Config] = None):
251
+ """获取记忆集合(同步)
252
+
253
+ Args:
254
+ memory_collection_name: 记忆集合名称
255
+ config: 配置
256
+
257
+ Returns:
258
+ MemoryCollection: 记忆集合对象
259
+
260
+ Raises:
261
+ ResourceNotExistError: 记忆集合不存在
262
+ """
263
+ try:
264
+ result = self.__control_api.get_memory_collection(
265
+ memory_collection_name, config=config
266
+ )
267
+ return MemoryCollection.from_inner_object(result)
268
+ except HTTPError as e:
269
+ raise e.to_resource_error(
270
+ "MemoryCollection", memory_collection_name
271
+ ) from e
272
+
273
+ async def list_async(
274
+ self,
275
+ input: Optional[MemoryCollectionListInput] = None,
276
+ config: Optional[Config] = None,
277
+ ):
278
+ """列出记忆集合(异步)
279
+
280
+ Args:
281
+ input: 分页查询参数
282
+ config: 配置
283
+
284
+ Returns:
285
+ List[MemoryCollectionListOutput]: 记忆集合列表
286
+ """
287
+ if input is None:
288
+ input = MemoryCollectionListInput()
289
+
290
+ results = await self.__control_api.list_memory_collections_async(
291
+ ListMemoryCollectionsRequest().from_map(input.model_dump()),
292
+ config=config,
293
+ )
294
+ return [
295
+ MemoryCollectionListOutput.from_inner_object(item)
296
+ for item in results.items # type: ignore
297
+ ]
298
+
299
+ def list(
300
+ self,
301
+ input: Optional[MemoryCollectionListInput] = None,
302
+ config: Optional[Config] = None,
303
+ ):
304
+ """列出记忆集合(同步)
305
+
306
+ Args:
307
+ input: 分页查询参数
308
+ config: 配置
309
+
310
+ Returns:
311
+ List[MemoryCollectionListOutput]: 记忆集合列表
312
+ """
313
+ if input is None:
314
+ input = MemoryCollectionListInput()
315
+
316
+ results = self.__control_api.list_memory_collections(
317
+ ListMemoryCollectionsRequest().from_map(input.model_dump()),
318
+ config=config,
319
+ )
320
+ return [
321
+ MemoryCollectionListOutput.from_inner_object(item)
322
+ for item in results.items # type: ignore
323
+ ]