agentrun-inner-test 0.0.46__py3-none-any.whl → 0.0.56__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 +1 -1
- agentrun/agent_runtime/api/control.py +1 -1
- agentrun/credential/api/control.py +1 -1
- agentrun/integration/agentscope/__init__.py +2 -1
- agentrun/integration/agentscope/builtin.py +23 -0
- agentrun/integration/builtin/__init__.py +2 -0
- agentrun/integration/builtin/knowledgebase.py +137 -0
- agentrun/integration/crewai/__init__.py +2 -1
- agentrun/integration/crewai/builtin.py +23 -0
- agentrun/integration/google_adk/__init__.py +2 -1
- agentrun/integration/google_adk/builtin.py +23 -0
- agentrun/integration/langchain/__init__.py +2 -1
- agentrun/integration/langchain/builtin.py +23 -0
- agentrun/integration/langgraph/__init__.py +2 -1
- agentrun/integration/langgraph/builtin.py +23 -0
- agentrun/integration/pydantic_ai/__init__.py +2 -1
- agentrun/integration/pydantic_ai/builtin.py +23 -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/model/api/control.py +1 -1
- agentrun/sandbox/aio_sandbox.py +11 -4
- agentrun/sandbox/api/control.py +1 -1
- agentrun/sandbox/browser_sandbox.py +2 -2
- agentrun/sandbox/model.py +0 -13
- agentrun/toolset/api/control.py +1 -1
- agentrun/toolset/toolset.py +1 -0
- agentrun/utils/__data_api_async_template.py +1 -0
- agentrun/utils/config.py +12 -0
- agentrun/utils/control_api.py +27 -0
- agentrun/utils/data_api.py +1 -0
- {agentrun_inner_test-0.0.46.dist-info → agentrun_inner_test-0.0.56.dist-info}/METADATA +4 -2
- {agentrun_inner_test-0.0.46.dist-info → agentrun_inner_test-0.0.56.dist-info}/RECORD +43 -32
- {agentrun_inner_test-0.0.46.dist-info → agentrun_inner_test-0.0.56.dist-info}/WHEEL +0 -0
- {agentrun_inner_test-0.0.46.dist-info → agentrun_inner_test-0.0.56.dist-info}/licenses/LICENSE +0 -0
- {agentrun_inner_test-0.0.46.dist-info → agentrun_inner_test-0.0.56.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
"""KnowledgeBase 模型定义 / KnowledgeBase Model Definitions
|
|
2
|
+
|
|
3
|
+
定义知识库相关的数据模型和枚举。
|
|
4
|
+
Defines data models and enumerations related to knowledge bases.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from enum import Enum
|
|
8
|
+
from typing import Any, Dict, List, Optional, Union
|
|
9
|
+
|
|
10
|
+
from agentrun.utils.config import Config
|
|
11
|
+
from agentrun.utils.model import BaseModel, PageableInput
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class KnowledgeBaseProvider(str, Enum):
|
|
15
|
+
"""知识库提供商类型 / KnowledgeBase Provider Type"""
|
|
16
|
+
|
|
17
|
+
RAGFLOW = "ragflow"
|
|
18
|
+
"""RagFlow 知识库 / RagFlow knowledge base"""
|
|
19
|
+
BAILIAN = "bailian"
|
|
20
|
+
"""百炼知识库 / Bailian knowledge base"""
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# =============================================================================
|
|
24
|
+
# RagFlow 配置模型 / RagFlow Configuration Models
|
|
25
|
+
# =============================================================================
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RagFlowProviderSettings(BaseModel):
|
|
29
|
+
"""RagFlow 提供商设置 / RagFlow Provider Settings"""
|
|
30
|
+
|
|
31
|
+
base_url: str
|
|
32
|
+
"""RagFlow 服务地址,http或https开头,最后不能有/
|
|
33
|
+
RagFlow service URL, starting with http or https, no trailing slash"""
|
|
34
|
+
dataset_ids: List[str]
|
|
35
|
+
"""RagFlow 知识库 ID 列表,可以填写多个
|
|
36
|
+
List of RagFlow dataset IDs, multiple values allowed"""
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class RagFlowRetrieveSettings(BaseModel):
|
|
40
|
+
"""RagFlow 检索设置 / RagFlow Retrieve Settings"""
|
|
41
|
+
|
|
42
|
+
similarity_threshold: Optional[float] = None
|
|
43
|
+
"""相似度阈值 / Similarity threshold"""
|
|
44
|
+
vector_similarity_weight: Optional[float] = None
|
|
45
|
+
"""向量相似度权重 / Vector similarity weight"""
|
|
46
|
+
cross_languages: Optional[List[str]] = None
|
|
47
|
+
"""跨语言检索语言列表,如 ["English", "Chinese"]
|
|
48
|
+
Cross-language retrieval languages, e.g. ["English", "Chinese"]"""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
# =============================================================================
|
|
52
|
+
# Bailian 配置模型 / Bailian Configuration Models
|
|
53
|
+
# =============================================================================
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class BailianProviderSettings(BaseModel):
|
|
57
|
+
"""百炼提供商设置 / Bailian Provider Settings"""
|
|
58
|
+
|
|
59
|
+
workspace_id: str
|
|
60
|
+
"""百炼工作空间 ID / Bailian workspace ID"""
|
|
61
|
+
index_ids: List[str]
|
|
62
|
+
"""绑定的知识库索引列表 / List of bound knowledge base index IDs"""
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class BailianRetrieveSettings(BaseModel):
|
|
66
|
+
"""百炼检索设置 / Bailian Retrieve Settings"""
|
|
67
|
+
|
|
68
|
+
dense_similarity_top_k: Optional[int] = None
|
|
69
|
+
"""稠密向量检索返回的 Top K 数量 / Dense similarity top K"""
|
|
70
|
+
sparse_similarity_top_k: Optional[int] = None
|
|
71
|
+
"""稀疏向量检索返回的 Top K 数量 / Sparse similarity top K"""
|
|
72
|
+
rerank_min_score: Optional[float] = None
|
|
73
|
+
"""重排序最低分数阈值 / Rerank minimum score threshold"""
|
|
74
|
+
rerank_top_n: Optional[int] = None
|
|
75
|
+
"""重排序返回的 Top N 数量 / Rerank top N"""
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
# =============================================================================
|
|
79
|
+
# 联合类型定义 / Union Type Definitions
|
|
80
|
+
# =============================================================================
|
|
81
|
+
|
|
82
|
+
ProviderSettings = Union[
|
|
83
|
+
RagFlowProviderSettings, BailianProviderSettings, Dict[str, Any]
|
|
84
|
+
]
|
|
85
|
+
"""提供商设置联合类型 / Provider settings union type"""
|
|
86
|
+
|
|
87
|
+
RetrieveSettings = Union[
|
|
88
|
+
RagFlowRetrieveSettings, BailianRetrieveSettings, Dict[str, Any]
|
|
89
|
+
]
|
|
90
|
+
"""检索设置联合类型 / Retrieve settings union type"""
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
# =============================================================================
|
|
94
|
+
# 知识库属性模型 / KnowledgeBase Property Models
|
|
95
|
+
# =============================================================================
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class KnowledgeBaseMutableProps(BaseModel):
|
|
99
|
+
"""知识库可变属性 / KnowledgeBase Mutable Properties"""
|
|
100
|
+
|
|
101
|
+
description: Optional[str] = None
|
|
102
|
+
"""描述 / Description"""
|
|
103
|
+
credential_name: Optional[str] = None
|
|
104
|
+
"""凭证名称 / Credential name"""
|
|
105
|
+
provider_settings: Optional[Union[ProviderSettings, Dict[str, Any]]] = None
|
|
106
|
+
"""提供商设置 / Provider settings"""
|
|
107
|
+
retrieve_settings: Optional[Union[RetrieveSettings, Dict[str, Any]]] = None
|
|
108
|
+
"""检索设置 / Retrieve settings"""
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
class KnowledgeBaseImmutableProps(BaseModel):
|
|
112
|
+
"""知识库不可变属性 / KnowledgeBase Immutable Properties"""
|
|
113
|
+
|
|
114
|
+
knowledge_base_name: Optional[str] = None
|
|
115
|
+
"""知识库名称 / KnowledgeBase name"""
|
|
116
|
+
provider: Optional[Union[KnowledgeBaseProvider, str]] = None
|
|
117
|
+
"""提供商 / Provider"""
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
class KnowledgeBaseSystemProps(BaseModel):
|
|
121
|
+
"""知识库系统属性 / KnowledgeBase System Properties"""
|
|
122
|
+
|
|
123
|
+
knowledge_base_id: Optional[str] = None
|
|
124
|
+
"""知识库 ID / KnowledgeBase ID"""
|
|
125
|
+
created_at: Optional[str] = None
|
|
126
|
+
"""创建时间 / Created at"""
|
|
127
|
+
last_updated_at: Optional[str] = None
|
|
128
|
+
"""最后更新时间 / Last updated at"""
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
# =============================================================================
|
|
132
|
+
# API 输入输出模型 / API Input/Output Models
|
|
133
|
+
# =============================================================================
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class KnowledgeBaseCreateInput(
|
|
137
|
+
KnowledgeBaseImmutableProps, KnowledgeBaseMutableProps
|
|
138
|
+
):
|
|
139
|
+
"""知识库创建输入参数 / KnowledgeBase Create Input"""
|
|
140
|
+
|
|
141
|
+
knowledge_base_name: str # type: ignore
|
|
142
|
+
"""知识库名称(必填)/ KnowledgeBase name (required)"""
|
|
143
|
+
provider: Union[KnowledgeBaseProvider, str] # type: ignore
|
|
144
|
+
"""提供商(必填)/ Provider (required)"""
|
|
145
|
+
provider_settings: Union[ProviderSettings, Dict[str, Any]] # type: ignore
|
|
146
|
+
"""提供商设置(必填)/ Provider settings (required)"""
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class KnowledgeBaseUpdateInput(KnowledgeBaseMutableProps):
|
|
150
|
+
"""知识库更新输入参数 / KnowledgeBase Update Input"""
|
|
151
|
+
|
|
152
|
+
pass
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
class KnowledgeBaseListInput(PageableInput):
|
|
156
|
+
"""知识库列表查询输入参数 / KnowledgeBase List Input"""
|
|
157
|
+
|
|
158
|
+
provider: Optional[Union[KnowledgeBaseProvider, str]] = None
|
|
159
|
+
"""提供商 / Provider"""
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class KnowledgeBaseListOutput(BaseModel):
|
|
163
|
+
"""知识库列表查询输出 / KnowledgeBase List Output"""
|
|
164
|
+
|
|
165
|
+
knowledge_base_id: Optional[str] = None
|
|
166
|
+
"""知识库 ID / KnowledgeBase ID"""
|
|
167
|
+
knowledge_base_name: Optional[str] = None
|
|
168
|
+
"""知识库名称 / KnowledgeBase name"""
|
|
169
|
+
provider: Optional[Union[KnowledgeBaseProvider, str]] = None
|
|
170
|
+
"""提供商 / Provider"""
|
|
171
|
+
description: Optional[str] = None
|
|
172
|
+
"""描述 / Description"""
|
|
173
|
+
credential_name: Optional[str] = None
|
|
174
|
+
"""凭证名称 / Credential name"""
|
|
175
|
+
provider_settings: Optional[Union[ProviderSettings, Dict[str, Any]]] = None
|
|
176
|
+
"""提供商设置 / Provider settings"""
|
|
177
|
+
retrieve_settings: Optional[Union[RetrieveSettings, Dict[str, Any]]] = None
|
|
178
|
+
"""检索设置 / Retrieve settings"""
|
|
179
|
+
created_at: Optional[str] = None
|
|
180
|
+
"""创建时间 / Created at"""
|
|
181
|
+
last_updated_at: Optional[str] = None
|
|
182
|
+
"""最后更新时间 / Last updated at"""
|
|
183
|
+
|
|
184
|
+
async def to_knowledge_base_async(self, config: Optional[Config] = None):
|
|
185
|
+
"""转换为知识库对象(异步)/ Convert to KnowledgeBase object (async)
|
|
186
|
+
|
|
187
|
+
Args:
|
|
188
|
+
config: 配置 / Configuration
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
KnowledgeBase: 知识库对象 / KnowledgeBase object
|
|
192
|
+
"""
|
|
193
|
+
from .client import KnowledgeBaseClient
|
|
194
|
+
|
|
195
|
+
return await KnowledgeBaseClient(config).get_async(
|
|
196
|
+
self.knowledge_base_name or "", config=config
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
def to_knowledge_base(self, config: Optional[Config] = None):
|
|
200
|
+
"""转换为知识库对象(同步)/ Convert to KnowledgeBase object (sync)
|
|
201
|
+
|
|
202
|
+
Args:
|
|
203
|
+
config: 配置 / Configuration
|
|
204
|
+
|
|
205
|
+
Returns:
|
|
206
|
+
KnowledgeBase: 知识库对象 / KnowledgeBase object
|
|
207
|
+
"""
|
|
208
|
+
from .client import KnowledgeBaseClient
|
|
209
|
+
|
|
210
|
+
return KnowledgeBaseClient(config).get(
|
|
211
|
+
self.knowledge_base_name or "", config=config
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
class RetrieveInput(BaseModel):
|
|
216
|
+
"""知识库检索输入参数 / KnowledgeBase Retrieve Input
|
|
217
|
+
|
|
218
|
+
用于多知识库检索的输入参数。
|
|
219
|
+
Input parameters for multi-knowledge base retrieval.
|
|
220
|
+
"""
|
|
221
|
+
|
|
222
|
+
knowledge_base_names: List[str]
|
|
223
|
+
"""知识库名称列表 / List of knowledge base names"""
|
|
224
|
+
query: str
|
|
225
|
+
"""查询文本 / Query text"""
|
|
226
|
+
|
|
227
|
+
knowledge_base_id: Optional[str] = None
|
|
228
|
+
"""知识库 ID / KnowledgeBase ID"""
|
|
229
|
+
knowledge_base_name: Optional[str] = None
|
|
230
|
+
"""知识库名称 / KnowledgeBase name"""
|
|
231
|
+
provider: Optional[str] = None
|
|
232
|
+
"""提供商 / Provider"""
|
|
233
|
+
description: Optional[str] = None
|
|
234
|
+
"""描述 / Description"""
|
|
235
|
+
credential_name: Optional[str] = None
|
|
236
|
+
"""凭证名称 / Credential name"""
|
|
237
|
+
created_at: Optional[str] = None
|
|
238
|
+
"""创建时间 / Created at"""
|
|
239
|
+
last_updated_at: Optional[str] = None
|
|
240
|
+
"""最后更新时间 / Last updated at"""
|
|
241
|
+
|
|
242
|
+
async def to_knowledge_base_async(self, config: Optional[Config] = None):
|
|
243
|
+
"""转换为知识库对象(异步)/ Convert to KnowledgeBase object (async)
|
|
244
|
+
|
|
245
|
+
Args:
|
|
246
|
+
config: 配置 / Configuration
|
|
247
|
+
|
|
248
|
+
Returns:
|
|
249
|
+
KnowledgeBase: 知识库对象 / KnowledgeBase object
|
|
250
|
+
"""
|
|
251
|
+
from .client import KnowledgeBaseClient
|
|
252
|
+
|
|
253
|
+
return await KnowledgeBaseClient(config).get_async(
|
|
254
|
+
self.knowledge_base_name or "", config=config
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
def to_knowledge_base(self, config: Optional[Config] = None):
|
|
258
|
+
"""转换为知识库对象(同步)/ Convert to KnowledgeBase object (sync)
|
|
259
|
+
|
|
260
|
+
Args:
|
|
261
|
+
config: 配置 / Configuration
|
|
262
|
+
|
|
263
|
+
Returns:
|
|
264
|
+
KnowledgeBase: 知识库对象 / KnowledgeBase object
|
|
265
|
+
"""
|
|
266
|
+
from .client import KnowledgeBaseClient
|
|
267
|
+
|
|
268
|
+
return KnowledgeBaseClient(config).get(
|
|
269
|
+
self.knowledge_base_name or "", config=config
|
|
270
|
+
)
|
agentrun/model/api/control.py
CHANGED
|
@@ -32,7 +32,7 @@ from alibabacloud_agentrun20250910.models import (
|
|
|
32
32
|
)
|
|
33
33
|
from alibabacloud_tea_openapi.exceptions._client import ClientException
|
|
34
34
|
from alibabacloud_tea_openapi.exceptions._server import ServerException
|
|
35
|
-
from
|
|
35
|
+
from darabonba.runtime import RuntimeOptions
|
|
36
36
|
import pydash
|
|
37
37
|
|
|
38
38
|
from agentrun.utils.config import Config
|
agentrun/sandbox/aio_sandbox.py
CHANGED
|
@@ -763,8 +763,7 @@ class AioSandbox(Sandbox):
|
|
|
763
763
|
|
|
764
764
|
except Exception as e:
|
|
765
765
|
logger.error(
|
|
766
|
-
f"[{retry_count}/{max_retries}] Health check failed
|
|
767
|
-
f" retrying: {e}"
|
|
766
|
+
f"[{retry_count}/{max_retries}] Health check failed: {e}"
|
|
768
767
|
)
|
|
769
768
|
|
|
770
769
|
if retry_count < max_retries:
|
|
@@ -806,8 +805,12 @@ class AioSandbox(Sandbox):
|
|
|
806
805
|
"""Check sandbox health status (async)."""
|
|
807
806
|
return await self.data_api.check_health_async()
|
|
808
807
|
|
|
808
|
+
# ========================================
|
|
809
|
+
# Browser API Methods
|
|
810
|
+
# ========================================
|
|
811
|
+
|
|
809
812
|
def check_health(self):
|
|
810
|
-
"""Check sandbox health status (
|
|
813
|
+
"""Check sandbox health status (async)."""
|
|
811
814
|
return self.data_api.check_health()
|
|
812
815
|
|
|
813
816
|
# ========================================
|
|
@@ -868,8 +871,12 @@ class AioSandbox(Sandbox):
|
|
|
868
871
|
"""Delete a recording file (async)."""
|
|
869
872
|
return await self.data_api.delete_recording_async(filename)
|
|
870
873
|
|
|
874
|
+
# ========================================
|
|
875
|
+
# Code Interpreter API Properties
|
|
876
|
+
# ========================================
|
|
877
|
+
|
|
871
878
|
def delete_recording(self, filename: str):
|
|
872
|
-
"""Delete a recording file (
|
|
879
|
+
"""Delete a recording file (async)."""
|
|
873
880
|
return self.data_api.delete_recording(filename)
|
|
874
881
|
|
|
875
882
|
# ========================================
|
agentrun/sandbox/api/control.py
CHANGED
|
@@ -30,7 +30,7 @@ from alibabacloud_agentrun20250910.models import (
|
|
|
30
30
|
)
|
|
31
31
|
from alibabacloud_tea_openapi.exceptions._client import ClientException
|
|
32
32
|
from alibabacloud_tea_openapi.exceptions._server import ServerException
|
|
33
|
-
from
|
|
33
|
+
from darabonba.runtime import RuntimeOptions
|
|
34
34
|
import pydash
|
|
35
35
|
|
|
36
36
|
from agentrun.utils.config import Config
|
|
@@ -51,7 +51,7 @@ class BrowserSandbox(Sandbox):
|
|
|
51
51
|
|
|
52
52
|
logger.debug(
|
|
53
53
|
f"[{retry_count}/{max_retries}] Health status:"
|
|
54
|
-
f" {health.get('code')} {
|
|
54
|
+
f" {health.get('code')} {health.get('message')}",
|
|
55
55
|
)
|
|
56
56
|
|
|
57
57
|
except Exception as e:
|
|
@@ -88,7 +88,7 @@ class BrowserSandbox(Sandbox):
|
|
|
88
88
|
|
|
89
89
|
logger.debug(
|
|
90
90
|
f"[{retry_count}/{max_retries}] Health status:"
|
|
91
|
-
f" {health.get('code')} {
|
|
91
|
+
f" {health.get('code')} {health.get('message')}",
|
|
92
92
|
)
|
|
93
93
|
|
|
94
94
|
except Exception as e:
|
agentrun/sandbox/model.py
CHANGED
|
@@ -337,19 +337,6 @@ class TemplateInput(BaseModel):
|
|
|
337
337
|
f"the current disk size is {self.disk_size}"
|
|
338
338
|
)
|
|
339
339
|
|
|
340
|
-
if (
|
|
341
|
-
self.template_type == TemplateType.CODE_INTERPRETER
|
|
342
|
-
or self.template_type == TemplateType.AIO
|
|
343
|
-
):
|
|
344
|
-
if (
|
|
345
|
-
self.network_configuration
|
|
346
|
-
and self.network_configuration.network_mode
|
|
347
|
-
== TemplateNetworkMode.PRIVATE
|
|
348
|
-
):
|
|
349
|
-
raise ValueError(
|
|
350
|
-
"when template_type is CODE_INTERPRETER,"
|
|
351
|
-
"network_mode cannot be PRIVATE"
|
|
352
|
-
)
|
|
353
340
|
return self
|
|
354
341
|
|
|
355
342
|
|
agentrun/toolset/api/control.py
CHANGED
|
@@ -21,7 +21,7 @@ from alibabacloud_devs20230714.models import (
|
|
|
21
21
|
)
|
|
22
22
|
from alibabacloud_tea_openapi.exceptions._client import ClientException
|
|
23
23
|
from alibabacloud_tea_openapi.exceptions._server import ServerException
|
|
24
|
-
from
|
|
24
|
+
from darabonba.runtime import RuntimeOptions
|
|
25
25
|
import pydash
|
|
26
26
|
|
|
27
27
|
from agentrun.utils.config import Config
|
agentrun/toolset/toolset.py
CHANGED
agentrun/utils/config.py
CHANGED
|
@@ -61,6 +61,7 @@ class Config:
|
|
|
61
61
|
"_control_endpoint",
|
|
62
62
|
"_data_endpoint",
|
|
63
63
|
"_devs_endpoint",
|
|
64
|
+
"_bailian_endpoint",
|
|
64
65
|
"_headers",
|
|
65
66
|
"__weakref__",
|
|
66
67
|
)
|
|
@@ -78,6 +79,7 @@ class Config:
|
|
|
78
79
|
control_endpoint: Optional[str] = None,
|
|
79
80
|
data_endpoint: Optional[str] = None,
|
|
80
81
|
devs_endpoint: Optional[str] = None,
|
|
82
|
+
bailian_endpoint: Optional[str] = None,
|
|
81
83
|
headers: Optional[Dict[str, str]] = None,
|
|
82
84
|
) -> None:
|
|
83
85
|
"""初始化配置 / Initialize configuration
|
|
@@ -135,6 +137,8 @@ class Config:
|
|
|
135
137
|
data_endpoint = get_env_with_default("", "AGENTRUN_DATA_ENDPOINT")
|
|
136
138
|
if devs_endpoint is None:
|
|
137
139
|
devs_endpoint = get_env_with_default("", "DEVS_ENDPOINT")
|
|
140
|
+
if bailian_endpoint is None:
|
|
141
|
+
bailian_endpoint = get_env_with_default("", "BAILIAN_ENDPOINT")
|
|
138
142
|
|
|
139
143
|
self._access_key_id = access_key_id
|
|
140
144
|
self._access_key_secret = access_key_secret
|
|
@@ -147,6 +151,7 @@ class Config:
|
|
|
147
151
|
self._control_endpoint = control_endpoint
|
|
148
152
|
self._data_endpoint = data_endpoint
|
|
149
153
|
self._devs_endpoint = devs_endpoint
|
|
154
|
+
self._bailian_endpoint = bailian_endpoint
|
|
150
155
|
self._headers = headers or {}
|
|
151
156
|
|
|
152
157
|
@classmethod
|
|
@@ -253,6 +258,13 @@ class Config:
|
|
|
253
258
|
|
|
254
259
|
return f"https://devs.{self.get_region_id()}.aliyuncs.com"
|
|
255
260
|
|
|
261
|
+
def get_bailian_endpoint(self) -> str:
|
|
262
|
+
"""获取百炼端点 / Get Bailian endpoint"""
|
|
263
|
+
if self._bailian_endpoint:
|
|
264
|
+
return self._bailian_endpoint
|
|
265
|
+
|
|
266
|
+
return "https://bailian.cn-beijing.aliyuncs.com"
|
|
267
|
+
|
|
256
268
|
def get_headers(self) -> Dict[str, str]:
|
|
257
269
|
"""获取自定义请求头"""
|
|
258
270
|
return self._headers or {}
|
agentrun/utils/control_api.py
CHANGED
|
@@ -7,6 +7,7 @@ This module defines the base class for control API.
|
|
|
7
7
|
from typing import Optional
|
|
8
8
|
|
|
9
9
|
from alibabacloud_agentrun20250910.client import Client as AgentRunClient
|
|
10
|
+
from alibabacloud_bailian20231229.client import Client as BailianClient
|
|
10
11
|
from alibabacloud_devs20230714.client import Client as DevsClient
|
|
11
12
|
from alibabacloud_tea_openapi import utils_models as open_api_util_models
|
|
12
13
|
|
|
@@ -76,3 +77,29 @@ class ControlAPI:
|
|
|
76
77
|
read_timeout=cfg.get_read_timeout(), # type: ignore
|
|
77
78
|
)
|
|
78
79
|
)
|
|
80
|
+
|
|
81
|
+
def _get_bailian_client(
|
|
82
|
+
self, config: Optional[Config] = None
|
|
83
|
+
) -> "BailianClient":
|
|
84
|
+
"""
|
|
85
|
+
获取百炼 API 客户端实例 / Get Bailian API client instance
|
|
86
|
+
|
|
87
|
+
Returns:
|
|
88
|
+
BailianClient: 百炼 API 客户端实例 / Bailian API client instance
|
|
89
|
+
"""
|
|
90
|
+
|
|
91
|
+
cfg = Config.with_configs(self.config, config)
|
|
92
|
+
endpoint = cfg.get_bailian_endpoint()
|
|
93
|
+
if endpoint.startswith("http://") or endpoint.startswith("https://"):
|
|
94
|
+
endpoint = endpoint.split("://", 1)[1]
|
|
95
|
+
return BailianClient(
|
|
96
|
+
open_api_util_models.Config(
|
|
97
|
+
access_key_id=cfg.get_access_key_id(),
|
|
98
|
+
access_key_secret=cfg.get_access_key_secret(),
|
|
99
|
+
security_token=cfg.get_security_token(),
|
|
100
|
+
region_id=cfg.get_region_id(),
|
|
101
|
+
endpoint=endpoint,
|
|
102
|
+
connect_timeout=cfg.get_timeout(), # type: ignore
|
|
103
|
+
read_timeout=cfg.get_read_timeout(), # type: ignore
|
|
104
|
+
)
|
|
105
|
+
)
|
agentrun/utils/data_api.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: agentrun-inner-test
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.56
|
|
4
4
|
Summary: Alibaba Cloud Agent Run SDK
|
|
5
5
|
Requires-Python: >=3.10
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -13,7 +13,7 @@ Requires-Dist: typing-extensions>=4.15.0
|
|
|
13
13
|
Requires-Dist: litellm>=1.79.3
|
|
14
14
|
Requires-Dist: alibabacloud-devs20230714>=2.4.1
|
|
15
15
|
Requires-Dist: pydash>=8.0.5
|
|
16
|
-
Requires-Dist: alibabacloud-agentrun20250910>=5.0.
|
|
16
|
+
Requires-Dist: alibabacloud-agentrun20250910>=5.0.1
|
|
17
17
|
Requires-Dist: alibabacloud_tea_openapi>=0.4.2
|
|
18
18
|
Provides-Extra: server
|
|
19
19
|
Requires-Dist: fastapi>=0.104.0; extra == "server"
|
|
@@ -34,6 +34,8 @@ Provides-Extra: playwright
|
|
|
34
34
|
Requires-Dist: playwright>=1.40.0; extra == "playwright"
|
|
35
35
|
Provides-Extra: mcp
|
|
36
36
|
Requires-Dist: mcp>=1.21.2; python_version >= "3.10" and extra == "mcp"
|
|
37
|
+
Provides-Extra: knowledgebase
|
|
38
|
+
Requires-Dist: alibabacloud_bailian20231229>=2.6.2; extra == "knowledgebase"
|
|
37
39
|
Dynamic: license-file
|
|
38
40
|
|
|
39
41
|
# AgentRun Python SDK
|