bohr-agent-sdk 0.1.101__py3-none-any.whl → 0.1.103__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.
- bohr_agent_sdk-0.1.103.dist-info/METADATA +292 -0
- bohr_agent_sdk-0.1.103.dist-info/RECORD +80 -0
- dp/agent/cli/cli.py +126 -25
- dp/agent/cli/templates/__init__.py +1 -0
- dp/agent/cli/templates/calculation/simple.py.template +15 -0
- dp/agent/cli/templates/device/tescan_device.py.template +158 -0
- dp/agent/cli/templates/main.py.template +67 -0
- dp/agent/cli/templates/ui/__init__.py +1 -0
- dp/agent/cli/templates/ui/api/__init__.py +1 -0
- dp/agent/cli/templates/ui/api/config.py +32 -0
- dp/agent/cli/templates/ui/api/constants.py +61 -0
- dp/agent/cli/templates/ui/api/debug.py +257 -0
- dp/agent/cli/templates/ui/api/files.py +469 -0
- dp/agent/cli/templates/ui/api/files_upload.py +115 -0
- dp/agent/cli/templates/ui/api/files_user.py +50 -0
- dp/agent/cli/templates/ui/api/messages.py +161 -0
- dp/agent/cli/templates/ui/api/projects.py +146 -0
- dp/agent/cli/templates/ui/api/sessions.py +93 -0
- dp/agent/cli/templates/ui/api/utils.py +161 -0
- dp/agent/cli/templates/ui/api/websocket.py +184 -0
- dp/agent/cli/templates/ui/config/__init__.py +1 -0
- dp/agent/cli/templates/ui/config/agent_config.py +257 -0
- dp/agent/cli/templates/ui/frontend/index.html +13 -0
- dp/agent/cli/templates/ui/frontend/package.json +46 -0
- dp/agent/cli/templates/ui/frontend/tsconfig.json +26 -0
- dp/agent/cli/templates/ui/frontend/tsconfig.node.json +10 -0
- dp/agent/cli/templates/ui/frontend/ui-static/assets/index-DdAmKhul.js +105 -0
- dp/agent/cli/templates/ui/frontend/ui-static/assets/index-DfN2raU9.css +1 -0
- dp/agent/cli/templates/ui/frontend/ui-static/index.html +14 -0
- dp/agent/cli/templates/ui/frontend/vite.config.ts +37 -0
- dp/agent/cli/templates/ui/scripts/build_ui.py +56 -0
- dp/agent/cli/templates/ui/server/__init__.py +0 -0
- dp/agent/cli/templates/ui/server/app.py +98 -0
- dp/agent/cli/templates/ui/server/connection.py +210 -0
- dp/agent/cli/templates/ui/server/file_watcher.py +85 -0
- dp/agent/cli/templates/ui/server/middleware.py +43 -0
- dp/agent/cli/templates/ui/server/models.py +53 -0
- dp/agent/cli/templates/ui/server/session_manager.py +1158 -0
- dp/agent/cli/templates/ui/server/user_files.py +85 -0
- dp/agent/cli/templates/ui/server/utils.py +50 -0
- dp/agent/cli/templates/ui/test_download.py +98 -0
- dp/agent/cli/templates/ui/ui_utils.py +260 -0
- dp/agent/cli/templates/ui/websocket-server.py +87 -0
- dp/agent/server/storage/http_storage.py +1 -1
- bohr_agent_sdk-0.1.101.dist-info/METADATA +0 -224
- bohr_agent_sdk-0.1.101.dist-info/RECORD +0 -40
- {bohr_agent_sdk-0.1.101.dist-info → bohr_agent_sdk-0.1.103.dist-info}/WHEEL +0 -0
- {bohr_agent_sdk-0.1.101.dist-info → bohr_agent_sdk-0.1.103.dist-info}/entry_points.txt +0 -0
- {bohr_agent_sdk-0.1.101.dist-info → bohr_agent_sdk-0.1.103.dist-info}/top_level.txt +0 -0
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: bohr-agent-sdk
|
|
3
|
-
Version: 0.1.101
|
|
4
|
-
Summary: SDK for scientific agents
|
|
5
|
-
Home-page: https://github.com/dptech-corp/bohr-agent-sdk/
|
|
6
|
-
Author: DP Technology
|
|
7
|
-
Maintainer-email: liupeng <liupeng@dp.tech>, zjgemi <liuxzj@dp.tech>
|
|
8
|
-
License: MIT
|
|
9
|
-
Project-URL: Homepage, https://github.com/dptech-corp/bohr-agent-sdk
|
|
10
|
-
Project-URL: repository, https://github.com/dptech-corp/bohr-agent-sdk
|
|
11
|
-
Project-URL: Bug Reports, https://github.com/dptech-corp/bohr-agent-sdk/issues
|
|
12
|
-
Keywords: agent SDK,AI for science
|
|
13
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
-
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
-
Requires-Python: >=3.10
|
|
20
|
-
Description-Content-Type: text/markdown
|
|
21
|
-
Requires-Dist: click>=8.0.0
|
|
22
|
-
Requires-Dist: mcp
|
|
23
|
-
Requires-Dist: python-dotenv>=1.0.0
|
|
24
|
-
Requires-Dist: typing-extensions>=4.8.0
|
|
25
|
-
Requires-Dist: dpdispatcher>=0.6.8
|
|
26
|
-
Requires-Dist: lbg>=1.2.29
|
|
27
|
-
Requires-Dist: jsonpickle>=3.0.3
|
|
28
|
-
Requires-Dist: psutil>=5.9.6
|
|
29
|
-
Requires-Dist: paho-mqtt>=2.1.0
|
|
30
|
-
Requires-Dist: redis>=6.2.0
|
|
31
|
-
Requires-Dist: twine>=6.1.0
|
|
32
|
-
Requires-Dist: build>=1.2.2.post1
|
|
33
|
-
Provides-Extra: device
|
|
34
|
-
Requires-Dist: pywinauto-recorder>=0.1.0; extra == "device"
|
|
35
|
-
Provides-Extra: cloud
|
|
36
|
-
Requires-Dist: paho-mqtt>=1.6.1; extra == "cloud"
|
|
37
|
-
Requires-Dist: redis>=5.0.1; extra == "cloud"
|
|
38
|
-
Requires-Dist: aiohttp>=3.9.1; extra == "cloud"
|
|
39
|
-
Provides-Extra: dev
|
|
40
|
-
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
41
|
-
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
42
|
-
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
43
|
-
Requires-Dist: black>=23.11.0; extra == "dev"
|
|
44
|
-
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
45
|
-
Requires-Dist: mypy>=1.7.0; extra == "dev"
|
|
46
|
-
Requires-Dist: pylint>=3.0.0; extra == "dev"
|
|
47
|
-
Provides-Extra: docs
|
|
48
|
-
Requires-Dist: sphinx>=7.2.0; extra == "docs"
|
|
49
|
-
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
50
|
-
Provides-Extra: all
|
|
51
|
-
Requires-Dist: bohr-agent-sdk[bohrium,cloud,dev,device,dispatcher,docs]; extra == "all"
|
|
52
|
-
Dynamic: home-page
|
|
53
|
-
Dynamic: requires-python
|
|
54
|
-
|
|
55
|
-
# Bohrium Science Agent SDK
|
|
56
|
-
|
|
57
|
-
这是DP Tech的Bohrium Science Agent SDK,提供了一个命令行工具dp-agent,用于管理科学计算任务。同时提供了Python SDK用于开发自定义的科学计算应用。
|
|
58
|
-
|
|
59
|
-
## 安装
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
pip install bohr-agent-sdk -i https://pypi.org/simple --upgrade
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## CLI 使用方法
|
|
66
|
-
|
|
67
|
-
安装后,您可以使用以下命令:
|
|
68
|
-
|
|
69
|
-
### 获取资源
|
|
70
|
-
|
|
71
|
-
```bash
|
|
72
|
-
# 获取基础代码结构
|
|
73
|
-
dp-agent fetch scaffolding --type=calculation/device
|
|
74
|
-
|
|
75
|
-
# 获取配置文件
|
|
76
|
-
dp-agent fetch config
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
`fetch config` 命令会下载 .env 配置文件并替换部分动态变量,如 MQTT_DEVICE_ID。
|
|
80
|
-
注意:出于安全考虑,此功能仅在内网环境可用。其他环境需要手动配置。
|
|
81
|
-
|
|
82
|
-
### 运行命令
|
|
83
|
-
|
|
84
|
-
```bash
|
|
85
|
-
# 运行实验环境
|
|
86
|
-
dp-agent run tool device
|
|
87
|
-
|
|
88
|
-
# 运行云环境
|
|
89
|
-
dp-agent run tool cloud
|
|
90
|
-
|
|
91
|
-
# 运行计算环境
|
|
92
|
-
dp-agent run tool calculation
|
|
93
|
-
|
|
94
|
-
# 运行代理
|
|
95
|
-
dp-agent run agent
|
|
96
|
-
|
|
97
|
-
# 调试模式
|
|
98
|
-
dp-agent run debug
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
## SDK 快速入门
|
|
102
|
-
|
|
103
|
-
Bohrium Science Agent SDK 提供了两种主要的开发模式:实验室模式(Lab)和云模式(Cloud)。
|
|
104
|
-
|
|
105
|
-
### 基础结构
|
|
106
|
-
|
|
107
|
-
安装完成并运行 `dp-agent fetch scaffolding` 后,您将获得以下基础项目结构:
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
your-project/
|
|
111
|
-
├── lab/ # 实验室模式相关代码
|
|
112
|
-
│ ├── __init__.py
|
|
113
|
-
│ └── tescan_device.py # 设备控制示例
|
|
114
|
-
├── cloud/ # 云模式相关代码
|
|
115
|
-
│ └── __init__.py
|
|
116
|
-
└── main.py # 主程序入口
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
### 实验室模式开发
|
|
120
|
-
|
|
121
|
-
实验室模式主要用于控制本地实验设备。以下是一个基于 Tescan 设备的示例:
|
|
122
|
-
|
|
123
|
-
```python
|
|
124
|
-
from typing import Dict, TypedDict
|
|
125
|
-
from dp.agent.device.device import Device, action, BaseParams, SuccessResult
|
|
126
|
-
|
|
127
|
-
class TakePictureParams(BaseParams):
|
|
128
|
-
"""拍照参数"""
|
|
129
|
-
horizontal_width: str
|
|
130
|
-
|
|
131
|
-
class PictureData(TypedDict):
|
|
132
|
-
"""照片数据"""
|
|
133
|
-
image_id: str
|
|
134
|
-
|
|
135
|
-
class PictureResult(SuccessResult):
|
|
136
|
-
"""拍照结果"""
|
|
137
|
-
data: PictureData
|
|
138
|
-
|
|
139
|
-
class MyDevice(Device):
|
|
140
|
-
device_name = "my_device"
|
|
141
|
-
|
|
142
|
-
@action("take_picture")
|
|
143
|
-
def take_picture(self, params: TakePictureParams) -> PictureResult:
|
|
144
|
-
"""拍照动作
|
|
145
|
-
|
|
146
|
-
Args:
|
|
147
|
-
params: 拍照参数
|
|
148
|
-
- horizontal_width: 图片水平宽度
|
|
149
|
-
"""
|
|
150
|
-
hw = params.get("horizontal_width", "default")
|
|
151
|
-
return PictureResult(
|
|
152
|
-
message=f"Picture taken with {self.device_name}",
|
|
153
|
-
data={"image_id": "image_123"}
|
|
154
|
-
)
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
### 云端开发
|
|
158
|
-
|
|
159
|
-
云模式基于 MCP (Message Control Protocol) 实现,用于处理远程设备控制和任务调度。register_mcp_tools 通过 python 的自省和反射机制实现了设备控制的自动注册,无需重复实现操作定义。
|
|
160
|
-
以下展示如何创建设备并注册到 MCP 服务器:
|
|
161
|
-
|
|
162
|
-
```python
|
|
163
|
-
"""
|
|
164
|
-
Example of using the bohr-agent-sdk cloud functionality.
|
|
165
|
-
"""
|
|
166
|
-
import signal
|
|
167
|
-
import sys
|
|
168
|
-
from dp.agent.cloud import mcp, get_mqtt_cloud_instance
|
|
169
|
-
from dp.agent.device.device import TescanDevice, register_mcp_tools
|
|
170
|
-
|
|
171
|
-
def signal_handler(sig, frame):
|
|
172
|
-
"""Handle SIGINT signal to gracefully shutdown."""
|
|
173
|
-
print("Shutting down...")
|
|
174
|
-
get_mqtt_cloud_instance().stop()
|
|
175
|
-
sys.exit(0)
|
|
176
|
-
|
|
177
|
-
def main():
|
|
178
|
-
"""Start the cloud services."""
|
|
179
|
-
print("Starting Tescan Device Twin Cloud Services...")
|
|
180
|
-
|
|
181
|
-
# Register signal handler
|
|
182
|
-
signal.signal(signal.SIGINT, signal_handler)
|
|
183
|
-
|
|
184
|
-
# Create device instance
|
|
185
|
-
device = TescanDevice(mcp, device)
|
|
186
|
-
|
|
187
|
-
# Register device tools
|
|
188
|
-
register_mcp_tools(device)
|
|
189
|
-
|
|
190
|
-
# Start MCP server
|
|
191
|
-
print("Starting MCP server...")
|
|
192
|
-
mcp.run(transport="sse")
|
|
193
|
-
|
|
194
|
-
if __name__ == "__main__":
|
|
195
|
-
main()
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
### 配置说明
|
|
200
|
-
|
|
201
|
-
在 `.env` 文件中配置必要的环境变量:
|
|
202
|
-
|
|
203
|
-
```
|
|
204
|
-
MQTT_INSTANCE_ID=your_instance_id
|
|
205
|
-
MQTT_ENDPOINT=your_endpoint
|
|
206
|
-
MQTT_DEVICE_ID=your_device_id
|
|
207
|
-
MQTT_GROUP_ID=your_group_id
|
|
208
|
-
MQTT_AK=your_access_key
|
|
209
|
-
MQTT_SK=your_secret_key
|
|
210
|
-
```
|
|
211
|
-
|
|
212
|
-
### 主要功能
|
|
213
|
-
|
|
214
|
-
- 设备控制接口(Lab模式)
|
|
215
|
-
- 设备初始化
|
|
216
|
-
- 命令执行
|
|
217
|
-
- 状态监控
|
|
218
|
-
|
|
219
|
-
- 云端任务处理(Cloud模式)
|
|
220
|
-
- 任务队列管理
|
|
221
|
-
- 计算资源调度
|
|
222
|
-
- 结果回传
|
|
223
|
-
|
|
224
|
-
更详细的API文档请参考代码中的注释。
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
dp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
dp/agent/__init__.py,sha256=4kwF1khocxEkqJjnVhBV5cCsWkR_MBGrUthuHk44pT8,153
|
|
3
|
-
dp/agent/adapter/adk/__init__.py,sha256=mxX2SxGgDjwQ7WjfKMw9mQkq4ddl8XlCA6gnUinCW0w,493
|
|
4
|
-
dp/agent/adapter/adk/storage_artifact_service.py,sha256=Hd1CmEB8HgEz3x_riHVSSmYdw6W2bDYYa3c5ySCqmCE,5414
|
|
5
|
-
dp/agent/adapter/adk/utils.py,sha256=Hf6zZOmNi0YSI9t5acmR5kzowWaYr-UfyPiN8fefPkI,7359
|
|
6
|
-
dp/agent/adapter/adk/client/__init__.py,sha256=F1xfFNa4ZG8jV9adeGI2D3YBiSX-5RkvqEdTqNdJce4,209
|
|
7
|
-
dp/agent/adapter/adk/client/calculation_mcp_tool.py,sha256=8_uBP12SLaYUiQL6c0vysVsePEZS_r0YMogvW93ZFHo,12188
|
|
8
|
-
dp/agent/adapter/camel/__init__.py,sha256=RN1NhdmsJyN43fTxTXFld4UKZksjpSV0b2QvFn5gK7o,77
|
|
9
|
-
dp/agent/adapter/camel/client/__init__.py,sha256=ld-r0_WsZLFv6yyrmxjWmR8JgnrQzOw4fX0hwVHzciY,93
|
|
10
|
-
dp/agent/adapter/camel/client/calculation_mcp_client.py,sha256=JZZUYYfMgXvHzK4f6IJp-ia33wn3aYZqDSDVa5yKtdc,1860
|
|
11
|
-
dp/agent/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
dp/agent/cli/cli.py,sha256=dm2_qH_1Dzlc3IH-BBwEPDJcJrew58AV0dNzwEMn6cY,8219
|
|
13
|
-
dp/agent/cloud/__init__.py,sha256=e16ymCZX2f-S8DyGB5jSK8gnQqVObRIsvtLXLALIKxQ,441
|
|
14
|
-
dp/agent/cloud/main.py,sha256=5QIEjpZ1RxWnR8wyLf-vlgz1bn9oOnxCYn158LBaLN4,727
|
|
15
|
-
dp/agent/cloud/mcp.py,sha256=tsAwC3doVMLYr6Oh8PxVqF-qCygYkDZJTIhoF_h8eGQ,4537
|
|
16
|
-
dp/agent/cloud/mqtt.py,sha256=e8Dz1Wffzjj8V0Xrr6LukwfdiPrj9VsVXatD3u4NpkQ,23036
|
|
17
|
-
dp/agent/device/__init__.py,sha256=G3i0zG7orCgMcXBEEhm7dufDeKY0QgFdQinOjDh8zSg,400
|
|
18
|
-
dp/agent/device/mqtt_device_twin.py,sha256=xHQFi2WQxrL5KqSEU2DeRSBiaPT5FLXvgszinyanQ_Q,8671
|
|
19
|
-
dp/agent/device/device/__init__.py,sha256=w7_1S16S1vWUq0RGl0GFgjq2vFkc5oNvy8cQTnvPm24,319
|
|
20
|
-
dp/agent/device/device/device.py,sha256=9ZRIJth-4qMO-i-u_b_cO3d6a4eTbTQjPaxFsV_zEkc,9643
|
|
21
|
-
dp/agent/device/device/types.py,sha256=JuxB-hjf1CjjvfBxCLwRAXVFlYS-nPEdiJpBWLFVCzo,1924
|
|
22
|
-
dp/agent/server/__init__.py,sha256=rckaYd8pbYyB4ENEhgjXKeGMXjdnrgcJpdM1gu5u1Wc,508
|
|
23
|
-
dp/agent/server/calculation_mcp_server.py,sha256=eClRP7A-t5hMGyTh81KC3GAKjSPNJIylOrOKyzqwo8o,11459
|
|
24
|
-
dp/agent/server/preprocessor.py,sha256=XUWu7QOwo_sIDMYS2b1OTrM33EXEVH_73vk-ju1Ok8A,1264
|
|
25
|
-
dp/agent/server/utils.py,sha256=8jgYZEW4XBp86AF2Km6QkwHltBmrnS-soTpHov7ZEJw,4501
|
|
26
|
-
dp/agent/server/executor/__init__.py,sha256=s95M5qKQk39Yi9qaVJZhk_nfj54quSf7EDghR3OCFUA,248
|
|
27
|
-
dp/agent/server/executor/base_executor.py,sha256=EFJBsYVYAvuRbiLAbLOwLTw3h7ScjN025xnSP4uJHrQ,2052
|
|
28
|
-
dp/agent/server/executor/dispatcher_executor.py,sha256=urpzmKH_tBOgblBdJEa3y8eEhXqUDrdcdWCnUdJpfZk,9420
|
|
29
|
-
dp/agent/server/executor/local_executor.py,sha256=wYCclNZFkLb3v7KpW1nCnupO8piBES-esYlDAuz86zk,6120
|
|
30
|
-
dp/agent/server/storage/__init__.py,sha256=Sgsyp5hb0_hhIGugAPfQFzBHt_854rS_MuMuE3sn8Gs,389
|
|
31
|
-
dp/agent/server/storage/base_storage.py,sha256=728-oNG6N8isV95gZVnyi4vTznJPJhSjxw9Gl5Y_y5o,2356
|
|
32
|
-
dp/agent/server/storage/bohrium_storage.py,sha256=EsKX4dWWvZTn2TEhZv4zsvihfDK0mmPFecrln-Ytk40,10488
|
|
33
|
-
dp/agent/server/storage/http_storage.py,sha256=KiySq7g9-iJr12XQCKKyJLn8wJoDnSRpQAR5_qPJ1ZU,1471
|
|
34
|
-
dp/agent/server/storage/local_storage.py,sha256=t1wfjByjXew9ws3PuUxWxmZQ0-Wt1a6t4wmj3fW62GI,1352
|
|
35
|
-
dp/agent/server/storage/oss_storage.py,sha256=pgjmi7Gir3Y5wkMDCvU4fvSls15fXT7Ax-h9MYHFPK0,3359
|
|
36
|
-
bohr_agent_sdk-0.1.101.dist-info/METADATA,sha256=aPSBkjXZHVZyRBAqdWQl_BNJnVxAcRbuK-izY7ibVXw,6330
|
|
37
|
-
bohr_agent_sdk-0.1.101.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
38
|
-
bohr_agent_sdk-0.1.101.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
|
|
39
|
-
bohr_agent_sdk-0.1.101.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
|
|
40
|
-
bohr_agent_sdk-0.1.101.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|