bohr-agent-sdk 0.1.102__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.102.dist-info → bohr_agent_sdk-0.1.103.dist-info}/RECORD +6 -6
- dp/agent/cli/cli.py +1 -1
- bohr_agent_sdk-0.1.102.dist-info/METADATA +0 -228
- {bohr_agent_sdk-0.1.102.dist-info → bohr_agent_sdk-0.1.103.dist-info}/WHEEL +0 -0
- {bohr_agent_sdk-0.1.102.dist-info → bohr_agent_sdk-0.1.103.dist-info}/entry_points.txt +0 -0
- {bohr_agent_sdk-0.1.102.dist-info → bohr_agent_sdk-0.1.103.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bohr-agent-sdk
|
|
3
|
+
Version: 0.1.103
|
|
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
|
+
Requires-Dist: watchdog>=6.0.0
|
|
34
|
+
Requires-Dist: fastapi>=0.116.0
|
|
35
|
+
Requires-Dist: bohrium-open-sdk
|
|
36
|
+
Provides-Extra: device
|
|
37
|
+
Requires-Dist: pywinauto-recorder>=0.1.0; extra == "device"
|
|
38
|
+
Provides-Extra: cloud
|
|
39
|
+
Requires-Dist: paho-mqtt>=1.6.1; extra == "cloud"
|
|
40
|
+
Requires-Dist: redis>=5.0.1; extra == "cloud"
|
|
41
|
+
Requires-Dist: aiohttp>=3.9.1; extra == "cloud"
|
|
42
|
+
Provides-Extra: dev
|
|
43
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
44
|
+
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
45
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
46
|
+
Requires-Dist: black>=23.11.0; extra == "dev"
|
|
47
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
48
|
+
Requires-Dist: mypy>=1.7.0; extra == "dev"
|
|
49
|
+
Requires-Dist: pylint>=3.0.0; extra == "dev"
|
|
50
|
+
Requires-Dist: google-adk; extra == "dev"
|
|
51
|
+
Provides-Extra: docs
|
|
52
|
+
Requires-Dist: sphinx>=7.2.0; extra == "docs"
|
|
53
|
+
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
54
|
+
Provides-Extra: all
|
|
55
|
+
Requires-Dist: bohr-agent-sdk[bohrium,cloud,dev,device,dispatcher,docs]; extra == "all"
|
|
56
|
+
Dynamic: home-page
|
|
57
|
+
Dynamic: requires-python
|
|
58
|
+
|
|
59
|
+
# Bohrium Science Agent SDK
|
|
60
|
+
|
|
61
|
+
[English](README.md) | [简体中文](README_CN.md)
|
|
62
|
+
|
|
63
|
+
**Transform Scientific Software into AI Assistants — 3 Steps to Intelligent Transformation**
|
|
64
|
+
|
|
65
|
+
## 📖 Introduction
|
|
66
|
+
|
|
67
|
+
The Bohrium platform introduces the **bohr-agent-sdk Scientific Agent Development Kit**, enabling AI systems to truly execute professional scientific tasks and helping developers quickly build their own specialized research agents. Through a three-step process — **Invoking MCP Tools, Orchestrating Agent Workflows, and Deploying Services** — any scientific software can be rapidly transformed into an AI assistant.
|
|
68
|
+
|
|
69
|
+
## ✨ Core Features
|
|
70
|
+
|
|
71
|
+
### 🎯 Intelligent Task Management: Simplified Development, Standardized Output
|
|
72
|
+
With a decorator pattern, just a few annotations can quickly transform scientific computing programs into MCP standard services. Built-in application templates turn scattered research code into standardized, reusable intelligent components.
|
|
73
|
+
|
|
74
|
+
### 🔧 Multi-Backend Framework Support
|
|
75
|
+
Supports mainstream Agent open frameworks including Google ADK, Langraph, and Camel, providing flexible choices for developers familiar with different technology stacks.
|
|
76
|
+
|
|
77
|
+
### ☁️ Flexible Deployment: Local Development, Cloud Production
|
|
78
|
+
Dual-mode architecture supports seamless transition between development and production. Local environments enable rapid iteration and feature validation, while Bohrium's cloud GPU clusters handle production-grade computing tasks. The SDK automatically manages the complete workflow of task scheduling, status monitoring, and result collection, with built-in file transfer mechanisms for handling large-scale data uploads and downloads. Developers focus on core algorithm implementation while infrastructure management is fully automated.
|
|
79
|
+
|
|
80
|
+
### 🖼️ Visual Interactive Interface: Professional Presentation, Intuitive Operation
|
|
81
|
+
Based on the modern React framework, deploy fully-featured web applications with one click. Built-in 3D molecular visualization engine supports multiple structure formats and rendering modes for interactive molecular structure display. Real-time data synchronization ensures instant computing status updates, while multi-session management supports parallel task processing. Integrated with enterprise-grade features including file management, project switching, and permission control. Transform command-line tools into professional visual applications, significantly enhancing user experience and tool usability.
|
|
82
|
+
|
|
83
|
+
## 🖼️ Interface Showcase
|
|
84
|
+
|
|
85
|
+
### Scientific Computing Master Console
|
|
86
|
+
<div align="center">
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
|
|
90
|
+
*Powerful scientific computing task management and monitoring platform*
|
|
91
|
+
|
|
92
|
+
</div>
|
|
93
|
+
|
|
94
|
+
### Visual Interactive Interface
|
|
95
|
+
<div align="center">
|
|
96
|
+
|
|
97
|
+

|
|
98
|
+
|
|
99
|
+
*Modern web application interface providing intuitive user experience*
|
|
100
|
+
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
## 🚀 Quick Start
|
|
104
|
+
|
|
105
|
+
### Installation
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install bohr-agent-sdk -i https://pypi.org/simple --upgrade
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Build Your Research Agent in 3 Steps
|
|
112
|
+
|
|
113
|
+
#### Step 1: Get Project Templates
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Get calculation project template
|
|
117
|
+
dp-agent fetch scaffolding --type=calculation
|
|
118
|
+
|
|
119
|
+
# Get device control project template
|
|
120
|
+
dp-agent fetch scaffolding --type=device
|
|
121
|
+
|
|
122
|
+
# Get configuration file
|
|
123
|
+
dp-agent fetch config
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Step 2: Develop Your Agent
|
|
127
|
+
|
|
128
|
+
**Lab Mode Development Example**
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
from typing import Dict, TypedDict
|
|
132
|
+
from dp.agent.device.device import Device, action, BaseParams, SuccessResult
|
|
133
|
+
|
|
134
|
+
class TakePictureParams(BaseParams):
|
|
135
|
+
"""Picture taking parameters"""
|
|
136
|
+
horizontal_width: str # Image horizontal width
|
|
137
|
+
|
|
138
|
+
class PictureData(TypedDict):
|
|
139
|
+
"""Picture data structure"""
|
|
140
|
+
image_id: str
|
|
141
|
+
|
|
142
|
+
class PictureResult(SuccessResult):
|
|
143
|
+
"""Picture taking result"""
|
|
144
|
+
data: PictureData
|
|
145
|
+
|
|
146
|
+
class MyDevice(Device):
|
|
147
|
+
"""Custom device class"""
|
|
148
|
+
device_name = "my_device"
|
|
149
|
+
|
|
150
|
+
@action("take_picture")
|
|
151
|
+
def take_picture(self, params: TakePictureParams) -> PictureResult:
|
|
152
|
+
"""
|
|
153
|
+
Execute picture taking action
|
|
154
|
+
|
|
155
|
+
Through the @action decorator, automatically register this method as an MCP standard service
|
|
156
|
+
"""
|
|
157
|
+
hw = params.get("horizontal_width", "default")
|
|
158
|
+
# Execute actual device control logic
|
|
159
|
+
return PictureResult(
|
|
160
|
+
message=f"Picture taken with {self.device_name}",
|
|
161
|
+
data={"image_id": "image_123"}
|
|
162
|
+
)
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
**Cloud Mode Development Example**
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
"""
|
|
169
|
+
MCP protocol-based cloud device control example
|
|
170
|
+
"""
|
|
171
|
+
import signal
|
|
172
|
+
import sys
|
|
173
|
+
from dp.agent.cloud import mcp, get_mqtt_cloud_instance
|
|
174
|
+
from dp.agent.device.device import TescanDevice, register_mcp_tools
|
|
175
|
+
|
|
176
|
+
def signal_handler(sig, frame):
|
|
177
|
+
"""Graceful shutdown handling"""
|
|
178
|
+
print("Shutting down...")
|
|
179
|
+
get_mqtt_cloud_instance().stop()
|
|
180
|
+
sys.exit(0)
|
|
181
|
+
|
|
182
|
+
def main():
|
|
183
|
+
"""Start cloud services"""
|
|
184
|
+
print("Starting Tescan Device Twin Cloud Services...")
|
|
185
|
+
|
|
186
|
+
# Register signal handler
|
|
187
|
+
signal.signal(signal.SIGINT, signal_handler)
|
|
188
|
+
|
|
189
|
+
# Create device instance
|
|
190
|
+
device = TescanDevice(mcp, device)
|
|
191
|
+
|
|
192
|
+
# Automatically register device tools to MCP server
|
|
193
|
+
# register_mcp_tools implements automatic registration through Python introspection
|
|
194
|
+
register_mcp_tools(device)
|
|
195
|
+
|
|
196
|
+
# Start MCP server
|
|
197
|
+
print("Starting MCP server...")
|
|
198
|
+
mcp.run(transport="sse")
|
|
199
|
+
|
|
200
|
+
if __name__ == "__main__":
|
|
201
|
+
main()
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Step 3: Run and Deploy
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
# Local lab environment
|
|
208
|
+
dp-agent run tool device
|
|
209
|
+
|
|
210
|
+
# Cloud computing environment
|
|
211
|
+
dp-agent run tool cloud
|
|
212
|
+
|
|
213
|
+
# Scientific calculation mode
|
|
214
|
+
dp-agent run tool calculation
|
|
215
|
+
|
|
216
|
+
# Start agent (with Web UI)
|
|
217
|
+
dp-agent run agent --config
|
|
218
|
+
|
|
219
|
+
# Debug mode
|
|
220
|
+
dp-agent run debug
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## 🏗️ Project Structure
|
|
224
|
+
|
|
225
|
+
After running `dp-agent fetch scaffolding`, you'll get a standardized project structure:
|
|
226
|
+
|
|
227
|
+
```
|
|
228
|
+
your-project/
|
|
229
|
+
├── lab/ # Lab mode
|
|
230
|
+
│ ├── __init__.py
|
|
231
|
+
│ └── tescan_device.py # Device control implementation
|
|
232
|
+
├── cloud/ # Cloud mode
|
|
233
|
+
│ ├── __init__.py
|
|
234
|
+
│ └── mcp_server.py # MCP service implementation
|
|
235
|
+
├── calculation/ # Calculation mode
|
|
236
|
+
│ └── __init__.py
|
|
237
|
+
├── .env # Environment configuration
|
|
238
|
+
└── main.py # Main program entry
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## ⚙️ Configuration
|
|
242
|
+
|
|
243
|
+
Configure necessary environment variables in the `.env` file:
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# MQTT connection configuration
|
|
247
|
+
MQTT_INSTANCE_ID=your_instance_id
|
|
248
|
+
MQTT_ENDPOINT=your_endpoint
|
|
249
|
+
MQTT_DEVICE_ID=your_device_id
|
|
250
|
+
MQTT_GROUP_ID=your_group_id
|
|
251
|
+
MQTT_AK=your_access_key
|
|
252
|
+
MQTT_SK=your_secret_key
|
|
253
|
+
|
|
254
|
+
# Computing resource configuration
|
|
255
|
+
BOHRIUM_USERNAME=your_username
|
|
256
|
+
BOHRIUM_PASSWORD=your_password
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
Note: The `dp-agent fetch config` command automatically downloads configuration files and replaces dynamic variables (such as MQTT_DEVICE_ID). For security reasons, this feature is only available in internal network environments.
|
|
260
|
+
|
|
261
|
+
## 🎯 Application Scenarios
|
|
262
|
+
|
|
263
|
+
- **Materials Science Computing**: Molecular dynamics simulation, first-principles calculations
|
|
264
|
+
- **Bioinformatics Analysis**: Gene sequence analysis, protein structure prediction
|
|
265
|
+
- **Laboratory Equipment Control**: Intelligent control of research equipment such as electron microscopes and X-ray diffractometers
|
|
266
|
+
- **Data Processing Workflows**: Automated data cleaning, analysis, and visualization
|
|
267
|
+
- **Machine Learning Training**: Model training, hyperparameter optimization, result evaluation
|
|
268
|
+
|
|
269
|
+
## 🔧 Advanced Features
|
|
270
|
+
|
|
271
|
+
### File Management
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Upload files to cloud
|
|
275
|
+
dp-agent artifact upload <path>
|
|
276
|
+
|
|
277
|
+
# Download cloud files
|
|
278
|
+
dp-agent artifact download <artifact_id>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
### Task Monitoring
|
|
282
|
+
|
|
283
|
+
The SDK provides real-time task status monitoring, supporting:
|
|
284
|
+
- Task queue management
|
|
285
|
+
- Computing resource scheduling
|
|
286
|
+
- Automatic result collection
|
|
287
|
+
- Exception handling and retry mechanisms
|
|
288
|
+
|
|
289
|
+
## 📚 Documentation & Support
|
|
290
|
+
|
|
291
|
+
- 📖 [Detailed Documentation](https://dptechnology.feishu.cn/wiki/ZSj9wbLJEiwdNek0Iu7cKsFanuW)
|
|
292
|
+
|
|
@@ -9,7 +9,7 @@ dp/agent/adapter/camel/__init__.py,sha256=RN1NhdmsJyN43fTxTXFld4UKZksjpSV0b2QvFn
|
|
|
9
9
|
dp/agent/adapter/camel/client/__init__.py,sha256=ld-r0_WsZLFv6yyrmxjWmR8JgnrQzOw4fX0hwVHzciY,93
|
|
10
10
|
dp/agent/adapter/camel/client/calculation_mcp_client.py,sha256=JZZUYYfMgXvHzK4f6IJp-ia33wn3aYZqDSDVa5yKtdc,1860
|
|
11
11
|
dp/agent/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
-
dp/agent/cli/cli.py,sha256=
|
|
12
|
+
dp/agent/cli/cli.py,sha256=Xp3Q7gp50ttsidPG1i3bOQ0-_pMN7yILePJ-ZyOogvA,12363
|
|
13
13
|
dp/agent/cli/templates/__init__.py,sha256=h5__iNn8QzUyYpCUORJO9GTd42tga_BFQ3ZjA3QtSCI,15
|
|
14
14
|
dp/agent/cli/templates/main.py.template,sha256=gEv_naKkBKUmVY1aGM_RZPWqXhkYDIrk4eu7uQFpWrA,1986
|
|
15
15
|
dp/agent/cli/templates/calculation/simple.py.template,sha256=AkOrMWZf9YKQuLnl5yRgl2V-fepFuZJ1qDcTc9S5Gj0,395
|
|
@@ -73,8 +73,8 @@ dp/agent/server/storage/bohrium_storage.py,sha256=EsKX4dWWvZTn2TEhZv4zsvihfDK0mm
|
|
|
73
73
|
dp/agent/server/storage/http_storage.py,sha256=w0lY95wQqKmjXTGFRhEG2hLu8GBFwgqG8ocm5lJ_fYc,1470
|
|
74
74
|
dp/agent/server/storage/local_storage.py,sha256=t1wfjByjXew9ws3PuUxWxmZQ0-Wt1a6t4wmj3fW62GI,1352
|
|
75
75
|
dp/agent/server/storage/oss_storage.py,sha256=pgjmi7Gir3Y5wkMDCvU4fvSls15fXT7Ax-h9MYHFPK0,3359
|
|
76
|
-
bohr_agent_sdk-0.1.
|
|
77
|
-
bohr_agent_sdk-0.1.
|
|
78
|
-
bohr_agent_sdk-0.1.
|
|
79
|
-
bohr_agent_sdk-0.1.
|
|
80
|
-
bohr_agent_sdk-0.1.
|
|
76
|
+
bohr_agent_sdk-0.1.103.dist-info/METADATA,sha256=hds24-rnglRxU193mo5VosDHUGte8Zk_Cmu12umIQF0,10184
|
|
77
|
+
bohr_agent_sdk-0.1.103.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
78
|
+
bohr_agent_sdk-0.1.103.dist-info/entry_points.txt,sha256=5n5kneF5IbDQtoQ2WfF-QuBjDtsimJte9Rv9baSGgc0,86
|
|
79
|
+
bohr_agent_sdk-0.1.103.dist-info/top_level.txt,sha256=87xLUDhu_1nQHoGLwlhJ6XlO7OsjILh6i1nX6ljFzDo,3
|
|
80
|
+
bohr_agent_sdk-0.1.103.dist-info/RECORD,,
|
dp/agent/cli/cli.py
CHANGED
|
@@ -188,7 +188,7 @@ def calculation():
|
|
|
188
188
|
def agent(ui, config, port, module, agent_name, dev):
|
|
189
189
|
"""Run the science agent with optional UI interface."""
|
|
190
190
|
if not ui:
|
|
191
|
-
|
|
191
|
+
click.echo("Starting agent in console mode...")
|
|
192
192
|
click.echo("Console mode not yet implemented.")
|
|
193
193
|
return
|
|
194
194
|
|
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: bohr-agent-sdk
|
|
3
|
-
Version: 0.1.102
|
|
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
|
-
Requires-Dist: watchdog>=6.0.0
|
|
34
|
-
Requires-Dist: fastapi>=0.116.0
|
|
35
|
-
Requires-Dist: bohrium-open-sdk==0.1.5
|
|
36
|
-
Provides-Extra: device
|
|
37
|
-
Requires-Dist: pywinauto-recorder>=0.1.0; extra == "device"
|
|
38
|
-
Provides-Extra: cloud
|
|
39
|
-
Requires-Dist: paho-mqtt>=1.6.1; extra == "cloud"
|
|
40
|
-
Requires-Dist: redis>=5.0.1; extra == "cloud"
|
|
41
|
-
Requires-Dist: aiohttp>=3.9.1; extra == "cloud"
|
|
42
|
-
Provides-Extra: dev
|
|
43
|
-
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
44
|
-
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
|
|
45
|
-
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
46
|
-
Requires-Dist: black>=23.11.0; extra == "dev"
|
|
47
|
-
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
48
|
-
Requires-Dist: mypy>=1.7.0; extra == "dev"
|
|
49
|
-
Requires-Dist: pylint>=3.0.0; extra == "dev"
|
|
50
|
-
Requires-Dist: google-adk; extra == "dev"
|
|
51
|
-
Provides-Extra: docs
|
|
52
|
-
Requires-Dist: sphinx>=7.2.0; extra == "docs"
|
|
53
|
-
Requires-Dist: sphinx-rtd-theme>=1.3.0; extra == "docs"
|
|
54
|
-
Provides-Extra: all
|
|
55
|
-
Requires-Dist: bohr-agent-sdk[bohrium,cloud,dev,device,dispatcher,docs]; extra == "all"
|
|
56
|
-
Dynamic: home-page
|
|
57
|
-
Dynamic: requires-python
|
|
58
|
-
|
|
59
|
-
# Bohrium Science Agent SDK
|
|
60
|
-
|
|
61
|
-
这是DP Tech的Bohrium Science Agent SDK,提供了一个命令行工具dp-agent,用于管理科学计算任务。同时提供了Python SDK用于开发自定义的科学计算应用。
|
|
62
|
-
|
|
63
|
-
## 安装
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
pip install bohr-agent-sdk -i https://pypi.org/simple --upgrade
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## CLI 使用方法
|
|
70
|
-
|
|
71
|
-
安装后,您可以使用以下命令:
|
|
72
|
-
|
|
73
|
-
### 获取资源
|
|
74
|
-
|
|
75
|
-
```bash
|
|
76
|
-
# 获取基础代码结构
|
|
77
|
-
dp-agent fetch scaffolding --type=calculation/device
|
|
78
|
-
|
|
79
|
-
# 获取配置文件
|
|
80
|
-
dp-agent fetch config
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
`fetch config` 命令会下载 .env 配置文件并替换部分动态变量,如 MQTT_DEVICE_ID。
|
|
84
|
-
注意:出于安全考虑,此功能仅在内网环境可用。其他环境需要手动配置。
|
|
85
|
-
|
|
86
|
-
### 运行命令
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
# 运行实验环境
|
|
90
|
-
dp-agent run tool device
|
|
91
|
-
|
|
92
|
-
# 运行云环境
|
|
93
|
-
dp-agent run tool cloud
|
|
94
|
-
|
|
95
|
-
# 运行计算环境
|
|
96
|
-
dp-agent run tool calculation
|
|
97
|
-
|
|
98
|
-
# 运行代理
|
|
99
|
-
dp-agent run agent --config config.json
|
|
100
|
-
|
|
101
|
-
# 调试模式
|
|
102
|
-
dp-agent run debug
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## SDK 快速入门
|
|
106
|
-
|
|
107
|
-
Bohrium Science Agent SDK 提供了两种主要的开发模式:实验室模式(Lab)和云模式(Cloud)。
|
|
108
|
-
|
|
109
|
-
### 基础结构
|
|
110
|
-
|
|
111
|
-
安装完成并运行 `dp-agent fetch scaffolding` 后,您将获得以下基础项目结构:
|
|
112
|
-
|
|
113
|
-
```
|
|
114
|
-
your-project/
|
|
115
|
-
├── lab/ # 实验室模式相关代码
|
|
116
|
-
│ ├── __init__.py
|
|
117
|
-
│ └── tescan_device.py # 设备控制示例
|
|
118
|
-
├── cloud/ # 云模式相关代码
|
|
119
|
-
│ └── __init__.py
|
|
120
|
-
└── main.py # 主程序入口
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### 实验室模式开发
|
|
124
|
-
|
|
125
|
-
实验室模式主要用于控制本地实验设备。以下是一个基于 Tescan 设备的示例:
|
|
126
|
-
|
|
127
|
-
```python
|
|
128
|
-
from typing import Dict, TypedDict
|
|
129
|
-
from dp.agent.device.device import Device, action, BaseParams, SuccessResult
|
|
130
|
-
|
|
131
|
-
class TakePictureParams(BaseParams):
|
|
132
|
-
"""拍照参数"""
|
|
133
|
-
horizontal_width: str
|
|
134
|
-
|
|
135
|
-
class PictureData(TypedDict):
|
|
136
|
-
"""照片数据"""
|
|
137
|
-
image_id: str
|
|
138
|
-
|
|
139
|
-
class PictureResult(SuccessResult):
|
|
140
|
-
"""拍照结果"""
|
|
141
|
-
data: PictureData
|
|
142
|
-
|
|
143
|
-
class MyDevice(Device):
|
|
144
|
-
device_name = "my_device"
|
|
145
|
-
|
|
146
|
-
@action("take_picture")
|
|
147
|
-
def take_picture(self, params: TakePictureParams) -> PictureResult:
|
|
148
|
-
"""拍照动作
|
|
149
|
-
|
|
150
|
-
Args:
|
|
151
|
-
params: 拍照参数
|
|
152
|
-
- horizontal_width: 图片水平宽度
|
|
153
|
-
"""
|
|
154
|
-
hw = params.get("horizontal_width", "default")
|
|
155
|
-
return PictureResult(
|
|
156
|
-
message=f"Picture taken with {self.device_name}",
|
|
157
|
-
data={"image_id": "image_123"}
|
|
158
|
-
)
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
### 云端开发
|
|
162
|
-
|
|
163
|
-
云模式基于 MCP (Message Control Protocol) 实现,用于处理远程设备控制和任务调度。register_mcp_tools 通过 python 的自省和反射机制实现了设备控制的自动注册,无需重复实现操作定义。
|
|
164
|
-
以下展示如何创建设备并注册到 MCP 服务器:
|
|
165
|
-
|
|
166
|
-
```python
|
|
167
|
-
"""
|
|
168
|
-
Example of using the bohr-agent-sdk cloud functionality.
|
|
169
|
-
"""
|
|
170
|
-
import signal
|
|
171
|
-
import sys
|
|
172
|
-
from dp.agent.cloud import mcp, get_mqtt_cloud_instance
|
|
173
|
-
from dp.agent.device.device import TescanDevice, register_mcp_tools
|
|
174
|
-
|
|
175
|
-
def signal_handler(sig, frame):
|
|
176
|
-
"""Handle SIGINT signal to gracefully shutdown."""
|
|
177
|
-
print("Shutting down...")
|
|
178
|
-
get_mqtt_cloud_instance().stop()
|
|
179
|
-
sys.exit(0)
|
|
180
|
-
|
|
181
|
-
def main():
|
|
182
|
-
"""Start the cloud services."""
|
|
183
|
-
print("Starting Tescan Device Twin Cloud Services...")
|
|
184
|
-
|
|
185
|
-
# Register signal handler
|
|
186
|
-
signal.signal(signal.SIGINT, signal_handler)
|
|
187
|
-
|
|
188
|
-
# Create device instance
|
|
189
|
-
device = TescanDevice(mcp, device)
|
|
190
|
-
|
|
191
|
-
# Register device tools
|
|
192
|
-
register_mcp_tools(device)
|
|
193
|
-
|
|
194
|
-
# Start MCP server
|
|
195
|
-
print("Starting MCP server...")
|
|
196
|
-
mcp.run(transport="sse")
|
|
197
|
-
|
|
198
|
-
if __name__ == "__main__":
|
|
199
|
-
main()
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
### 配置说明
|
|
204
|
-
|
|
205
|
-
在 `.env` 文件中配置必要的环境变量:
|
|
206
|
-
|
|
207
|
-
```
|
|
208
|
-
MQTT_INSTANCE_ID=your_instance_id
|
|
209
|
-
MQTT_ENDPOINT=your_endpoint
|
|
210
|
-
MQTT_DEVICE_ID=your_device_id
|
|
211
|
-
MQTT_GROUP_ID=your_group_id
|
|
212
|
-
MQTT_AK=your_access_key
|
|
213
|
-
MQTT_SK=your_secret_key
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### 主要功能
|
|
217
|
-
|
|
218
|
-
- 设备控制接口(Lab模式)
|
|
219
|
-
- 设备初始化
|
|
220
|
-
- 命令执行
|
|
221
|
-
- 状态监控
|
|
222
|
-
|
|
223
|
-
- 云端任务处理(Cloud模式)
|
|
224
|
-
- 任务队列管理
|
|
225
|
-
- 计算资源调度
|
|
226
|
-
- 结果回传
|
|
227
|
-
|
|
228
|
-
更详细的API文档请参考代码中的注释。
|
|
File without changes
|
|
File without changes
|
|
File without changes
|