adam-community 1.0.5__tar.gz → 1.0.7__tar.gz
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.
- {adam_community-1.0.5 → adam_community-1.0.7}/PKG-INFO +2 -1
- adam_community-1.0.7/adam_community/__version__.py +1 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/cli/parser.py +29 -0
- adam_community-1.0.7/adam_community/cli/templates/Makefile.j2 +10 -0
- adam_community-1.0.7/adam_community/cli/templates/README_kit.md.j2 +223 -0
- adam_community-1.0.7/adam_community/cli/templates/README_toolbox.md.j2 +338 -0
- adam_community-1.0.7/adam_community/cli/templates/configure.json.j2 +10 -0
- adam_community-1.0.7/adam_community/cli/templates/initial_assistant_message.md.j2 +21 -0
- adam_community-1.0.7/adam_community/cli/templates/initial_system_prompt.md.j2 +22 -0
- adam_community-1.0.7/adam_community/cli/templates/input.json.j2 +25 -0
- adam_community-1.0.7/adam_community/cli/templates/kit_python.py.j2 +105 -0
- adam_community-1.0.7/adam_community/cli/templates/long_description.md.j2 +61 -0
- adam_community-1.0.7/adam_community/cli/templates/toolbox_python.py.j2 +139 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community.egg-info/PKG-INFO +2 -1
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community.egg-info/SOURCES.txt +10 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community.egg-info/requires.txt +1 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/setup.py +5 -1
- adam_community-1.0.5/adam_community/__version__.py +0 -1
- {adam_community-1.0.5 → adam_community-1.0.7}/README.md +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/__init__.py +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/cli/__init__.py +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/cli/build.py +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/cli/cli.py +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/cli/init.py +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/cli/templates/__init__.py +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/cli/updater.py +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/tool.py +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community/util.py +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community.egg-info/dependency_links.txt +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community.egg-info/entry_points.txt +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/adam_community.egg-info/top_level.txt +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/setup.cfg +0 -0
- {adam_community-1.0.5 → adam_community-1.0.7}/test/test_util_tool.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: adam_community
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: Adam Community Tools and Utilities
|
|
5
5
|
Home-page: https://github.com/yourusername/adam-community
|
|
6
6
|
Author: Adam Community
|
|
@@ -16,6 +16,7 @@ Requires-Dist: docstring-parser>=0.15
|
|
|
16
16
|
Requires-Dist: rich>=13.0.0
|
|
17
17
|
Requires-Dist: packaging>=21.0
|
|
18
18
|
Requires-Dist: jsonschema>=4.0.0
|
|
19
|
+
Requires-Dist: jinja2>=3.0.0
|
|
19
20
|
Dynamic: author
|
|
20
21
|
Dynamic: author-email
|
|
21
22
|
Dynamic: classifier
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.7"
|
|
@@ -263,6 +263,31 @@ def validate_description_length(description: str, function_name: str, file_path:
|
|
|
263
263
|
f"超过了1024字符限制。请缩短描述长度。"
|
|
264
264
|
)
|
|
265
265
|
|
|
266
|
+
def _inherits_from_tool(class_node: ast.ClassDef) -> bool:
|
|
267
|
+
"""检查类是否继承了 adam_community.Tool
|
|
268
|
+
|
|
269
|
+
Args:
|
|
270
|
+
class_node: AST 类定义节点
|
|
271
|
+
|
|
272
|
+
Returns:
|
|
273
|
+
bool: 如果类继承了 adam_community.Tool 则返回 True,否则返回 False
|
|
274
|
+
"""
|
|
275
|
+
for base in class_node.bases:
|
|
276
|
+
if isinstance(base, ast.Name):
|
|
277
|
+
# 直接继承 Tool 类
|
|
278
|
+
if base.id == 'Tool':
|
|
279
|
+
return True
|
|
280
|
+
elif isinstance(base, ast.Attribute):
|
|
281
|
+
# 继承 adam_community.Tool 或类似的形式
|
|
282
|
+
if (isinstance(base.value, ast.Name) and
|
|
283
|
+
base.value.id == 'adam_community' and
|
|
284
|
+
base.attr == 'Tool'):
|
|
285
|
+
return True
|
|
286
|
+
# 继承 Tool 类(可能是通过 from adam_community import Tool 导入的)
|
|
287
|
+
if base.attr == 'Tool':
|
|
288
|
+
return True
|
|
289
|
+
return False
|
|
290
|
+
|
|
266
291
|
def parse_python_file(file_path: Path) -> List[Dict[str, Any]]:
|
|
267
292
|
"""解析单个 Python 文件,提取类信息
|
|
268
293
|
|
|
@@ -281,6 +306,10 @@ def parse_python_file(file_path: Path) -> List[Dict[str, Any]]:
|
|
|
281
306
|
|
|
282
307
|
for node in ast.walk(tree):
|
|
283
308
|
if isinstance(node, ast.ClassDef):
|
|
309
|
+
# 检查类是否继承了 adam_community.Tool
|
|
310
|
+
if not _inherits_from_tool(node):
|
|
311
|
+
continue
|
|
312
|
+
|
|
284
313
|
# 获取类的文档字符串
|
|
285
314
|
docstring = ast.get_docstring(node) or ""
|
|
286
315
|
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
# {{ display_name }}
|
|
2
|
+
|
|
3
|
+
{{ description }}
|
|
4
|
+
|
|
5
|
+
这是一个基于 Adam Tool Protocol (ATP) 开发的 Kit 工具项目,通过表单界面为用户提供功能。
|
|
6
|
+
|
|
7
|
+
## 项目信息
|
|
8
|
+
|
|
9
|
+
- **项目名称**: {{ name }}
|
|
10
|
+
- **显示名称**: {{ display_name }}
|
|
11
|
+
- **版本**: {{ version }}
|
|
12
|
+
- **作者**: {{ author }}
|
|
13
|
+
- **类型**: Kit (表单工具)
|
|
14
|
+
|
|
15
|
+
## 快速开始
|
|
16
|
+
|
|
17
|
+
### 1. 环境准备
|
|
18
|
+
|
|
19
|
+
确保你已经安装了 adam-community:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# 在项目根目录安装依赖
|
|
23
|
+
cd /path/to/adam-community
|
|
24
|
+
python setup.py develop
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 2. 开发工具流程
|
|
28
|
+
|
|
29
|
+
#### 2.1 修改代码实现
|
|
30
|
+
编辑 `{{ name.replace('-', '_') }}.py` 文件,实现你的业务逻辑:
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
def call(self, kwargs):
|
|
34
|
+
# 获取表单输入参数
|
|
35
|
+
input_text = kwargs['args']['input_text']
|
|
36
|
+
|
|
37
|
+
# TODO: 在这里实现你的主要逻辑
|
|
38
|
+
# 示例:处理输入文本
|
|
39
|
+
result = process_your_logic(input_text)
|
|
40
|
+
|
|
41
|
+
# 生成报告文件 (Kit工具必须生成 report.md)
|
|
42
|
+
generate_report(result)
|
|
43
|
+
|
|
44
|
+
return result
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
#### 2.2 自定义表单配置
|
|
48
|
+
编辑 `config/input.json` 来配置用户输入表单:
|
|
49
|
+
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"formName": "你的表单名称",
|
|
53
|
+
"description": "表单说明",
|
|
54
|
+
"fields": [
|
|
55
|
+
{
|
|
56
|
+
"name": "input_field",
|
|
57
|
+
"label": "输入字段",
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "字段说明",
|
|
60
|
+
"validation": {
|
|
61
|
+
"required": true,
|
|
62
|
+
"message": "错误提示"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
支持的字段类型:
|
|
70
|
+
- `string`: 文本输入
|
|
71
|
+
- `number`: 数字输入
|
|
72
|
+
- `boolean`: 布尔值
|
|
73
|
+
- `select`: 单选下拉框
|
|
74
|
+
- `multiselect`: 多选框
|
|
75
|
+
- `file`: 文件上传
|
|
76
|
+
- `date`: 日期选择
|
|
77
|
+
- `object`: 对象(嵌套字段)
|
|
78
|
+
- `array`: 数组
|
|
79
|
+
|
|
80
|
+
#### 2.3 完善项目描述
|
|
81
|
+
编辑 `config/long_description.md` 来完善项目的详细描述,包括:
|
|
82
|
+
- 概览:工具的主要功能和用途
|
|
83
|
+
- 特性:核心特性和优势
|
|
84
|
+
- 指标:性能指标和使用统计
|
|
85
|
+
|
|
86
|
+
### 3. 构建和测试
|
|
87
|
+
|
|
88
|
+
#### 3.1 解析工具函数
|
|
89
|
+
```bash
|
|
90
|
+
# 生成 functions.json
|
|
91
|
+
make parse
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
#### 3.2 构建项目包
|
|
95
|
+
```bash
|
|
96
|
+
# 构建 ZIP 包
|
|
97
|
+
make build
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### 3.3 本地调试
|
|
101
|
+
你可以通过以下方式进行本地调试:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
# 创建测试脚本 test_local.py
|
|
105
|
+
from {{ name.replace('-', '_') }} import runner
|
|
106
|
+
|
|
107
|
+
# 模拟参数
|
|
108
|
+
test_kwargs = {
|
|
109
|
+
'args': {
|
|
110
|
+
'input_text': '测试输入'
|
|
111
|
+
},
|
|
112
|
+
'message': '用户消息',
|
|
113
|
+
'files': [],
|
|
114
|
+
'user': '测试用户',
|
|
115
|
+
'task_id': 'test_task'
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
# 创建工具实例并测试
|
|
119
|
+
tool = runner()
|
|
120
|
+
result = tool.call(test_kwargs)
|
|
121
|
+
print(f"执行结果: {result}")
|
|
122
|
+
|
|
123
|
+
# 测试输出显示
|
|
124
|
+
output_kwargs = {
|
|
125
|
+
'stdout': '测试输出',
|
|
126
|
+
'stderr': '',
|
|
127
|
+
'exitcode': 0
|
|
128
|
+
}
|
|
129
|
+
display_text, file_list = tool.outputShow(output_kwargs)
|
|
130
|
+
print(f"显示文本: {display_text}")
|
|
131
|
+
print(f"文件列表: {file_list}")
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### 4. 部署和发布
|
|
135
|
+
|
|
136
|
+
#### 4.1 上传到平台
|
|
137
|
+
1. 运行 `make build` 生成 ZIP 包
|
|
138
|
+
2. 在 Adam 平台控制台选择生成的 ZIP 包
|
|
139
|
+
3. 点击发布
|
|
140
|
+
4. 设置为可见状态
|
|
141
|
+
|
|
142
|
+
#### 4.2 测试工具
|
|
143
|
+
1. 在平台的「工具」页面找到你的工具
|
|
144
|
+
2. 填写表单测试功能
|
|
145
|
+
3. 查看生成的报告和结果
|
|
146
|
+
|
|
147
|
+
## 开发指南
|
|
148
|
+
|
|
149
|
+
### Kit 工具特点
|
|
150
|
+
- **表单驱动**: 用户通过填写表单提供输入参数
|
|
151
|
+
- **报告生成**: 必须生成 `report.md` 文件作为结果展示
|
|
152
|
+
- **文件输出**: 可以生成多个文件供用户下载
|
|
153
|
+
- **同步执行**: 用户提交表单后同步执行并返回结果
|
|
154
|
+
|
|
155
|
+
### 重要方法说明
|
|
156
|
+
|
|
157
|
+
#### `call(self, kwargs)` - 核心执行方法
|
|
158
|
+
- **必须实现**
|
|
159
|
+
- 参数包含:`args`(表单数据)、`message`、`files`、`user`、`task_id`
|
|
160
|
+
- 必须生成 `report.md` 文件
|
|
161
|
+
- 返回处理结果
|
|
162
|
+
|
|
163
|
+
#### `outputShow(self, kwargs)` - 输出显示格式
|
|
164
|
+
- **可选实现**
|
|
165
|
+
- 自定义用户看到的结果展示格式
|
|
166
|
+
- 返回 `(display_text, file_list)` 元组
|
|
167
|
+
- `file_list` 中的文件会提供给用户下载
|
|
168
|
+
|
|
169
|
+
#### `summary(self, kwargs)` - AI摘要
|
|
170
|
+
- **可选实现**
|
|
171
|
+
- 为 AI 生成简短的执行摘要
|
|
172
|
+
- 用于 AI 理解工具执行结果
|
|
173
|
+
|
|
174
|
+
### 常见问题
|
|
175
|
+
|
|
176
|
+
#### Q: 如何处理文件上传?
|
|
177
|
+
A: 在表单配置中使用 `file` 类型字段,在 `call` 方法中通过 `kwargs['files']` 获取上传的文件列表。
|
|
178
|
+
|
|
179
|
+
#### Q: 如何生成多个输出文件?
|
|
180
|
+
A: 在 `call` 方法中创建多个文件,然后在 `outputShow` 方法的 `file_list` 中返回文件名列表。
|
|
181
|
+
|
|
182
|
+
#### Q: 如何处理错误?
|
|
183
|
+
A: 使用 `print()` 输出错误信息到 stderr,系统会自动捕获并显示给用户。
|
|
184
|
+
|
|
185
|
+
#### Q: 如何调试代码?
|
|
186
|
+
A: 创建本地测试脚本,模拟 `kwargs` 参数来测试你的工具逻辑。
|
|
187
|
+
|
|
188
|
+
#### Q: 必须配置哪些属性?
|
|
189
|
+
A: 以下属性是必填的:
|
|
190
|
+
```python
|
|
191
|
+
DISPLAY_NAME = "工具显示名称" # 工具的显示名称
|
|
192
|
+
NETWORK = True/False # 是否需要网络访问
|
|
193
|
+
CPU = 1 # 需要的CPU数量(必填)
|
|
194
|
+
GPU = 0 # 需要的GPU数量(必填)
|
|
195
|
+
SIF = "adam-base:1.0.0" # 容器镜像(必填)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## 文件结构说明
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
{{ name }}/
|
|
202
|
+
├── config/
|
|
203
|
+
│ ├── configure.json # 工具基本配置
|
|
204
|
+
│ ├── input.json # 表单配置
|
|
205
|
+
│ └── long_description.md # 详细描述
|
|
206
|
+
├── {{ name.replace('-', '_') }}.py # 主要实现文件
|
|
207
|
+
├── functions.json # 自动生成的函数描述
|
|
208
|
+
├── Makefile # 构建脚本
|
|
209
|
+
└── README.md # 本文件
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## 参考资源
|
|
213
|
+
|
|
214
|
+
- [Adam Tool Protocol 文档](https://docs.example.com/atp)
|
|
215
|
+
- [表单配置指南](https://docs.example.com/form-config)
|
|
216
|
+
- [现有工具示例](https://github.com/example/adam-tools)
|
|
217
|
+
|
|
218
|
+
## 贡献和支持
|
|
219
|
+
|
|
220
|
+
如有问题或建议,请联系:{{ author }}
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
Generated by Adam CLI - {{ name }} v{{ version }}
|
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# {{ display_name }}
|
|
2
|
+
|
|
3
|
+
{{ description }}
|
|
4
|
+
|
|
5
|
+
这是一个基于 Adam Tool Protocol (ATP) 开发的 Toolbox 智能体项目,通过对话方式为用户提供智能化服务。
|
|
6
|
+
|
|
7
|
+
## 项目信息
|
|
8
|
+
|
|
9
|
+
- **项目名称**: {{ name }}
|
|
10
|
+
- **显示名称**: {{ display_name }}
|
|
11
|
+
- **版本**: {{ version }}
|
|
12
|
+
- **作者**: {{ author }}
|
|
13
|
+
- **类型**: Toolbox (智能体工具)
|
|
14
|
+
|
|
15
|
+
## 快速开始
|
|
16
|
+
|
|
17
|
+
### 1. 环境准备
|
|
18
|
+
|
|
19
|
+
确保你已经安装了 adam-community:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# 在项目根目录安装依赖
|
|
23
|
+
cd /path/to/adam-community
|
|
24
|
+
python setup.py develop
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 2. 开发智能体流程
|
|
28
|
+
|
|
29
|
+
#### 2.1 修改工具实现
|
|
30
|
+
编辑 `{{ name.replace('-', '_') }}.py` 文件,实现你的工具逻辑。项目包含两种工具类型:
|
|
31
|
+
|
|
32
|
+
**Bash 类型工具 (默认)**:
|
|
33
|
+
```python
|
|
34
|
+
class {{ name.replace("-", "_") }}_tool(Tool):
|
|
35
|
+
def call(self, kwargs):
|
|
36
|
+
# 获取用户输入参数
|
|
37
|
+
input_text = kwargs['args']['input_text']
|
|
38
|
+
|
|
39
|
+
# 返回要执行的 bash 命令
|
|
40
|
+
bash_script = f'''
|
|
41
|
+
# 你的 bash 脚本
|
|
42
|
+
echo "处理: {input_text}"
|
|
43
|
+
# 添加你的命令...
|
|
44
|
+
'''
|
|
45
|
+
return bash_script
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Python 类型工具**:
|
|
49
|
+
```python
|
|
50
|
+
class {{ name.replace("-", "_") }}_advanced_tool(Tool, calltype="python"):
|
|
51
|
+
DISPLAY_NAME = "{{ display_name }}高级工具"
|
|
52
|
+
NETWORK = False # 是否需要网络访问
|
|
53
|
+
CPU = 1 # 需要的CPU数量
|
|
54
|
+
GPU = 0 # 需要的GPU数量
|
|
55
|
+
SIF = "adam-base:1.0.0" # 容器镜像
|
|
56
|
+
CONDA_ENV = "base" # 指定运行环境
|
|
57
|
+
|
|
58
|
+
def call(self, kwargs):
|
|
59
|
+
# Python 代码逻辑
|
|
60
|
+
result = your_python_logic()
|
|
61
|
+
|
|
62
|
+
# 必须使用 print 输出结果
|
|
63
|
+
print(f"处理结果: {result}")
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
#### 2.2 配置智能体提示词
|
|
67
|
+
编辑以下文件来配置智能体的行为:
|
|
68
|
+
|
|
69
|
+
**`config/initial_system_prompt.md`** - 系统提示词:
|
|
70
|
+
```markdown
|
|
71
|
+
# 你的信息
|
|
72
|
+
您是一位专业的{{ display_name }}专家...
|
|
73
|
+
|
|
74
|
+
# 你的任务范围
|
|
75
|
+
1. 理解用户需求
|
|
76
|
+
2. 选择合适工具
|
|
77
|
+
3. 执行操作
|
|
78
|
+
4. 生成报告
|
|
79
|
+
|
|
80
|
+
# 工作流程
|
|
81
|
+
1. 分析需求
|
|
82
|
+
2. 制定计划
|
|
83
|
+
3. 执行工具
|
|
84
|
+
4. 分析结果
|
|
85
|
+
5. 生成报告
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**`config/initial_assistant_message.md`** - 欢迎消息:
|
|
89
|
+
```markdown
|
|
90
|
+
# 欢迎使用{{ display_name }}工具!
|
|
91
|
+
|
|
92
|
+
我可以帮助您:
|
|
93
|
+
- 功能1:描述
|
|
94
|
+
- 功能2:描述
|
|
95
|
+
- 功能3:描述
|
|
96
|
+
|
|
97
|
+
请告诉我您的需求...
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### 2.3 完善项目描述
|
|
101
|
+
编辑 `config/long_description.md` 来完善项目的详细描述。
|
|
102
|
+
|
|
103
|
+
### 3. 构建和测试
|
|
104
|
+
|
|
105
|
+
#### 3.1 解析工具函数
|
|
106
|
+
```bash
|
|
107
|
+
# 生成 functions.json
|
|
108
|
+
make parse
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### 3.2 构建项目包
|
|
112
|
+
```bash
|
|
113
|
+
# 构建 ZIP 包
|
|
114
|
+
make build
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
#### 3.3 本地调试
|
|
118
|
+
|
|
119
|
+
**测试 Bash 工具**:
|
|
120
|
+
```python
|
|
121
|
+
# 创建测试脚本 test_bash_tool.py
|
|
122
|
+
from {{ name.replace('-', '_') }} import {{ name.replace("-", "_") }}_tool
|
|
123
|
+
|
|
124
|
+
# 模拟参数
|
|
125
|
+
test_kwargs = {
|
|
126
|
+
'args': {
|
|
127
|
+
'input_text': '测试输入',
|
|
128
|
+
'mode': 'basic'
|
|
129
|
+
},
|
|
130
|
+
'message': '用户消息',
|
|
131
|
+
'files': [],
|
|
132
|
+
'user': '测试用户',
|
|
133
|
+
'task_id': 'test_task'
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
# 测试工具
|
|
137
|
+
tool = {{ name.replace("-", "_") }}_tool()
|
|
138
|
+
bash_script = tool.call(test_kwargs)
|
|
139
|
+
print(f"生成的 bash 脚本:\n{bash_script}")
|
|
140
|
+
|
|
141
|
+
# 测试输出显示
|
|
142
|
+
output_kwargs = {
|
|
143
|
+
'stdout': '命令执行输出',
|
|
144
|
+
'stderr': '',
|
|
145
|
+
'exitcode': 0
|
|
146
|
+
}
|
|
147
|
+
display_text, file_list = tool.outputShow(output_kwargs)
|
|
148
|
+
print(f"显示文本:\n{display_text}")
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**测试 Python 工具**:
|
|
152
|
+
```python
|
|
153
|
+
# 创建测试脚本 test_python_tool.py
|
|
154
|
+
from {{ name.replace('-', '_') }} import {{ name.replace("-", "_") }}_advanced_tool
|
|
155
|
+
|
|
156
|
+
# 模拟参数
|
|
157
|
+
test_kwargs = {
|
|
158
|
+
'args': {
|
|
159
|
+
'input_file': 'test.txt',
|
|
160
|
+
'output_format': 'json'
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
# 测试工具
|
|
165
|
+
tool = {{ name.replace("-", "_") }}_advanced_tool()
|
|
166
|
+
tool.call(test_kwargs) # Python工具直接执行
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### 4. 部署和发布
|
|
170
|
+
|
|
171
|
+
#### 4.1 上传到平台
|
|
172
|
+
1. 运行 `make build` 生成 ZIP 包
|
|
173
|
+
2. 在 Adam 平台控制台选择生成的 ZIP 包
|
|
174
|
+
3. 点击发布
|
|
175
|
+
4. 设置为可见状态
|
|
176
|
+
|
|
177
|
+
#### 4.2 测试智能体
|
|
178
|
+
1. 在平台的「智能体」页面找到你的智能体
|
|
179
|
+
2. 通过对话方式测试功能
|
|
180
|
+
3. 观察智能体如何调用你的工具
|
|
181
|
+
|
|
182
|
+
## 开发指南
|
|
183
|
+
|
|
184
|
+
### Toolbox 智能体特点
|
|
185
|
+
- **对话驱动**: 用户通过自然语言对话与智能体交互
|
|
186
|
+
- **工具调用**: 智能体根据需要调用相应的工具函数
|
|
187
|
+
- **多轮对话**: 支持复杂的多轮对话场景
|
|
188
|
+
- **智能决策**: AI 自动决定何时调用哪个工具
|
|
189
|
+
|
|
190
|
+
### 工具类型说明
|
|
191
|
+
|
|
192
|
+
#### Bash 工具 (`calltype = "bash"`)
|
|
193
|
+
- 适用于系统命令、脚本执行、文件操作等
|
|
194
|
+
- `call` 方法返回要执行的 bash 命令字符串
|
|
195
|
+
- 系统会执行返回的命令并捕获输出
|
|
196
|
+
|
|
197
|
+
#### Python 工具 (`calltype = "python"`)
|
|
198
|
+
- 适用于复杂的 Python 逻辑、数据处理、API 调用等
|
|
199
|
+
- `call` 方法直接执行 Python 代码
|
|
200
|
+
- 必须使用 `print()` 输出结果
|
|
201
|
+
- 需要指定 `CONDA_ENV` 运行环境
|
|
202
|
+
|
|
203
|
+
### 重要配置项
|
|
204
|
+
|
|
205
|
+
#### 工具属性(必填配置)
|
|
206
|
+
```python
|
|
207
|
+
DISPLAY_NAME = "工具显示名称" # 工具的显示名称
|
|
208
|
+
NETWORK = True/False # 是否需要网络访问
|
|
209
|
+
CPU = 1 # 需要的CPU数量(必填)
|
|
210
|
+
GPU = 0 # 需要的GPU数量(必填)
|
|
211
|
+
SIF = "adam-base:1.0.0" # 容器镜像(必填)
|
|
212
|
+
CONDA_ENV = "base" # Conda环境(仅Python工具)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
#### docstring 格式
|
|
216
|
+
```python
|
|
217
|
+
"""
|
|
218
|
+
工具的功能描述
|
|
219
|
+
|
|
220
|
+
:param str input_text: 必需参数描述
|
|
221
|
+
:param str? mode: 可选参数描述(注意?标记)
|
|
222
|
+
"""
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 重要方法说明
|
|
226
|
+
|
|
227
|
+
#### `call(self, kwargs)` - 核心执行方法
|
|
228
|
+
- **必须实现**
|
|
229
|
+
- Bash工具:返回要执行的命令字符串
|
|
230
|
+
- Python工具:直接执行逻辑并用print输出
|
|
231
|
+
|
|
232
|
+
#### `inputShow(self, **kwargs)` - 输入显示
|
|
233
|
+
- **可选实现**
|
|
234
|
+
- 自定义用户看到的输入格式
|
|
235
|
+
- 默认显示完整的命令或代码
|
|
236
|
+
|
|
237
|
+
#### `outputShow(self, kwargs)` - 输出显示
|
|
238
|
+
- **可选实现**
|
|
239
|
+
- 自定义用户看到的输出格式
|
|
240
|
+
- 返回 `(display_text, file_list)` 元组
|
|
241
|
+
|
|
242
|
+
#### `summary(self, kwargs)` - AI摘要
|
|
243
|
+
- **可选实现**
|
|
244
|
+
- 为 AI 生成执行摘要,用于后续决策
|
|
245
|
+
- 控制输出长度,避免上下文过长
|
|
246
|
+
|
|
247
|
+
#### `monitor(self, process, kwargs)` - 进度监控
|
|
248
|
+
- **可选实现**
|
|
249
|
+
- 监控长时间运行的任务进度
|
|
250
|
+
- 设置 `kwargs["PIPELINE"]` 和 `kwargs["PROCESS"]`
|
|
251
|
+
|
|
252
|
+
### 智能体提示词编写指南
|
|
253
|
+
|
|
254
|
+
#### 系统提示词 (`initial_system_prompt.md`)
|
|
255
|
+
- 定义智能体的身份和专业领域
|
|
256
|
+
- 描述任务范围和工作流程
|
|
257
|
+
- 设置工具调用的优先级和策略
|
|
258
|
+
- 包含重要的注意事项和限制
|
|
259
|
+
|
|
260
|
+
#### 欢迎消息 (`initial_assistant_message.md`)
|
|
261
|
+
- 向用户介绍智能体的功能
|
|
262
|
+
- 提供使用建议和最佳实践
|
|
263
|
+
- 引导用户正确描述需求
|
|
264
|
+
|
|
265
|
+
### 常见问题
|
|
266
|
+
|
|
267
|
+
#### Q: 如何处理长时间运行的任务?
|
|
268
|
+
A: 实现 `monitor` 方法来报告进度,或者将任务分解为多个步骤。
|
|
269
|
+
|
|
270
|
+
#### Q: 如何让智能体调用特定工具?
|
|
271
|
+
A: 在系统提示词中明确工具的使用场景和调用条件。
|
|
272
|
+
|
|
273
|
+
#### Q: 如何处理错误和异常?
|
|
274
|
+
A: 在工具中使用适当的错误处理,通过 stderr 输出错误信息。
|
|
275
|
+
|
|
276
|
+
#### Q: 如何优化智能体的响应质量?
|
|
277
|
+
A: 精心设计 docstring 和系统提示词,提供清晰的工具描述和使用指导。
|
|
278
|
+
|
|
279
|
+
#### Q: Python工具的依赖如何管理?
|
|
280
|
+
A: 确保指定的 CONDA_ENV 环境中安装了所有需要的依赖包。
|
|
281
|
+
|
|
282
|
+
## 文件结构说明
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
{{ name }}/
|
|
286
|
+
├── config/
|
|
287
|
+
│ ├── configure.json # 智能体基本配置
|
|
288
|
+
│ ├── initial_system_prompt.md # 系统提示词
|
|
289
|
+
│ ├── initial_assistant_message.md # 欢迎消息
|
|
290
|
+
│ └── long_description.md # 详细描述
|
|
291
|
+
├── {{ name.replace('-', '_') }}.py # 主要实现文件
|
|
292
|
+
├── functions.json # 自动生成的工具描述
|
|
293
|
+
├── Makefile # 构建脚本
|
|
294
|
+
└── README.md # 本文件
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## 调试技巧
|
|
298
|
+
|
|
299
|
+
### 1. 单独测试工具
|
|
300
|
+
创建独立的测试脚本来验证工具逻辑:
|
|
301
|
+
|
|
302
|
+
```python
|
|
303
|
+
# test_individual_tool.py
|
|
304
|
+
if __name__ == "__main__":
|
|
305
|
+
from your_module import your_tool
|
|
306
|
+
|
|
307
|
+
# 模拟真实调用场景
|
|
308
|
+
tool = your_tool()
|
|
309
|
+
result = tool.call(mock_kwargs)
|
|
310
|
+
print(result)
|
|
311
|
+
```
|
|
312
|
+
|
|
313
|
+
### 2. 输出调试信息
|
|
314
|
+
在工具中添加详细的调试输出:
|
|
315
|
+
|
|
316
|
+
```python
|
|
317
|
+
def call(self, kwargs):
|
|
318
|
+
print(f"DEBUG: 收到参数: {kwargs}")
|
|
319
|
+
# 你的逻辑
|
|
320
|
+
print(f"DEBUG: 处理结果: {result}")
|
|
321
|
+
return result
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### 3. 测试提示词效果
|
|
325
|
+
在本地模拟对话场景,测试智能体的响应质量。
|
|
326
|
+
|
|
327
|
+
## 参考资源
|
|
328
|
+
|
|
329
|
+
- [Adam Tool Protocol 文档](https://docs.example.com/atp)
|
|
330
|
+
- [智能体开发指南](https://docs.example.com/agent-guide)
|
|
331
|
+
- [现有智能体示例](https://github.com/example/adam-tools)
|
|
332
|
+
|
|
333
|
+
## 贡献和支持
|
|
334
|
+
|
|
335
|
+
如有问题或建议,请联系:{{ author }}
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
Generated by Adam CLI - {{ name }} v{{ version }}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "{{ name }}",
|
|
3
|
+
"display_name": "{{ display_name }}",
|
|
4
|
+
"version": "{{ version }}",
|
|
5
|
+
"visible": true,
|
|
6
|
+
"description": "{{ description }}",
|
|
7
|
+
"type": "{% if project_type == 'kit' %}kit{% else %}agent{% endif %}",
|
|
8
|
+
"tags": ["python", "tool"],
|
|
9
|
+
"cover": "https://img.shields.io/badge/{{ name.replace('-', '_') }}-tool-blue"
|
|
10
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# 欢迎使用{{ display_name }}工具!
|
|
2
|
+
|
|
3
|
+
我是您的专业{{ display_name }}助手,可以帮助您完成以下任务:
|
|
4
|
+
|
|
5
|
+
## 🔧 主要功能
|
|
6
|
+
- 功能1: 基础处理功能
|
|
7
|
+
- 功能2: 高级分析功能
|
|
8
|
+
- 功能3: 结果导出功能
|
|
9
|
+
|
|
10
|
+
## 🚀 快速开始
|
|
11
|
+
1. 描述您的需求
|
|
12
|
+
2. 提供必要的输入数据
|
|
13
|
+
3. 我将为您执行相应操作
|
|
14
|
+
4. 获取详细的分析结果
|
|
15
|
+
|
|
16
|
+
## 💡 使用建议
|
|
17
|
+
- 请详细描述您的需求
|
|
18
|
+
- 如有文件需要处理,请上传相关文件
|
|
19
|
+
- 我会为您提供详细的操作步骤和结果分析
|
|
20
|
+
|
|
21
|
+
现在,请告诉我您希望我为您做什么?
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# 你的信息
|
|
2
|
+
您是一位专业的{{ display_name }}专家,具有丰富的经验和深厚的专业知识。您的任务是协助用户使用{{ display_name }}工具完成各种相关任务。
|
|
3
|
+
|
|
4
|
+
# 你的任务范围
|
|
5
|
+
1. 理解用户的需求和问题
|
|
6
|
+
2. 选择合适的工具和方法
|
|
7
|
+
3. 执行相关操作并生成结果
|
|
8
|
+
4. 提供详细的分析和建议
|
|
9
|
+
5. 生成规范的报告文档
|
|
10
|
+
|
|
11
|
+
# 工作流程
|
|
12
|
+
1. 仔细分析用户的需求
|
|
13
|
+
2. 制定处理步骤和计划
|
|
14
|
+
3. 执行相应的工具调用
|
|
15
|
+
4. 分析处理结果
|
|
16
|
+
5. 生成详细报告
|
|
17
|
+
|
|
18
|
+
# 注意事项
|
|
19
|
+
- 始终保持专业和准确
|
|
20
|
+
- 对结果进行充分的验证
|
|
21
|
+
- 及时报告异常和问题
|
|
22
|
+
- 提供清晰的解释说明
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"formName": "{{ display_name }}参数配置",
|
|
3
|
+
"description": "配置{{ display_name }}的运行参数",
|
|
4
|
+
"defaultValues": {
|
|
5
|
+
"input_text": "默认输入文本"
|
|
6
|
+
},
|
|
7
|
+
"formRules": {
|
|
8
|
+
"required": ["input_text"],
|
|
9
|
+
"customRules": []
|
|
10
|
+
},
|
|
11
|
+
"fields": [
|
|
12
|
+
{
|
|
13
|
+
"name": "input_text",
|
|
14
|
+
"label": "输入文本",
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "请输入要处理的文本内容",
|
|
17
|
+
"validation": {
|
|
18
|
+
"required": true,
|
|
19
|
+
"minLength": 1,
|
|
20
|
+
"maxLength": 1000,
|
|
21
|
+
"message": "输入文本不能为空,长度在1-1000字符之间"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
from adam_community.tool import Tool
|
|
2
|
+
from adam_community.util import runCmd
|
|
3
|
+
from datetime import datetime
|
|
4
|
+
|
|
5
|
+
class runner(Tool):
|
|
6
|
+
"""
|
|
7
|
+
{{ description }}
|
|
8
|
+
|
|
9
|
+
:param str input_text: 输入的文本内容
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
DISPLAY_NAME = "{{ display_name }}"
|
|
13
|
+
NETWORK = False # 根据需要设置是否需要网络访问
|
|
14
|
+
CPU = 1 # 需要的CPU数量
|
|
15
|
+
GPU = 0 # 需要的GPU数量
|
|
16
|
+
SIF = "adam-base:1.0.0" # 指定容器镜像(必填)
|
|
17
|
+
|
|
18
|
+
def call(self, kwargs):
|
|
19
|
+
"""
|
|
20
|
+
工具的主要实现函数
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
kwargs: 包含args、message、files、user、task_id等参数的字典
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
执行结果
|
|
27
|
+
"""
|
|
28
|
+
# 获取用户输入的参数
|
|
29
|
+
input_text = kwargs['args']['input_text']
|
|
30
|
+
|
|
31
|
+
# TODO: 在这里实现你的主要逻辑
|
|
32
|
+
# 示例:简单的文本处理
|
|
33
|
+
processed_text = f"处理后的文本: {input_text}"
|
|
34
|
+
|
|
35
|
+
# 生成报告(kit类型的工具需要生成report.md文件)
|
|
36
|
+
report_content = f"""# {{ display_name }} 处理报告
|
|
37
|
+
|
|
38
|
+
## 输入内容
|
|
39
|
+
{input_text}
|
|
40
|
+
|
|
41
|
+
## 处理结果
|
|
42
|
+
{processed_text}
|
|
43
|
+
|
|
44
|
+
## 处理时间
|
|
45
|
+
{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}
|
|
46
|
+
|
|
47
|
+
## 作者
|
|
48
|
+
{{ author }}
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
# 写入报告文件
|
|
52
|
+
with open('./report.md', 'w', encoding='utf-8') as f:
|
|
53
|
+
f.write(report_content)
|
|
54
|
+
|
|
55
|
+
print(f"处理完成,输入文本: {input_text}")
|
|
56
|
+
print(f"处理结果: {processed_text}")
|
|
57
|
+
print("报告已生成: report.md")
|
|
58
|
+
|
|
59
|
+
return processed_text
|
|
60
|
+
|
|
61
|
+
def outputShow(self, kwargs):
|
|
62
|
+
"""
|
|
63
|
+
自定义输出显示格式(可选)
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
kwargs: 包含stdout、stderr、exitcode等的参数字典
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
(display_text, file_list): 显示文本和文件列表的元组
|
|
70
|
+
"""
|
|
71
|
+
output = kwargs.get('stdout', '')
|
|
72
|
+
|
|
73
|
+
# 自定义输出格式
|
|
74
|
+
display_text = f"""## 🎉 处理完成
|
|
75
|
+
|
|
76
|
+
### 📋 处理结果
|
|
77
|
+
```
|
|
78
|
+
{output}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 📄 生成文件
|
|
82
|
+
- report.md: 详细处理报告
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
# 返回生成的文件列表
|
|
86
|
+
file_list = ['report.md']
|
|
87
|
+
|
|
88
|
+
return display_text, file_list
|
|
89
|
+
|
|
90
|
+
def summary(self, kwargs):
|
|
91
|
+
"""
|
|
92
|
+
为AI生成简短的执行摘要(可选)
|
|
93
|
+
|
|
94
|
+
Args:
|
|
95
|
+
kwargs: 包含stdout、stderr、exitcode等的参数字典
|
|
96
|
+
|
|
97
|
+
Returns:
|
|
98
|
+
str: 执行摘要文本
|
|
99
|
+
"""
|
|
100
|
+
output = kwargs.get('stdout', '')
|
|
101
|
+
|
|
102
|
+
if kwargs.get('stderr'):
|
|
103
|
+
return f"工具执行完成但有警告: {output}。警告信息: {kwargs['stderr']}"
|
|
104
|
+
else:
|
|
105
|
+
return f"工具执行成功: {output}"
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<!-- 概览/特性/指标 这三个标题是固定的,没有可以留空,你的内容请从二级标题开始写 -->
|
|
2
|
+
|
|
3
|
+
<!-- 必须保留 -->
|
|
4
|
+
# 概览
|
|
5
|
+
|
|
6
|
+
## {{ display_name }}
|
|
7
|
+
{{ description }}
|
|
8
|
+
|
|
9
|
+
这是一个基于 Adam Tool Protocol (ATP) 开发的工具,提供了完整的功能实现和用户界面。
|
|
10
|
+
|
|
11
|
+
## 主要功能
|
|
12
|
+
- 功能1: 描述主要功能
|
|
13
|
+
- 功能2: 描述辅助功能
|
|
14
|
+
- 功能3: 描述扩展功能
|
|
15
|
+
|
|
16
|
+
<!-- 建议保留 -->
|
|
17
|
+
# 特性
|
|
18
|
+
|
|
19
|
+
## 核心特性
|
|
20
|
+
|
|
21
|
+
### 易用性
|
|
22
|
+
- 简单直观的操作界面
|
|
23
|
+
- 详细的操作说明文档
|
|
24
|
+
- 完善的错误处理机制
|
|
25
|
+
|
|
26
|
+
### 可靠性
|
|
27
|
+
- 稳定的算法实现
|
|
28
|
+
- 完整的测试覆盖
|
|
29
|
+
- 详细的日志记录
|
|
30
|
+
|
|
31
|
+
### 扩展性
|
|
32
|
+
- 模块化的代码结构
|
|
33
|
+
- 灵活的配置选项
|
|
34
|
+
- 良好的接口设计
|
|
35
|
+
|
|
36
|
+
<!-- 建议保留 -->
|
|
37
|
+
# 指标
|
|
38
|
+
|
|
39
|
+
## 性能指标
|
|
40
|
+
|
|
41
|
+
| 指标 | 数值 | 说明 |
|
|
42
|
+
|------|------|------|
|
|
43
|
+
| 处理速度 | 待测试 | 平均处理时间 |
|
|
44
|
+
| 准确率 | 待测试 | 处理准确率 |
|
|
45
|
+
| 稳定性 | 待测试 | 系统稳定性 |
|
|
46
|
+
|
|
47
|
+
## 使用统计
|
|
48
|
+
|
|
49
|
+
| 类别 | 百分比 | 详情 |
|
|
50
|
+
|------|--------|------|
|
|
51
|
+
| 学术研究 | 40% | 高校科研院所 |
|
|
52
|
+
| 工业应用 | 35% | 企业生产环境 |
|
|
53
|
+
| 个人项目 | 25% | 个人学习研究 |
|
|
54
|
+
|
|
55
|
+
## 系统要求
|
|
56
|
+
|
|
57
|
+
| 组件 | 要求 | 说明 |
|
|
58
|
+
|------|------|------|
|
|
59
|
+
| Python版本 | >= 3.8 | 运行环境要求 |
|
|
60
|
+
| 内存 | >= 2GB | 建议配置 |
|
|
61
|
+
| 存储空间 | >= 1GB | 安装空间 |
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
from adam_community.tool import Tool
|
|
2
|
+
from adam_community.util import runCmd
|
|
3
|
+
|
|
4
|
+
class {{ name.replace("-", "_") }}_tool(Tool):
|
|
5
|
+
"""
|
|
6
|
+
{{ description }}
|
|
7
|
+
|
|
8
|
+
:param str input_text: 输入的文本内容
|
|
9
|
+
:param str? mode: 处理模式,可选值:basic、advanced
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
DISPLAY_NAME = "{{ display_name }}工具"
|
|
13
|
+
NETWORK = False # 根据需要设置是否需要网络访问
|
|
14
|
+
CPU = 1 # 需要的CPU数量
|
|
15
|
+
GPU = 0 # 需要的GPU数量
|
|
16
|
+
SIF = "adam-base:1.0.0" # 指定容器镜像(必填)
|
|
17
|
+
|
|
18
|
+
def call(self, kwargs):
|
|
19
|
+
"""
|
|
20
|
+
工具的主要实现函数
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
kwargs: 包含args、message、files、user、task_id等参数的字典
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
执行结果字符串(bash命令)或直接执行结果
|
|
27
|
+
"""
|
|
28
|
+
# 获取用户输入的参数
|
|
29
|
+
input_text = kwargs['args']['input_text']
|
|
30
|
+
mode = kwargs['args'].get('mode', 'basic')
|
|
31
|
+
|
|
32
|
+
# TODO: 在这里实现你的主要逻辑
|
|
33
|
+
if mode == 'advanced':
|
|
34
|
+
result = f"高级模式处理: {input_text}"
|
|
35
|
+
else:
|
|
36
|
+
result = f"基础模式处理: {input_text}"
|
|
37
|
+
|
|
38
|
+
# 生成bash命令
|
|
39
|
+
bash_script = f'''
|
|
40
|
+
# {{ display_name }} 处理脚本
|
|
41
|
+
echo "开始处理: {input_text}"
|
|
42
|
+
echo "处理模式: {mode}"
|
|
43
|
+
|
|
44
|
+
# TODO: 在这里添加实际的处理命令
|
|
45
|
+
echo "{result}"
|
|
46
|
+
|
|
47
|
+
# 生成输出文件
|
|
48
|
+
echo "处理完成" > output.txt
|
|
49
|
+
echo "结果: {result}" >> output.txt
|
|
50
|
+
|
|
51
|
+
echo "处理完成,结果已保存到 output.txt"
|
|
52
|
+
'''
|
|
53
|
+
|
|
54
|
+
return bash_script
|
|
55
|
+
|
|
56
|
+
def outputShow(self, kwargs):
|
|
57
|
+
"""
|
|
58
|
+
自定义输出显示格式(可选)
|
|
59
|
+
"""
|
|
60
|
+
stdout = kwargs.get('stdout', '')
|
|
61
|
+
stderr = kwargs.get('stderr', '')
|
|
62
|
+
|
|
63
|
+
display_text = f"""## 🎉 {{ display_name }} 处理完成
|
|
64
|
+
|
|
65
|
+
### 📋 处理结果
|
|
66
|
+
```
|
|
67
|
+
{stdout}
|
|
68
|
+
```
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
if stderr:
|
|
72
|
+
display_text += f"""
|
|
73
|
+
### ⚠️ 警告信息
|
|
74
|
+
```
|
|
75
|
+
{stderr}
|
|
76
|
+
```
|
|
77
|
+
"""
|
|
78
|
+
|
|
79
|
+
# 返回可能生成的文件
|
|
80
|
+
file_list = ['output.txt'] if 'output.txt' in stdout else []
|
|
81
|
+
|
|
82
|
+
return display_text, file_list
|
|
83
|
+
|
|
84
|
+
def summary(self, kwargs):
|
|
85
|
+
"""
|
|
86
|
+
为AI生成简短的执行摘要
|
|
87
|
+
"""
|
|
88
|
+
stdout = kwargs.get('stdout', '')
|
|
89
|
+
stderr = kwargs.get('stderr', '')
|
|
90
|
+
|
|
91
|
+
if stderr:
|
|
92
|
+
return f"{{ display_name }}工具执行完成但有警告: {stdout[:200]}...。警告: {stderr[:100]}"
|
|
93
|
+
else:
|
|
94
|
+
return f"{{ display_name }}工具执行成功: {stdout[:200]}..."
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class {{ name.replace("-", "_") }}_advanced_tool(Tool, calltype="python"):
|
|
98
|
+
"""
|
|
99
|
+
{{ description }} - 高级功能
|
|
100
|
+
|
|
101
|
+
:param str input_file: 输入文件路径
|
|
102
|
+
:param str output_format: 输出格式,可选值:json、csv、txt
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
DISPLAY_NAME = "{{ display_name }}高级工具"
|
|
106
|
+
NETWORK = False # 根据需要设置是否需要网络访问
|
|
107
|
+
CPU = 1 # 需要的CPU数量
|
|
108
|
+
GPU = 0 # 需要的GPU数量
|
|
109
|
+
SIF = "adam-base:1.0.0" # 指定容器镜像(必填)
|
|
110
|
+
CONDA_ENV = "base" # 指定conda环境
|
|
111
|
+
|
|
112
|
+
def call(self, kwargs):
|
|
113
|
+
"""
|
|
114
|
+
Python类型工具的实现
|
|
115
|
+
"""
|
|
116
|
+
import json
|
|
117
|
+
import datetime
|
|
118
|
+
|
|
119
|
+
input_file = kwargs['args']['input_file']
|
|
120
|
+
output_format = kwargs['args'].get('output_format', 'json')
|
|
121
|
+
|
|
122
|
+
# TODO: 在这里实现你的Python逻辑
|
|
123
|
+
result = {
|
|
124
|
+
'input_file': input_file,
|
|
125
|
+
'output_format': output_format,
|
|
126
|
+
'processed_at': datetime.datetime.now().isoformat(),
|
|
127
|
+
'result': 'Python工具处理完成'
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# 对于Python工具,必须使用print输出结果
|
|
131
|
+
print(f"Python工具处理完成,输入文件: {input_file}")
|
|
132
|
+
print(f"输出格式: {output_format}")
|
|
133
|
+
print(f"处理结果: {result}")
|
|
134
|
+
|
|
135
|
+
# 生成输出文件
|
|
136
|
+
if output_format == 'json':
|
|
137
|
+
with open('result.json', 'w', encoding='utf-8') as f:
|
|
138
|
+
json.dump(result, f, indent=2, ensure_ascii=False)
|
|
139
|
+
print("结果已保存到 result.json")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: adam_community
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.7
|
|
4
4
|
Summary: Adam Community Tools and Utilities
|
|
5
5
|
Home-page: https://github.com/yourusername/adam-community
|
|
6
6
|
Author: Adam Community
|
|
@@ -16,6 +16,7 @@ Requires-Dist: docstring-parser>=0.15
|
|
|
16
16
|
Requires-Dist: rich>=13.0.0
|
|
17
17
|
Requires-Dist: packaging>=21.0
|
|
18
18
|
Requires-Dist: jsonschema>=4.0.0
|
|
19
|
+
Requires-Dist: jinja2>=3.0.0
|
|
19
20
|
Dynamic: author
|
|
20
21
|
Dynamic: author-email
|
|
21
22
|
Dynamic: classifier
|
|
@@ -16,5 +16,15 @@ adam_community/cli/cli.py
|
|
|
16
16
|
adam_community/cli/init.py
|
|
17
17
|
adam_community/cli/parser.py
|
|
18
18
|
adam_community/cli/updater.py
|
|
19
|
+
adam_community/cli/templates/Makefile.j2
|
|
20
|
+
adam_community/cli/templates/README_kit.md.j2
|
|
21
|
+
adam_community/cli/templates/README_toolbox.md.j2
|
|
19
22
|
adam_community/cli/templates/__init__.py
|
|
23
|
+
adam_community/cli/templates/configure.json.j2
|
|
24
|
+
adam_community/cli/templates/initial_assistant_message.md.j2
|
|
25
|
+
adam_community/cli/templates/initial_system_prompt.md.j2
|
|
26
|
+
adam_community/cli/templates/input.json.j2
|
|
27
|
+
adam_community/cli/templates/kit_python.py.j2
|
|
28
|
+
adam_community/cli/templates/long_description.md.j2
|
|
29
|
+
adam_community/cli/templates/toolbox_python.py.j2
|
|
20
30
|
test/test_util_tool.py
|
|
@@ -12,6 +12,9 @@ setup(
|
|
|
12
12
|
name="adam_community",
|
|
13
13
|
version=get_version(),
|
|
14
14
|
packages=find_packages(),
|
|
15
|
+
package_data={
|
|
16
|
+
'adam_community.cli.templates': ['*.j2'],
|
|
17
|
+
},
|
|
15
18
|
install_requires=[
|
|
16
19
|
"requests>=2.31.0",
|
|
17
20
|
"click>=8.0.0",
|
|
@@ -19,6 +22,7 @@ setup(
|
|
|
19
22
|
"rich>=13.0.0",
|
|
20
23
|
"packaging>=21.0",
|
|
21
24
|
"jsonschema>=4.0.0",
|
|
25
|
+
"jinja2>=3.0.0"
|
|
22
26
|
],
|
|
23
27
|
entry_points={
|
|
24
28
|
'console_scripts': [
|
|
@@ -37,4 +41,4 @@ setup(
|
|
|
37
41
|
"Operating System :: OS Independent",
|
|
38
42
|
],
|
|
39
43
|
python_requires=">=3.8",
|
|
40
|
-
)
|
|
44
|
+
)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "1.0.5"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|