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.
- agentrun/__init__.py +34 -1
- agentrun/agent_runtime/__endpoint_async_template.py +40 -0
- agentrun/agent_runtime/endpoint.py +79 -0
- agentrun/memory_collection/__client_async_template.py +178 -0
- agentrun/memory_collection/__init__.py +37 -0
- agentrun/memory_collection/__memory_collection_async_template.py +457 -0
- agentrun/memory_collection/api/__init__.py +5 -0
- agentrun/memory_collection/api/control.py +610 -0
- agentrun/memory_collection/client.py +323 -0
- agentrun/memory_collection/memory_collection.py +844 -0
- agentrun/memory_collection/model.py +162 -0
- {agentrun_inner_test-0.0.56.dist-info → agentrun_inner_test-0.0.64.dist-info}/METADATA +4 -4
- {agentrun_inner_test-0.0.56.dist-info → agentrun_inner_test-0.0.64.dist-info}/RECORD +16 -8
- {agentrun_inner_test-0.0.56.dist-info → agentrun_inner_test-0.0.64.dist-info}/WHEEL +0 -0
- {agentrun_inner_test-0.0.56.dist-info → agentrun_inner_test-0.0.64.dist-info}/licenses/LICENSE +0 -0
- {agentrun_inner_test-0.0.56.dist-info → agentrun_inner_test-0.0.64.dist-info}/top_level.txt +0 -0
agentrun/__init__.py
CHANGED
|
@@ -18,7 +18,7 @@ Provides simple and easy-to-use APIs for managing AI Agent runtime environments,
|
|
|
18
18
|
|
|
19
19
|
from typing import TYPE_CHECKING
|
|
20
20
|
|
|
21
|
-
__version__ = "0.0.
|
|
21
|
+
__version__ = "0.0.64"
|
|
22
22
|
|
|
23
23
|
# Agent Runtime
|
|
24
24
|
from agentrun.agent_runtime import (
|
|
@@ -55,6 +55,22 @@ from agentrun.credential import (
|
|
|
55
55
|
CredentialUpdateInput,
|
|
56
56
|
RelatedResource,
|
|
57
57
|
)
|
|
58
|
+
# Memory Collection
|
|
59
|
+
from agentrun.memory_collection import (
|
|
60
|
+
EmbedderConfig,
|
|
61
|
+
EmbedderConfigConfig,
|
|
62
|
+
LLMConfig,
|
|
63
|
+
LLMConfigConfig,
|
|
64
|
+
MemoryCollection,
|
|
65
|
+
MemoryCollectionClient,
|
|
66
|
+
MemoryCollectionCreateInput,
|
|
67
|
+
MemoryCollectionListInput,
|
|
68
|
+
MemoryCollectionListOutput,
|
|
69
|
+
MemoryCollectionUpdateInput,
|
|
70
|
+
NetworkConfiguration,
|
|
71
|
+
VectorStoreConfig,
|
|
72
|
+
VectorStoreConfigConfig,
|
|
73
|
+
)
|
|
58
74
|
# Model Service
|
|
59
75
|
from agentrun.model import (
|
|
60
76
|
BackendType,
|
|
@@ -173,6 +189,23 @@ __all__ = [
|
|
|
173
189
|
"CredentialCreateInput",
|
|
174
190
|
"CredentialUpdateInput",
|
|
175
191
|
"CredentialListInput",
|
|
192
|
+
######## Memory Collection ########
|
|
193
|
+
# base
|
|
194
|
+
"MemoryCollection",
|
|
195
|
+
"MemoryCollectionClient",
|
|
196
|
+
# inner model
|
|
197
|
+
"EmbedderConfig",
|
|
198
|
+
"EmbedderConfigConfig",
|
|
199
|
+
"LLMConfig",
|
|
200
|
+
"LLMConfigConfig",
|
|
201
|
+
"NetworkConfiguration",
|
|
202
|
+
"VectorStoreConfig",
|
|
203
|
+
"VectorStoreConfigConfig",
|
|
204
|
+
# api model
|
|
205
|
+
"MemoryCollectionCreateInput",
|
|
206
|
+
"MemoryCollectionUpdateInput",
|
|
207
|
+
"MemoryCollectionListInput",
|
|
208
|
+
"MemoryCollectionListOutput",
|
|
176
209
|
######## Model ########
|
|
177
210
|
# base
|
|
178
211
|
"ModelClient",
|
|
@@ -18,6 +18,7 @@ from agentrun.agent_runtime.model import (
|
|
|
18
18
|
AgentRuntimeEndpointUpdateInput,
|
|
19
19
|
)
|
|
20
20
|
from agentrun.utils.config import Config
|
|
21
|
+
from agentrun.utils.model import PageableInput
|
|
21
22
|
from agentrun.utils.resource import ResourceBase
|
|
22
23
|
|
|
23
24
|
|
|
@@ -160,6 +161,45 @@ class AgentRuntimeEndpoint(
|
|
|
160
161
|
config=config,
|
|
161
162
|
)
|
|
162
163
|
|
|
164
|
+
@classmethod
|
|
165
|
+
async def _list_page_async(
|
|
166
|
+
cls,
|
|
167
|
+
page_input: PageableInput,
|
|
168
|
+
config: Optional[Config] = None,
|
|
169
|
+
**kwargs,
|
|
170
|
+
) -> List["AgentRuntimeEndpoint"]:
|
|
171
|
+
"""分页列出端点 / List endpoints by page
|
|
172
|
+
|
|
173
|
+
此方法是 ResourceBase 要求实现的抽象方法,用于支持分页查询。
|
|
174
|
+
This method is an abstract method required by ResourceBase to support pagination.
|
|
175
|
+
|
|
176
|
+
Args:
|
|
177
|
+
page_input: 分页参数 / Pagination parameters
|
|
178
|
+
config: 配置对象,可选 / Configuration object, optional
|
|
179
|
+
**kwargs: 其他参数,必须包含 agent_runtime_id / Other parameters, must include agent_runtime_id
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
List[AgentRuntimeEndpoint]: 端点对象列表 / List of endpoint objects
|
|
183
|
+
|
|
184
|
+
Raises:
|
|
185
|
+
ValueError: 当 agent_runtime_id 未提供时 / When agent_runtime_id is not provided
|
|
186
|
+
HTTPError: HTTP 请求错误 / HTTP request error
|
|
187
|
+
"""
|
|
188
|
+
agent_runtime_id = kwargs.get("agent_runtime_id")
|
|
189
|
+
if not agent_runtime_id:
|
|
190
|
+
raise ValueError(
|
|
191
|
+
"agent_runtime_id is required for listing endpoints"
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
return await cls.__get_client().list_endpoints_async(
|
|
195
|
+
agent_runtime_id,
|
|
196
|
+
AgentRuntimeEndpointListInput(
|
|
197
|
+
page_number=page_input.page_number,
|
|
198
|
+
page_size=page_input.page_size,
|
|
199
|
+
),
|
|
200
|
+
config=config,
|
|
201
|
+
)
|
|
202
|
+
|
|
163
203
|
@classmethod
|
|
164
204
|
async def list_by_id_async(
|
|
165
205
|
cls, agent_runtime_id: str, config: Optional[Config] = None
|
|
@@ -28,6 +28,7 @@ from agentrun.agent_runtime.model import (
|
|
|
28
28
|
AgentRuntimeEndpointUpdateInput,
|
|
29
29
|
)
|
|
30
30
|
from agentrun.utils.config import Config
|
|
31
|
+
from agentrun.utils.model import PageableInput
|
|
31
32
|
from agentrun.utils.resource import ResourceBase
|
|
32
33
|
|
|
33
34
|
|
|
@@ -286,6 +287,84 @@ class AgentRuntimeEndpoint(
|
|
|
286
287
|
config=config,
|
|
287
288
|
)
|
|
288
289
|
|
|
290
|
+
@classmethod
|
|
291
|
+
async def _list_page_async(
|
|
292
|
+
cls,
|
|
293
|
+
page_input: PageableInput,
|
|
294
|
+
config: Optional[Config] = None,
|
|
295
|
+
**kwargs,
|
|
296
|
+
) -> List["AgentRuntimeEndpoint"]:
|
|
297
|
+
"""分页列出端点 / List endpoints by page
|
|
298
|
+
|
|
299
|
+
此方法是 ResourceBase 要求实现的抽象方法,用于支持分页查询。
|
|
300
|
+
This method is an abstract method required by ResourceBase to support pagination.
|
|
301
|
+
|
|
302
|
+
Args:
|
|
303
|
+
page_input: 分页参数 / Pagination parameters
|
|
304
|
+
config: 配置对象,可选 / Configuration object, optional
|
|
305
|
+
**kwargs: 其他参数,必须包含 agent_runtime_id / Other parameters, must include agent_runtime_id
|
|
306
|
+
|
|
307
|
+
Returns:
|
|
308
|
+
List[AgentRuntimeEndpoint]: 端点对象列表 / List of endpoint objects
|
|
309
|
+
|
|
310
|
+
Raises:
|
|
311
|
+
ValueError: 当 agent_runtime_id 未提供时 / When agent_runtime_id is not provided
|
|
312
|
+
HTTPError: HTTP 请求错误 / HTTP request error
|
|
313
|
+
"""
|
|
314
|
+
agent_runtime_id = kwargs.get("agent_runtime_id")
|
|
315
|
+
if not agent_runtime_id:
|
|
316
|
+
raise ValueError(
|
|
317
|
+
"agent_runtime_id is required for listing endpoints"
|
|
318
|
+
)
|
|
319
|
+
|
|
320
|
+
return await cls.__get_client().list_endpoints_async(
|
|
321
|
+
agent_runtime_id,
|
|
322
|
+
AgentRuntimeEndpointListInput(
|
|
323
|
+
page_number=page_input.page_number,
|
|
324
|
+
page_size=page_input.page_size,
|
|
325
|
+
),
|
|
326
|
+
config=config,
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
@classmethod
|
|
330
|
+
def _list_page(
|
|
331
|
+
cls,
|
|
332
|
+
page_input: PageableInput,
|
|
333
|
+
config: Optional[Config] = None,
|
|
334
|
+
**kwargs,
|
|
335
|
+
) -> List["AgentRuntimeEndpoint"]:
|
|
336
|
+
"""分页列出端点 / List endpoints by page
|
|
337
|
+
|
|
338
|
+
此方法是 ResourceBase 要求实现的抽象方法,用于支持分页查询。
|
|
339
|
+
This method is an abstract method required by ResourceBase to support pagination.
|
|
340
|
+
|
|
341
|
+
Args:
|
|
342
|
+
page_input: 分页参数 / Pagination parameters
|
|
343
|
+
config: 配置对象,可选 / Configuration object, optional
|
|
344
|
+
**kwargs: 其他参数,必须包含 agent_runtime_id / Other parameters, must include agent_runtime_id
|
|
345
|
+
|
|
346
|
+
Returns:
|
|
347
|
+
List[AgentRuntimeEndpoint]: 端点对象列表 / List of endpoint objects
|
|
348
|
+
|
|
349
|
+
Raises:
|
|
350
|
+
ValueError: 当 agent_runtime_id 未提供时 / When agent_runtime_id is not provided
|
|
351
|
+
HTTPError: HTTP 请求错误 / HTTP request error
|
|
352
|
+
"""
|
|
353
|
+
agent_runtime_id = kwargs.get("agent_runtime_id")
|
|
354
|
+
if not agent_runtime_id:
|
|
355
|
+
raise ValueError(
|
|
356
|
+
"agent_runtime_id is required for listing endpoints"
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
return cls.__get_client().list_endpoints(
|
|
360
|
+
agent_runtime_id,
|
|
361
|
+
AgentRuntimeEndpointListInput(
|
|
362
|
+
page_number=page_input.page_number,
|
|
363
|
+
page_size=page_input.page_size,
|
|
364
|
+
),
|
|
365
|
+
config=config,
|
|
366
|
+
)
|
|
367
|
+
|
|
289
368
|
@classmethod
|
|
290
369
|
async def list_by_id_async(
|
|
291
370
|
cls, agent_runtime_id: str, config: Optional[Config] = None
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"""MemoryCollection 客户端 / MemoryCollection Client
|
|
2
|
+
|
|
3
|
+
此模块提供记忆集合管理的客户端API。
|
|
4
|
+
This module provides the client API for memory collection management.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
from alibabacloud_agentrun20250910.models import (
|
|
10
|
+
CreateMemoryCollectionInput,
|
|
11
|
+
ListMemoryCollectionsRequest,
|
|
12
|
+
UpdateMemoryCollectionInput,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from agentrun.utils.config import Config
|
|
16
|
+
from agentrun.utils.exception import HTTPError
|
|
17
|
+
|
|
18
|
+
from .api.control import MemoryCollectionControlAPI
|
|
19
|
+
from .memory_collection import MemoryCollection
|
|
20
|
+
from .model import (
|
|
21
|
+
MemoryCollectionCreateInput,
|
|
22
|
+
MemoryCollectionListInput,
|
|
23
|
+
MemoryCollectionListOutput,
|
|
24
|
+
MemoryCollectionUpdateInput,
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class MemoryCollectionClient:
|
|
29
|
+
"""MemoryCollection 客户端 / MemoryCollection Client
|
|
30
|
+
|
|
31
|
+
提供记忆集合的创建、删除、更新和查询功能。
|
|
32
|
+
Provides create, delete, update and query functions for memory collections.
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(self, config: Optional[Config] = None):
|
|
36
|
+
"""初始化客户端 / Initialize client
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
config: 配置对象,可选 / Configuration object, optional
|
|
40
|
+
"""
|
|
41
|
+
self.__control_api = MemoryCollectionControlAPI(config)
|
|
42
|
+
|
|
43
|
+
async def create_async(
|
|
44
|
+
self,
|
|
45
|
+
input: MemoryCollectionCreateInput,
|
|
46
|
+
config: Optional[Config] = None,
|
|
47
|
+
):
|
|
48
|
+
"""创建记忆集合(异步) / Create memory collection asynchronously
|
|
49
|
+
|
|
50
|
+
Args:
|
|
51
|
+
input: 记忆集合输入参数 / Memory collection input parameters
|
|
52
|
+
config: 配置对象,可选 / Configuration object, optional
|
|
53
|
+
|
|
54
|
+
Returns:
|
|
55
|
+
MemoryCollection: 创建的记忆集合对象 / Created memory collection object
|
|
56
|
+
|
|
57
|
+
Raises:
|
|
58
|
+
ResourceAlreadyExistError: 资源已存在 / Resource already exists
|
|
59
|
+
HTTPError: HTTP 请求错误 / HTTP request error
|
|
60
|
+
"""
|
|
61
|
+
try:
|
|
62
|
+
result = await self.__control_api.create_memory_collection_async(
|
|
63
|
+
CreateMemoryCollectionInput().from_map(input.model_dump()),
|
|
64
|
+
config=config,
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
return MemoryCollection.from_inner_object(result)
|
|
68
|
+
except HTTPError as e:
|
|
69
|
+
raise e.to_resource_error(
|
|
70
|
+
"MemoryCollection", input.memory_collection_name
|
|
71
|
+
) from e
|
|
72
|
+
|
|
73
|
+
async def delete_async(
|
|
74
|
+
self, memory_collection_name: str, config: Optional[Config] = None
|
|
75
|
+
):
|
|
76
|
+
"""删除记忆集合(异步)
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
memory_collection_name: 记忆集合名称
|
|
80
|
+
config: 配置
|
|
81
|
+
|
|
82
|
+
Raises:
|
|
83
|
+
ResourceNotExistError: 记忆集合不存在
|
|
84
|
+
"""
|
|
85
|
+
try:
|
|
86
|
+
result = await self.__control_api.delete_memory_collection_async(
|
|
87
|
+
memory_collection_name, config=config
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
return MemoryCollection.from_inner_object(result)
|
|
91
|
+
|
|
92
|
+
except HTTPError as e:
|
|
93
|
+
raise e.to_resource_error(
|
|
94
|
+
"MemoryCollection", memory_collection_name
|
|
95
|
+
) from e
|
|
96
|
+
|
|
97
|
+
async def update_async(
|
|
98
|
+
self,
|
|
99
|
+
memory_collection_name: str,
|
|
100
|
+
input: MemoryCollectionUpdateInput,
|
|
101
|
+
config: Optional[Config] = None,
|
|
102
|
+
):
|
|
103
|
+
"""更新记忆集合(异步)
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
memory_collection_name: 记忆集合名称
|
|
107
|
+
input: 记忆集合更新输入参数
|
|
108
|
+
config: 配置
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
MemoryCollection: 更新后的记忆集合对象
|
|
112
|
+
|
|
113
|
+
Raises:
|
|
114
|
+
ResourceNotExistError: 记忆集合不存在
|
|
115
|
+
"""
|
|
116
|
+
try:
|
|
117
|
+
result = await self.__control_api.update_memory_collection_async(
|
|
118
|
+
memory_collection_name,
|
|
119
|
+
UpdateMemoryCollectionInput().from_map(input.model_dump()),
|
|
120
|
+
config=config,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
return MemoryCollection.from_inner_object(result)
|
|
124
|
+
except HTTPError as e:
|
|
125
|
+
raise e.to_resource_error(
|
|
126
|
+
"MemoryCollection", memory_collection_name
|
|
127
|
+
) from e
|
|
128
|
+
|
|
129
|
+
async def get_async(
|
|
130
|
+
self, memory_collection_name: str, config: Optional[Config] = None
|
|
131
|
+
):
|
|
132
|
+
"""获取记忆集合(异步)
|
|
133
|
+
|
|
134
|
+
Args:
|
|
135
|
+
memory_collection_name: 记忆集合名称
|
|
136
|
+
config: 配置
|
|
137
|
+
|
|
138
|
+
Returns:
|
|
139
|
+
MemoryCollection: 记忆集合对象
|
|
140
|
+
|
|
141
|
+
Raises:
|
|
142
|
+
ResourceNotExistError: 记忆集合不存在
|
|
143
|
+
"""
|
|
144
|
+
try:
|
|
145
|
+
result = await self.__control_api.get_memory_collection_async(
|
|
146
|
+
memory_collection_name, config=config
|
|
147
|
+
)
|
|
148
|
+
return MemoryCollection.from_inner_object(result)
|
|
149
|
+
except HTTPError as e:
|
|
150
|
+
raise e.to_resource_error(
|
|
151
|
+
"MemoryCollection", memory_collection_name
|
|
152
|
+
) from e
|
|
153
|
+
|
|
154
|
+
async def list_async(
|
|
155
|
+
self,
|
|
156
|
+
input: Optional[MemoryCollectionListInput] = None,
|
|
157
|
+
config: Optional[Config] = None,
|
|
158
|
+
):
|
|
159
|
+
"""列出记忆集合(异步)
|
|
160
|
+
|
|
161
|
+
Args:
|
|
162
|
+
input: 分页查询参数
|
|
163
|
+
config: 配置
|
|
164
|
+
|
|
165
|
+
Returns:
|
|
166
|
+
List[MemoryCollectionListOutput]: 记忆集合列表
|
|
167
|
+
"""
|
|
168
|
+
if input is None:
|
|
169
|
+
input = MemoryCollectionListInput()
|
|
170
|
+
|
|
171
|
+
results = await self.__control_api.list_memory_collections_async(
|
|
172
|
+
ListMemoryCollectionsRequest().from_map(input.model_dump()),
|
|
173
|
+
config=config,
|
|
174
|
+
)
|
|
175
|
+
return [
|
|
176
|
+
MemoryCollectionListOutput.from_inner_object(item)
|
|
177
|
+
for item in results.items # type: ignore
|
|
178
|
+
]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""MemoryCollection 模块 / MemoryCollection Module
|
|
2
|
+
|
|
3
|
+
提供记忆集合管理功能。
|
|
4
|
+
Provides memory collection management functionality.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .client import MemoryCollectionClient
|
|
8
|
+
from .memory_collection import MemoryCollection
|
|
9
|
+
from .model import (
|
|
10
|
+
EmbedderConfig,
|
|
11
|
+
EmbedderConfigConfig,
|
|
12
|
+
LLMConfig,
|
|
13
|
+
LLMConfigConfig,
|
|
14
|
+
MemoryCollectionCreateInput,
|
|
15
|
+
MemoryCollectionListInput,
|
|
16
|
+
MemoryCollectionListOutput,
|
|
17
|
+
MemoryCollectionUpdateInput,
|
|
18
|
+
NetworkConfiguration,
|
|
19
|
+
VectorStoreConfig,
|
|
20
|
+
VectorStoreConfigConfig,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"MemoryCollection",
|
|
25
|
+
"MemoryCollectionClient",
|
|
26
|
+
"MemoryCollectionCreateInput",
|
|
27
|
+
"MemoryCollectionUpdateInput",
|
|
28
|
+
"MemoryCollectionListInput",
|
|
29
|
+
"MemoryCollectionListOutput",
|
|
30
|
+
"EmbedderConfig",
|
|
31
|
+
"EmbedderConfigConfig",
|
|
32
|
+
"LLMConfig",
|
|
33
|
+
"LLMConfigConfig",
|
|
34
|
+
"NetworkConfiguration",
|
|
35
|
+
"VectorStoreConfig",
|
|
36
|
+
"VectorStoreConfigConfig",
|
|
37
|
+
]
|