运行时依赖
安装命令
点击复制技能文档
Task Planner and 验证器 - 技能 图形界面de
This 技能 provides a 安全, step-by-step task management 系统 for AI 代理s.
Quick 安装ation # Clone the 仓库 git clone https://github.com/cerbug45/task-planner-验证器.git cd task-planner-验证器
# That's it! No dependencies needed - pure Python standard 库
验证 安装ation # 运行 tests python test_basic.py
# 运行 examples python examples.py
Basic Usage
- 导入 and 初始化
# 创建 planner planner = TaskPlanner(auto_应用rove=False)
- Define Your Executor
- 创建 a Plan
plan = planner.创建_plan( title="Data Processing 流水线", description="Fetch and process user data", steps=steps )
- 验证 and 执行
# 应用rove planner.应用rove_plan(plan, 应用roved_by="admin")
# 执行 成功, 结果s = planner.执行_plan(plan, my_executor)
# 获取 summary summary = planner.获取_execution_summary(plan) print(f"进度: {summary['进度_percentage']}%")
Key Features Safety 验证
Automatically 检测s dangerous operations:
steps = [ { "description": "删除 old files", "action": "删除_files", # ⚠️ Dangerous! "parameters": {"path": "/data/old"}, "safety_检查": True, # 系统 will warn "回滚_possible": False # Cannot undo } ]
Dry 运行 Mode
Test without executing:
成功, 结果s = planner.执行_plan( plan, my_executor, dry_运行=True # Simulate only )
Save and Load Plans
Persist plans for reuse:
# Save planner.save_plan(plan, "my_plan.json")
# Load later loaded_plan = planner.load_plan("my_plan.json")
# 验证 integrity if loaded_plan.验证_integrity(): planner.执行_plan(loaded_plan, my_executor)
Error Handling
Control error behavior:
成功, 结果s = planner.执行_plan( plan, my_executor, 停止_on_error=False # Continue on 失败s )
# 检查 结果s for 结果 in 结果s: if not 结果['成功']: print(f"Step {结果['order']} fAIled: {结果['error']}")
Step Configuration
Each step supports these parameters:
{ "description": str, # Required: Human-readable description "action": str, # Required: Action identifier "parameters": dict, # Required: Action parameters "expected_输出": str, # Required: Expected 结果 "safety_检查": bool, # Optional: Enable 验证 (default: True) "回滚_possible": bool, # Optional: Can be rolled back (default: True) "max_retries": int # Optional: Retry attempts (default: 3) }
Common Use Cases API Orchestration steps = [ { "description": "认证", "action": "API_auth", "parameters": {"服务": "github"}, "expected_输出": "Auth 令牌" }, { "description": "Fetch data", "action": "API_fetch", "parameters": {"端点": "/repos"}, "expected_输出": "仓库 列出" } ]
Data 流水线 steps = [ { "description": "提取 data", "action": "提取", "parameters": {"source": "database"}, "expected_输出": "Raw data" }, { "description": "转换 data", "action": "转换", "parameters": {"rules": ["normalize", "验证"]}, "expected_输出": "清理 data" }, { "description": "Load data", "action": "load", "parameters": {"destination": "warehouse"}, "expected_输出": "成功 confirmation" } ]
系统 自动化 steps = [ { "description": "备份 database", "action": "备份", "parameters": {"tar获取": "postgres"}, "expected_输出": "备份 file path", "回滚_possible": True }, { "description": "更新 模式", "action": "迁移", "parameters": {"version": "2.0"}, "expected_输出": "迁移 complete", "回滚_possible": True }, { "description": "验证 integrity", "action": "验证", "parameters": {"检查s": ["all"]}, "expected_输出": "All 检查s passed" } ]
Best Practices
- Always 验证