OpenParable
Skip to content
← Back to skills

Nested Aggregator

Documents
nested_aggregator

Nested Aggregator is an Agent Skill for documents published in the cas-bigdatalab/piflow repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

嵌套聚合工具。将多个文档碎片整合成一个连贯的文档总结。 当用户提到文档摘要、整合文档、文档聚合、碎片整合、长文总结等需求时使用此skill。 即使用户没有明确说出"嵌套"或"聚合",只要任务涉及将多个短文档整合成一个总结, 就应该使用此skill。

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/cas-bigdatalab/piflow/blob/HEAD/workspace/skills/nested_aggregator/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/nested-aggregator, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Nested Aggregator 嵌套聚合 Skill

功能概述

本skill通过调用大语言模型(LLM)API,将多个分散的文档碎片智能整合成一个连贯的文档总结。 适用于处理长文档分段后的聚合、多个相关片段的整合等场景。

触发条件

当用户请求以下任务时,应使用此skill:

  • 文档摘要
  • 整合文档
  • 文档聚合
  • 碎片整合
  • 长文总结
  • 多段合一

核心参数说明

必需参数

参数说明
--input输入JSON文件路径
--output输出JSON文件路径
--api_modelAPI模型名称

可选参数

参数说明默认值
--input_key输入文档的键名event_description
--output_key输出结果的键名与 input_key 相同
--max_token_num每个分组最大token数None
--api_endpointAPI端点URLNone

输入文件格式

{
  "meta": [
    {"event_description": "文档碎片1内容..."},
    {"event_description": "文档碎片2内容..."},
    {"event_description": "文档碎片3内容..."}
  ]
}

或自定义键名:

{
  "meta": [
    {"sub_docs": "文档碎片1内容..."},
    {"sub_docs": "文档碎片2内容..."},
    {"sub_docs": "文档碎片3内容..."}
  ]
}

使用方法

基本用法

python scripts/run_nested_aggregator.py \
  --input ./input.json \
  --output ./output.json \
  --api_model qwen2.5-72b-instruct

自定义输入键名

python scripts/run_nested_aggregator.py \
  --input ./input.json \
  --output ./output.json \
  --api_model qwen2.5-72b-instruct \
  --input_key sub_docs

限制每组token数量

python scripts/run_nested_aggregator.py \
  --input ./input.json \
  --output ./output.json \
  --api_model qwen2.5-72b-instruct \
  --max_token_num 100

输出示例

命令行输出:

[OK] Nested aggregation completed!
   API model: qwen2.5-72b-instruct
   Input key: event_description
   Input file: ./input.json
   Output file: ./output.json

输出JSON格式:

[
  {
    "event_description": "整合后的完整文档总结..."
  }
]

环境要求

安装依赖: 本SKILL使用依赖 data_juicer,请在调用前安装好python环境并安装data_juicer,可用以下指令进行安装:

pip install py-data-juicer

API配置:

export OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1/
export OPENAI_API_KEY=your_api_key

注意事项

  1. 必需参数:需要指定 --api_model
  2. 输入格式:输入JSON必须包含 meta 字段
  3. 整合逻辑:LLM会自动将多个碎片整合成连贯的总结
  4. 保留信息:会尽可能保留原文中的专有名词和关键信息