Generative AIby Dhruv Narang

The Problem: One Big Prompt Does Too Much

We want to turn a rough text into a Hinglish video script.

The issue
We have a rough text. We want a clean, catchy video script in Hinglish.
The first try
One prompt: “Fix the grammar, make it a video script, and translate it to Hinglish.”
Why it fails
The model does three jobs at once, and does each one a little worse. When the result is bad, you cannot tell which job went wrong. And you cannot change one job without touching the others.
The fix
Split it into three small jobs, each in its own node, one after another. This is a sequential workflow.

The Idea: An Assembly Line

Definition

A sequential workflow is a graph whose nodes run one after another in a fixed order. Each node reads what the one before it wrote, and writes its own result into the state.

raw_inputeditoredited_textscriptwriterscript_texttranslatorfinal_outputstate key (gold) · node (teal)
NodeIts jobReadsWrites
editorfix grammar and spelling, smooth the flowraw_inputedited_text
scriptwriterturn the clean text into a catchy video scriptedited_textscript_text
translatorturn the script into natural Hinglishscript_textfinal_output
Nothing is passed by hand. Each node reads a key that an earlier node wrote. The state carries the work from step to step.

The Three Nodes

Each node has one job and its own role in the prompt.

Editor
“You are an expert copyeditor.” Cleans the text and keeps the meaning.
Scriptwriter
“You are a charismatic YouTube content creator.” Makes it punchy and conversational.
Translator
“You are an expert content localizer for the Indian market.” Writes natural Hinglish, not a word-by-word translation.
def scriptwriter_node(state:pipelinestate):
    """Stage 2: Formats the clean text into an engaging video script style."""

    prompt = (
        "You are a charismatic YouTube content creator. Take this edited text and transform "
        "it into a highly engaging, punchy, conversational video script hook. Make it sound "
        "like a real person speaking passionately. Return only the script content.\n\n"
        f"Edited Text:\n{state['edited_text']}"
    )

    response = model.invoke(prompt)
    return {"script_text": response.content.strip()}
The scriptwriter node in full, from your 02_sequential.py. Every node has the same shape: read one key, build a prompt, call the model, return one key.