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.
- agentrun/__init__.py +358 -0
- agentrun/agent_runtime/__client_async_template.py +466 -0
- agentrun/agent_runtime/__endpoint_async_template.py +345 -0
- agentrun/agent_runtime/__init__.py +53 -0
- agentrun/agent_runtime/__runtime_async_template.py +477 -0
- agentrun/agent_runtime/api/__data_async_template.py +58 -0
- agentrun/agent_runtime/api/__init__.py +6 -0
- agentrun/agent_runtime/api/control.py +1362 -0
- agentrun/agent_runtime/api/data.py +98 -0
- agentrun/agent_runtime/client.py +868 -0
- agentrun/agent_runtime/endpoint.py +649 -0
- agentrun/agent_runtime/model.py +362 -0
- agentrun/agent_runtime/runtime.py +904 -0
- agentrun/credential/__client_async_template.py +177 -0
- agentrun/credential/__credential_async_template.py +216 -0
- agentrun/credential/__init__.py +28 -0
- agentrun/credential/api/__init__.py +5 -0
- agentrun/credential/api/control.py +606 -0
- agentrun/credential/client.py +319 -0
- agentrun/credential/credential.py +381 -0
- agentrun/credential/model.py +248 -0
- agentrun/integration/__init__.py +21 -0
- agentrun/integration/agentscope/__init__.py +13 -0
- agentrun/integration/agentscope/adapter.py +17 -0
- agentrun/integration/agentscope/builtin.py +88 -0
- agentrun/integration/agentscope/message_adapter.py +185 -0
- agentrun/integration/agentscope/model_adapter.py +60 -0
- agentrun/integration/agentscope/tool_adapter.py +59 -0
- agentrun/integration/builtin/__init__.py +18 -0
- agentrun/integration/builtin/knowledgebase.py +137 -0
- agentrun/integration/builtin/model.py +93 -0
- agentrun/integration/builtin/sandbox.py +1234 -0
- agentrun/integration/builtin/toolset.py +47 -0
- agentrun/integration/crewai/__init__.py +13 -0
- agentrun/integration/crewai/adapter.py +9 -0
- agentrun/integration/crewai/builtin.py +88 -0
- agentrun/integration/crewai/model_adapter.py +31 -0
- agentrun/integration/crewai/tool_adapter.py +26 -0
- agentrun/integration/google_adk/__init__.py +13 -0
- agentrun/integration/google_adk/adapter.py +15 -0
- agentrun/integration/google_adk/builtin.py +88 -0
- agentrun/integration/google_adk/message_adapter.py +144 -0
- agentrun/integration/google_adk/model_adapter.py +46 -0
- agentrun/integration/google_adk/tool_adapter.py +235 -0
- agentrun/integration/langchain/__init__.py +31 -0
- agentrun/integration/langchain/adapter.py +15 -0
- agentrun/integration/langchain/builtin.py +94 -0
- agentrun/integration/langchain/message_adapter.py +141 -0
- agentrun/integration/langchain/model_adapter.py +37 -0
- agentrun/integration/langchain/tool_adapter.py +50 -0
- agentrun/integration/langgraph/__init__.py +36 -0
- agentrun/integration/langgraph/adapter.py +20 -0
- agentrun/integration/langgraph/agent_converter.py +1073 -0
- agentrun/integration/langgraph/builtin.py +88 -0
- agentrun/integration/pydantic_ai/__init__.py +13 -0
- agentrun/integration/pydantic_ai/adapter.py +13 -0
- agentrun/integration/pydantic_ai/builtin.py +88 -0
- agentrun/integration/pydantic_ai/model_adapter.py +44 -0
- agentrun/integration/pydantic_ai/tool_adapter.py +19 -0
- agentrun/integration/utils/__init__.py +112 -0
- agentrun/integration/utils/adapter.py +560 -0
- agentrun/integration/utils/canonical.py +164 -0
- agentrun/integration/utils/converter.py +134 -0
- agentrun/integration/utils/model.py +110 -0
- agentrun/integration/utils/tool.py +1759 -0
- agentrun/knowledgebase/__client_async_template.py +173 -0
- agentrun/knowledgebase/__init__.py +53 -0
- agentrun/knowledgebase/__knowledgebase_async_template.py +438 -0
- agentrun/knowledgebase/api/__data_async_template.py +414 -0
- agentrun/knowledgebase/api/__init__.py +19 -0
- agentrun/knowledgebase/api/control.py +606 -0
- agentrun/knowledgebase/api/data.py +624 -0
- agentrun/knowledgebase/client.py +311 -0
- agentrun/knowledgebase/knowledgebase.py +748 -0
- agentrun/knowledgebase/model.py +270 -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/model/__client_async_template.py +357 -0
- agentrun/model/__init__.py +57 -0
- agentrun/model/__model_proxy_async_template.py +270 -0
- agentrun/model/__model_service_async_template.py +267 -0
- agentrun/model/api/__init__.py +6 -0
- agentrun/model/api/control.py +1173 -0
- agentrun/model/api/data.py +196 -0
- agentrun/model/client.py +674 -0
- agentrun/model/model.py +235 -0
- agentrun/model/model_proxy.py +439 -0
- agentrun/model/model_service.py +438 -0
- agentrun/sandbox/__aio_sandbox_async_template.py +523 -0
- agentrun/sandbox/__browser_sandbox_async_template.py +110 -0
- agentrun/sandbox/__client_async_template.py +491 -0
- agentrun/sandbox/__code_interpreter_sandbox_async_template.py +463 -0
- agentrun/sandbox/__init__.py +69 -0
- agentrun/sandbox/__sandbox_async_template.py +463 -0
- agentrun/sandbox/__template_async_template.py +152 -0
- agentrun/sandbox/aio_sandbox.py +912 -0
- agentrun/sandbox/api/__aio_data_async_template.py +335 -0
- agentrun/sandbox/api/__browser_data_async_template.py +140 -0
- agentrun/sandbox/api/__code_interpreter_data_async_template.py +206 -0
- agentrun/sandbox/api/__init__.py +19 -0
- agentrun/sandbox/api/__sandbox_data_async_template.py +107 -0
- agentrun/sandbox/api/aio_data.py +551 -0
- agentrun/sandbox/api/browser_data.py +172 -0
- agentrun/sandbox/api/code_interpreter_data.py +396 -0
- agentrun/sandbox/api/control.py +1051 -0
- agentrun/sandbox/api/playwright_async.py +492 -0
- agentrun/sandbox/api/playwright_sync.py +492 -0
- agentrun/sandbox/api/sandbox_data.py +154 -0
- agentrun/sandbox/browser_sandbox.py +185 -0
- agentrun/sandbox/client.py +925 -0
- agentrun/sandbox/code_interpreter_sandbox.py +823 -0
- agentrun/sandbox/model.py +384 -0
- agentrun/sandbox/sandbox.py +848 -0
- agentrun/sandbox/template.py +217 -0
- agentrun/server/__init__.py +191 -0
- agentrun/server/agui_normalizer.py +180 -0
- agentrun/server/agui_protocol.py +797 -0
- agentrun/server/invoker.py +309 -0
- agentrun/server/model.py +427 -0
- agentrun/server/openai_protocol.py +535 -0
- agentrun/server/protocol.py +140 -0
- agentrun/server/server.py +208 -0
- agentrun/toolset/__client_async_template.py +62 -0
- agentrun/toolset/__init__.py +51 -0
- agentrun/toolset/__toolset_async_template.py +204 -0
- agentrun/toolset/api/__init__.py +17 -0
- agentrun/toolset/api/control.py +262 -0
- agentrun/toolset/api/mcp.py +100 -0
- agentrun/toolset/api/openapi.py +1251 -0
- agentrun/toolset/client.py +102 -0
- agentrun/toolset/model.py +321 -0
- agentrun/toolset/toolset.py +271 -0
- agentrun/utils/__data_api_async_template.py +721 -0
- agentrun/utils/__init__.py +5 -0
- agentrun/utils/__resource_async_template.py +158 -0
- agentrun/utils/config.py +270 -0
- agentrun/utils/control_api.py +105 -0
- agentrun/utils/data_api.py +1121 -0
- agentrun/utils/exception.py +151 -0
- agentrun/utils/helper.py +108 -0
- agentrun/utils/log.py +77 -0
- agentrun/utils/model.py +168 -0
- agentrun/utils/resource.py +291 -0
- agentrun_inner_test-0.0.62.dist-info/METADATA +265 -0
- agentrun_inner_test-0.0.62.dist-info/RECORD +154 -0
- agentrun_inner_test-0.0.62.dist-info/WHEEL +5 -0
- agentrun_inner_test-0.0.62.dist-info/licenses/LICENSE +201 -0
- agentrun_inner_test-0.0.62.dist-info/top_level.txt +1 -0
agentrun/__init__.py
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"""AgentRun Python SDK / AgentRun Python SDK
|
|
2
|
+
|
|
3
|
+
AgentRun Python SDK 是阿里云 AgentRun 服务的 Python 客户端库。
|
|
4
|
+
AgentRun Python SDK is the Python client library for Alibaba Cloud AgentRun service.
|
|
5
|
+
|
|
6
|
+
提供简洁易用的 API 来管理 AI Agent 运行时环境、模型服务、沙箱环境等。
|
|
7
|
+
Provides simple and easy-to-use APIs for managing AI Agent runtime environments, model services, sandbox environments, etc.
|
|
8
|
+
|
|
9
|
+
主要功能 / Main Features:
|
|
10
|
+
- Agent Runtime: Agent 运行时管理 / Agent runtime management
|
|
11
|
+
- Model Service: 模型服务管理 / Model service management
|
|
12
|
+
- Sandbox: 沙箱环境管理 / Sandbox environment management
|
|
13
|
+
- ToolSet: 工具集管理 / Toolset management
|
|
14
|
+
- Credential: 凭证管理 / Credential management
|
|
15
|
+
- Server: HTTP 服务器 / HTTP server
|
|
16
|
+
- Integration: 框架集成 / Framework integration
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
from typing import TYPE_CHECKING
|
|
20
|
+
|
|
21
|
+
__version__ = "0.0.62"
|
|
22
|
+
|
|
23
|
+
# Agent Runtime
|
|
24
|
+
from agentrun.agent_runtime import (
|
|
25
|
+
AgentRuntime,
|
|
26
|
+
AgentRuntimeArtifact,
|
|
27
|
+
AgentRuntimeClient,
|
|
28
|
+
AgentRuntimeCode,
|
|
29
|
+
AgentRuntimeContainer,
|
|
30
|
+
AgentRuntimeControlAPI,
|
|
31
|
+
AgentRuntimeCreateInput,
|
|
32
|
+
AgentRuntimeEndpoint,
|
|
33
|
+
AgentRuntimeEndpointCreateInput,
|
|
34
|
+
AgentRuntimeEndpointListInput,
|
|
35
|
+
AgentRuntimeEndpointRoutingConfig,
|
|
36
|
+
AgentRuntimeEndpointRoutingWeight,
|
|
37
|
+
AgentRuntimeEndpointUpdateInput,
|
|
38
|
+
AgentRuntimeHealthCheckConfig,
|
|
39
|
+
AgentRuntimeLanguage,
|
|
40
|
+
AgentRuntimeListInput,
|
|
41
|
+
AgentRuntimeLogConfig,
|
|
42
|
+
AgentRuntimeProtocolConfig,
|
|
43
|
+
AgentRuntimeProtocolType,
|
|
44
|
+
AgentRuntimeUpdateInput,
|
|
45
|
+
)
|
|
46
|
+
# Credential
|
|
47
|
+
from agentrun.credential import (
|
|
48
|
+
Credential,
|
|
49
|
+
CredentialBasicAuth,
|
|
50
|
+
CredentialClient,
|
|
51
|
+
CredentialConfig,
|
|
52
|
+
CredentialControlAPI,
|
|
53
|
+
CredentialCreateInput,
|
|
54
|
+
CredentialListInput,
|
|
55
|
+
CredentialUpdateInput,
|
|
56
|
+
RelatedResource,
|
|
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
|
+
)
|
|
74
|
+
# Model Service
|
|
75
|
+
from agentrun.model import (
|
|
76
|
+
BackendType,
|
|
77
|
+
ModelClient,
|
|
78
|
+
ModelCompletionAPI,
|
|
79
|
+
ModelControlAPI,
|
|
80
|
+
ModelDataAPI,
|
|
81
|
+
ModelFeatures,
|
|
82
|
+
ModelInfoConfig,
|
|
83
|
+
ModelParameterRule,
|
|
84
|
+
ModelProperties,
|
|
85
|
+
ModelProxy,
|
|
86
|
+
ModelProxyCreateInput,
|
|
87
|
+
ModelProxyListInput,
|
|
88
|
+
ModelProxyUpdateInput,
|
|
89
|
+
ModelService,
|
|
90
|
+
ModelServiceCreateInput,
|
|
91
|
+
ModelServiceListInput,
|
|
92
|
+
ModelServiceUpdateInput,
|
|
93
|
+
ModelType,
|
|
94
|
+
Provider,
|
|
95
|
+
ProviderSettings,
|
|
96
|
+
ProxyConfig,
|
|
97
|
+
ProxyConfigEndpoint,
|
|
98
|
+
ProxyConfigFallback,
|
|
99
|
+
ProxyConfigPolicies,
|
|
100
|
+
)
|
|
101
|
+
# Sandbox
|
|
102
|
+
from agentrun.sandbox import (
|
|
103
|
+
BrowserSandbox,
|
|
104
|
+
CodeInterpreterSandbox,
|
|
105
|
+
SandboxClient,
|
|
106
|
+
Template,
|
|
107
|
+
)
|
|
108
|
+
# ToolSet
|
|
109
|
+
from agentrun.toolset import ToolSet, ToolSetClient
|
|
110
|
+
from agentrun.utils.config import Config
|
|
111
|
+
from agentrun.utils.exception import (
|
|
112
|
+
ResourceAlreadyExistError,
|
|
113
|
+
ResourceNotExistError,
|
|
114
|
+
)
|
|
115
|
+
from agentrun.utils.model import Status
|
|
116
|
+
|
|
117
|
+
# Server - 延迟导入以避免可选依赖问题
|
|
118
|
+
# Type hints for IDE and type checkers
|
|
119
|
+
if TYPE_CHECKING:
|
|
120
|
+
from agentrun.server import (
|
|
121
|
+
AgentEvent,
|
|
122
|
+
AgentEventItem,
|
|
123
|
+
AgentRequest,
|
|
124
|
+
AgentResult,
|
|
125
|
+
AgentResultItem,
|
|
126
|
+
AgentReturnType,
|
|
127
|
+
AgentRunServer,
|
|
128
|
+
AguiEventNormalizer,
|
|
129
|
+
AGUIProtocolConfig,
|
|
130
|
+
AGUIProtocolHandler,
|
|
131
|
+
AsyncAgentEventGenerator,
|
|
132
|
+
AsyncAgentResultGenerator,
|
|
133
|
+
AsyncInvokeAgentHandler,
|
|
134
|
+
BaseProtocolHandler,
|
|
135
|
+
EventType,
|
|
136
|
+
InvokeAgentHandler,
|
|
137
|
+
MergeOptions,
|
|
138
|
+
Message,
|
|
139
|
+
MessageRole,
|
|
140
|
+
OpenAIProtocolConfig,
|
|
141
|
+
OpenAIProtocolHandler,
|
|
142
|
+
ProtocolConfig,
|
|
143
|
+
ProtocolHandler,
|
|
144
|
+
ServerConfig,
|
|
145
|
+
SyncAgentEventGenerator,
|
|
146
|
+
SyncAgentResultGenerator,
|
|
147
|
+
SyncInvokeAgentHandler,
|
|
148
|
+
Tool,
|
|
149
|
+
ToolCall,
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
__all__ = [
|
|
153
|
+
######## Agent Runtime ########
|
|
154
|
+
# base
|
|
155
|
+
"AgentRuntime",
|
|
156
|
+
"AgentRuntimeEndpoint",
|
|
157
|
+
"AgentRuntimeClient",
|
|
158
|
+
"AgentRuntimeControlAPI",
|
|
159
|
+
# enum
|
|
160
|
+
"AgentRuntimeArtifact",
|
|
161
|
+
"AgentRuntimeLanguage",
|
|
162
|
+
"AgentRuntimeProtocolType",
|
|
163
|
+
"Status",
|
|
164
|
+
# inner model
|
|
165
|
+
"AgentRuntimeCode",
|
|
166
|
+
"AgentRuntimeContainer",
|
|
167
|
+
"AgentRuntimeHealthCheckConfig",
|
|
168
|
+
"AgentRuntimeLogConfig",
|
|
169
|
+
"AgentRuntimeProtocolConfig",
|
|
170
|
+
"AgentRuntimeEndpointRoutingConfig",
|
|
171
|
+
"AgentRuntimeEndpointRoutingWeight",
|
|
172
|
+
# api model
|
|
173
|
+
"AgentRuntimeCreateInput",
|
|
174
|
+
"AgentRuntimeUpdateInput",
|
|
175
|
+
"AgentRuntimeListInput",
|
|
176
|
+
"AgentRuntimeEndpointCreateInput",
|
|
177
|
+
"AgentRuntimeEndpointUpdateInput",
|
|
178
|
+
"AgentRuntimeEndpointListInput",
|
|
179
|
+
######## Credential ########
|
|
180
|
+
# base
|
|
181
|
+
"Credential",
|
|
182
|
+
"CredentialClient",
|
|
183
|
+
"CredentialControlAPI",
|
|
184
|
+
# inner model
|
|
185
|
+
"CredentialBasicAuth",
|
|
186
|
+
"RelatedResource",
|
|
187
|
+
"CredentialConfig",
|
|
188
|
+
# api model
|
|
189
|
+
"CredentialCreateInput",
|
|
190
|
+
"CredentialUpdateInput",
|
|
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",
|
|
209
|
+
######## Model ########
|
|
210
|
+
# base
|
|
211
|
+
"ModelClient",
|
|
212
|
+
"ModelService",
|
|
213
|
+
"ModelProxy",
|
|
214
|
+
"ModelControlAPI",
|
|
215
|
+
"ModelCompletionAPI",
|
|
216
|
+
"ModelDataAPI",
|
|
217
|
+
# enum
|
|
218
|
+
"BackendType",
|
|
219
|
+
"ModelType",
|
|
220
|
+
"Provider",
|
|
221
|
+
# inner model
|
|
222
|
+
"ProviderSettings",
|
|
223
|
+
"ModelFeatures",
|
|
224
|
+
"ModelProperties",
|
|
225
|
+
"ModelParameterRule",
|
|
226
|
+
"ModelInfoConfig",
|
|
227
|
+
"ProxyConfigEndpoint",
|
|
228
|
+
"ProxyConfigFallback",
|
|
229
|
+
"ProxyConfigPolicies",
|
|
230
|
+
"ProxyConfig",
|
|
231
|
+
# api model
|
|
232
|
+
"ModelServiceCreateInput",
|
|
233
|
+
"ModelServiceUpdateInput",
|
|
234
|
+
"ModelServiceListInput",
|
|
235
|
+
"ModelProxyCreateInput",
|
|
236
|
+
"ModelProxyUpdateInput",
|
|
237
|
+
"ModelProxyListInput",
|
|
238
|
+
######## Sandbox ########
|
|
239
|
+
"SandboxClient",
|
|
240
|
+
"BrowserSandbox",
|
|
241
|
+
"CodeInterpreterSandbox",
|
|
242
|
+
"Template",
|
|
243
|
+
######## ToolSet ########
|
|
244
|
+
"ToolSetClient",
|
|
245
|
+
"ToolSet",
|
|
246
|
+
######## Server (延迟加载) ########
|
|
247
|
+
# Server
|
|
248
|
+
"AgentRunServer",
|
|
249
|
+
# Config
|
|
250
|
+
"ServerConfig",
|
|
251
|
+
"ProtocolConfig",
|
|
252
|
+
"OpenAIProtocolConfig",
|
|
253
|
+
"AGUIProtocolConfig",
|
|
254
|
+
# Request/Response Models
|
|
255
|
+
"AgentRequest",
|
|
256
|
+
"AgentEvent",
|
|
257
|
+
"AgentResult",
|
|
258
|
+
"Message",
|
|
259
|
+
"MessageRole",
|
|
260
|
+
"Tool",
|
|
261
|
+
"ToolCall",
|
|
262
|
+
# Event Types
|
|
263
|
+
"EventType",
|
|
264
|
+
# Type Aliases
|
|
265
|
+
"AgentEventItem",
|
|
266
|
+
"AgentResultItem",
|
|
267
|
+
"AgentReturnType",
|
|
268
|
+
"SyncAgentEventGenerator",
|
|
269
|
+
"SyncAgentResultGenerator",
|
|
270
|
+
"AsyncAgentEventGenerator",
|
|
271
|
+
"AsyncAgentResultGenerator",
|
|
272
|
+
"InvokeAgentHandler",
|
|
273
|
+
"AsyncInvokeAgentHandler",
|
|
274
|
+
"SyncInvokeAgentHandler",
|
|
275
|
+
# Protocol Base
|
|
276
|
+
"ProtocolHandler",
|
|
277
|
+
"BaseProtocolHandler",
|
|
278
|
+
# Protocol - OpenAI
|
|
279
|
+
"OpenAIProtocolHandler",
|
|
280
|
+
# Protocol - AG-UI
|
|
281
|
+
"AGUIProtocolHandler",
|
|
282
|
+
# Event Normalizer
|
|
283
|
+
"AguiEventNormalizer",
|
|
284
|
+
# Helpers
|
|
285
|
+
"MergeOptions",
|
|
286
|
+
######## Others ########
|
|
287
|
+
"ResourceNotExistError",
|
|
288
|
+
"ResourceAlreadyExistError",
|
|
289
|
+
"Config",
|
|
290
|
+
]
|
|
291
|
+
|
|
292
|
+
# Server 模块的所有导出
|
|
293
|
+
_SERVER_EXPORTS = {
|
|
294
|
+
"AgentRunServer",
|
|
295
|
+
"ServerConfig",
|
|
296
|
+
"ProtocolConfig",
|
|
297
|
+
"OpenAIProtocolConfig",
|
|
298
|
+
"AGUIProtocolConfig",
|
|
299
|
+
"AgentRequest",
|
|
300
|
+
"AgentEvent",
|
|
301
|
+
"AgentResult",
|
|
302
|
+
"Message",
|
|
303
|
+
"MessageRole",
|
|
304
|
+
"Tool",
|
|
305
|
+
"ToolCall",
|
|
306
|
+
"EventType",
|
|
307
|
+
"AgentEventItem",
|
|
308
|
+
"AgentResultItem",
|
|
309
|
+
"AgentReturnType",
|
|
310
|
+
"SyncAgentEventGenerator",
|
|
311
|
+
"SyncAgentResultGenerator",
|
|
312
|
+
"AsyncAgentEventGenerator",
|
|
313
|
+
"AsyncAgentResultGenerator",
|
|
314
|
+
"InvokeAgentHandler",
|
|
315
|
+
"AsyncInvokeAgentHandler",
|
|
316
|
+
"SyncInvokeAgentHandler",
|
|
317
|
+
"ProtocolHandler",
|
|
318
|
+
"BaseProtocolHandler",
|
|
319
|
+
"OpenAIProtocolHandler",
|
|
320
|
+
"AGUIProtocolHandler",
|
|
321
|
+
"AguiEventNormalizer",
|
|
322
|
+
"MergeOptions",
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
# 可选依赖包映射:安装命令 -> 导入错误的包名列表
|
|
326
|
+
# Optional dependency mapping: installation command -> list of import error package names
|
|
327
|
+
# 将使用相同安装命令的包合并到一起 / Group packages with the same installation command
|
|
328
|
+
_OPTIONAL_PACKAGES = {
|
|
329
|
+
"agentrun-sdk[server]": ["fastapi", "uvicorn", "ag_ui"],
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
def __getattr__(name: str):
|
|
334
|
+
"""延迟加载 server 模块的导出,避免可选依赖导致导入失败
|
|
335
|
+
|
|
336
|
+
当用户访问 server 相关的类时,才尝试导入 server 模块。
|
|
337
|
+
如果 server 可选依赖未安装,会抛出清晰的错误提示。
|
|
338
|
+
"""
|
|
339
|
+
if name in _SERVER_EXPORTS:
|
|
340
|
+
try:
|
|
341
|
+
from agentrun import server
|
|
342
|
+
|
|
343
|
+
return getattr(server, name)
|
|
344
|
+
except ImportError as e:
|
|
345
|
+
# 检查是否是缺少可选依赖导致的错误
|
|
346
|
+
error_str = str(e)
|
|
347
|
+
for install_cmd, package_names in _OPTIONAL_PACKAGES.items():
|
|
348
|
+
for package_name in package_names:
|
|
349
|
+
if package_name in error_str:
|
|
350
|
+
raise ImportError(
|
|
351
|
+
f"'{name}' requires the 'server' optional"
|
|
352
|
+
" dependencies. Install with: pip install"
|
|
353
|
+
f" {install_cmd}\nOriginal error: {e}"
|
|
354
|
+
) from e
|
|
355
|
+
# 其他导入错误继续抛出
|
|
356
|
+
raise
|
|
357
|
+
|
|
358
|
+
raise AttributeError(f"module '{__name__}' has no attribute '{name}'")
|