prompted-generator
GitHubPromptedGenerator算子参考文档,涵盖构造函数、run方法及数据流集成细节。用于在DataFlow管道中实现单字段LLM生成,处理DataFrame行级文本输入与批量调用。
Trigger Scenarios
Install
npx skills add OpenDCAI/DataFlow-WebUI --skill prompted-generator -g -y
SKILL.md
Frontmatter
{
"name": "prompted-generator",
"description": "Reference documentation for the PromptedGenerator operator. Covers constructor parameters, run() signature, actual row-processing behavior, and pipeline usage notes. Use when: integrating PromptedGenerator into a DataFlow pipeline for single-field LLM generation."
}
PromptedGenerator Operator Reference
PromptedGenerator is DataFlow's basic single-field LLM generation operator.
For each row in the current DataFrame, it reads the value from input_key. If that value is truthy, it builds one LLM input as:
user_prompt + str(row[input_key])
It then calls llm_serving.generate_from_input(...) in batch and writes the
generated results into output_key.
1. Import
from dataflow.operators.core_text import PromptedGenerator
2. Constructor
PromptedGenerator(
llm_serving, # required
system_prompt="You are a helpful agent.", # optional
user_prompt="", # optional
json_schema=None, # optional
)
| Parameter | Required | Default | Description |
|---|---|---|---|
llm_serving |
Yes | None | LLM service object implementing generate_from_input(...) |
system_prompt |
No | "You are a helpful agent." |
System prompt passed to the serving layer |
user_prompt |
No | "" |
Prefix prepended directly before each valid row's input text |
json_schema |
No | None |
Optional schema forwarded to the serving layer |
3. run() Signature
op.run(
storage=self.storage.step(),
input_key="raw_content",
output_key="generated_content",
)
# returns: output_key
| Parameter | Required | Default | Description |
|---|---|---|---|
storage |
Yes | None | Current operator-step storage object |
input_key |
No | "raw_content" |
Column read from the current DataFrame |
output_key |
No | "generated_content" |
Column written back to the DataFrame |
4. Actual Execution Logic
The operator performs the following steps:
- Read the current DataFrame from
storage. - Iterate over the DataFrame row by row.
- For each row, read
raw_content = row.get(input_key, ""). - Only if
raw_contentis truthy, appenduser_prompt + str(raw_content)to the batch LLM input list. - Call:
llm_serving.generate_from_input(
user_inputs=llm_inputs,
system_prompt=system_prompt,
json_schema=json_schema,
)
- Write the generated list into
dataframe[output_key]. - Persist the updated DataFrame through
storage.write(dataframe). - Return
output_key.
5. Important Rules
input_keymust exist in the current DataFrame.user_promptis a plain string prefix, not a template engine.- The implementation skips rows whose
input_keyvalue is empty,None, or otherwise falsy when building LLM inputs.
6. Typical Usage
from dataflow.operators.core_text import PromptedGenerator
prompted_gen = PromptedGenerator(
llm_serving=self.llm_serving,
system_prompt="You are a helpful agent.",
user_prompt="Summarize the following content in one sentence:\n",
)
prompted_gen.run(
storage=self.storage.step(),
input_key="raw_content",
output_key="summary",
)
7. Return Value
return output_key
This is intended for downstream operator chaining.
Version History
- 2e95d40 Current 2026-08-27 09:04


