| 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. |
| trigger_keywords | ["PromptedGenerator","prompted-generator","single-field generation","LLM generation"] |
| version | 1.0.0 |
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,
system_prompt="You are a helpful agent.",
user_prompt="",
json_schema=None,
)
| 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",
)
| 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_content is truthy, append user_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_key must exist in the current DataFrame.
user_prompt is a plain string prefix, not a template engine.
- The implementation skips rows whose
input_key value 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.