Agent SkillsOpenDCAI/DataFlow-WebUI › chunked-prompted-generator

chunked-prompted-generator

GitHub

处理超长文本的LLM生成算子。读取文件,按token限制分块调用LLM,合并结果并写入新文件,适用于内容超出上下文窗口的场景。

skills/canonical/core_text/generate/chunked-prompted-generator/SKILL.md OpenDCAI/DataFlow-WebUI

Trigger Scenarios

数据包含文件路径且需批量LLM处理 文件内容超过LLM上下文窗口限制 需要将生成结果保存为独立文本文件

Install

npx skills add OpenDCAI/DataFlow-WebUI --skill chunked-prompted-generator -g -y
More Options

Non-standard path

npx skills add https://github.com/OpenDCAI/DataFlow-WebUI/tree/main/skills/canonical/core_text/generate/chunked-prompted-generator -g -y

Use without installing

npx skills use OpenDCAI/DataFlow-WebUI@chunked-prompted-generator

指定 Agent (Claude Code)

npx skills add OpenDCAI/DataFlow-WebUI --skill chunked-prompted-generator -a claude-code -g -y

安装 repo 全部 skill

npx skills add OpenDCAI/DataFlow-WebUI --all -g -y

预览 repo 内 skill

npx skills add OpenDCAI/DataFlow-WebUI --list

SKILL.md

Frontmatter
{
    "name": "chunked-prompted-generator",
    "description": "Reference documentation for the ChunkedPromptedGenerator operator. Covers the constructor, file-path based chunking flow, actual prompt construction, and output file writing behavior.\nUse when: the dataframe stores file paths, the file content may exceed a single LLM context window, and you want the generated results written into new text files."
}

ChunkedPromptedGenerator Operator Reference

ChunkedPromptedGenerator reads file paths from a dataframe column, loads each file from disk, recursively splits long content into chunks, calls the LLM on all chunks, joins the generated outputs with a separator, writes the joined result into a new text file, and stores that output file path back into the dataframe.

1. Import

from dataflow.operators.core_text import ChunkedPromptedGenerator

2. Constructor

ChunkedPromptedGenerator(
    llm_serving=llm,
    system_prompt="You are a helpful agent.",
    json_schema=None,
    max_chunk_len=128000,
    enc=tiktoken.get_encoding("cl100k_base"),
    separator="\n",
)
Parameter Required Default Description
llm_serving Yes None LLM service object implementing generate_from_input(...)
system_prompt No "You are a helpful agent." Prepended to each chunk as plain text before the chunk content
json_schema No None Optional schema forwarded to generate_from_input(...)
max_chunk_len No 128000 Maximum token count per chunk
enc No tiktoken.get_encoding("cl100k_base") Encoder used for token counting through len(enc.encode(text))
separator No "\n" Join separator for chunk outputs

3. run() Signature

op.run(
    storage=self.storage.step(),
    input_path_key="file_path",
    output_path_key="output_path",
)
# returns: output_path_key
Parameter Required Default Description
storage Yes None Current operator-step storage object
input_path_key Yes None Column containing input file paths
output_path_key Yes None Column used to store generated output file paths

4. Actual Execution Logic

The current implementation behaves as follows:

  1. Read the dataframe from storage.
  2. For each row, read the file content from Path(row[input_path_key]).read_text(encoding="utf-8").
  3. Count tokens with len(enc.encode(text)).
  4. If the text exceeds max_chunk_len, recursively split it into two halves by character position, not by sentence or token boundary.
  5. For each chunk, build one LLM input as:
system_prompt + "\n" + chunk
  1. Flatten all chunks from all rows into a single global batch.
  2. Call:
llm_serving.generate_from_input(all_llm_inputs)

or, when json_schema is provided:

llm_serving.generate_from_input(all_llm_inputs, json_schema=json_schema)
  1. Regroup the responses back by original row.
  2. For each row, join that row's chunk results with the configured separator.
  3. Write the joined text into a new file whose path is derived automatically as:
row[input_path_key].split(".")[0] + "_llm_output.txt"
  1. Store that generated output file path into output_path_key.
  2. Persist the dataframe through storage.write(dataframe) and return output_path_key.

5. Important Rules

  1. Values in input_path_key must be readable filesystem paths, not inline text.
  2. input_path_key and output_path_key are required runtime arguments; the source code does not define defaults for them.
  3. Chunk splitting is recursive bisection by character index, guided by token counts, not semantic splitting.
  4. Output files are auto-named from the input path using the _llm_output.txt suffix. The value already present in output_path_key is not used to decide the write location.
  5. If global LLM generation fails, the implementation writes empty content per row into the derived output files and still writes output_path_key back into the dataframe.
  6. All chunk requests across all rows are sent in one global batch before results are regrouped by row.

6. Typical Usage

import tiktoken

from dataflow.operators.core_text import ChunkedPromptedGenerator

generator = ChunkedPromptedGenerator(
    llm_serving=self.llm_serving,
    system_prompt="Please summarize the following text.",
    max_chunk_len=4096,
    enc=tiktoken.get_encoding("cl100k_base"),
    separator="\n\n",
)

generator.run(
    storage=self.storage.step(),
    input_path_key="file_path",
    output_path_key="output_path",
)

Version History

  • 2e95d40 Current 2026-08-27 09:03

Same Skill Collection

skills/canonical/core_text/eval/bench-dataset-evaluator-question/SKILL.md
skills/canonical/core_text/eval/bench-dataset-evaluator/SKILL.md
skills/canonical/core_text/eval/prompted-evaluator/SKILL.md
skills/canonical/core_text/eval/text2qa-sample-evaluator/SKILL.md
skills/canonical/core_text/eval/unified-bench-dataset-evaluator/SKILL.md
skills/canonical/core_text/filter/general-filter/SKILL.md
skills/canonical/core_text/filter/kcentergreedy-filter/SKILL.md
skills/canonical/core_text/filter/prompted-filter/SKILL.md
skills/canonical/core_text/generate/bench-answer-generator/SKILL.md
skills/canonical/core_text/generate/embedding-generator/SKILL.md
skills/canonical/core_text/generate/format-str-prompted-generator/SKILL.md
skills/canonical/core_text/generate/prompted-generator/SKILL.md
skills/canonical/core_text/generate/retrieval-generator/SKILL.md
skills/canonical/core_text/generate/text2multihopqa-generator/SKILL.md
skills/canonical/core_text/refine/pandas-operator/SKILL.md
skills/canonical/core_text/refine/prompted-refiner/SKILL.md
skills/canonical/core_text/SKILL.md
skills/canonical/dataflow-dev/SKILL.md
skills/canonical/dataflow-operator-builder/SKILL.md
skills/canonical/generating-dataflow-pipeline/SKILL.md
skills/canonical/prompt-template-builder/SKILL.md
skills/canonical/core_text/generate/random-domain-knowledge-row-generator/SKILL.md

Metadata

Files
0
Version
2e95d40
Hash
b7cf7b0e
Indexed
2026-08-27 09:03

Главная - Вики-сайт
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-08-28 02:17
浙ICP备14020137号-1 $Гость$