PromptedRefiner
About 322 wordsAbout 1 min
2025-10-09
📘 Overview
PromptedRefiner is an operator that rewrites, refines, or normalizes text within a specified column of a dataframe. It operates by concatenating a user-defined system_prompt with the content of each row in the target column (input_key). The combined text is then sent to a Large Language Model (LLM) to generate a refined version. The key feature of this operator is that it performs an in-place update, overwriting the original content in the input_key column with the newly generated text.
__init__
def __init__(self, llm_serving: LLMServingABC, system_prompt: str = "You are a helpful agent."):| Parameter | Type | Default | Description |
|---|---|---|---|
| llm_serving | LLMServingABC | Required | An instance of the Large Language Model serving class, responsible for inference. |
| system_prompt | str | "You are a helpful agent." | A system-level instruction that guides the LLM on how to refine the text. |
Prompt Template Descriptions
| Prompt Template Name | Primary Use | Applicable Scenarios | Feature Description |
|---|---|---|---|
run
def run(self, storage: DataFlowStorage, input_key: str = "raw_content"):| Parameter | Type | Default | Description |
|---|---|---|---|
| storage | DataFlowStorage | Required | The dataflow storage instance for reading the input dataframe and writing the result. |
| input_key | str | "raw_content" | The name of the column containing the text to be refined. This column will be overwritten with the refined text. |
🧠 Example Usage
🧾 Default Output Format (Output Format)
The operator modifies the input dataframe in-place by overwriting the column specified by input_key. The output dataframe will have the same schema as the input, but the content of the target column will be replaced by the LLM's generated text.
| Field | Type | Description |
|---|---|---|
| other_columns | any | Other columns from the input are preserved. |
| input_key | str | The original text in this column is replaced by the refined text generated by the model. |
Example Input:
{
"id": 1,
"raw_content": "this text has several errrors and bad formatting"
}Example Output (with input_key="raw_content"):
{
"id": 1,
"raw_content": "This text has several errors and poor formatting."
}
