How to Draft Long Form AI Content With Coherence

In this tutorial, we'll create a sophisticated action that helps write long-form content by breaking it down into manageable sections. The action will take writing instructions, create a detailed plan, and then execute that plan section by section while maintaining coherence throughout the piece.

Reference: https://arxiv.org/pdf/2408.07055

Overview

The "Long Writer" action works in three main steps:

  1. Gather writing instructions from the user

  2. Create a detailed plan breaking down the content into sections

  3. Execute the plan section by section, maintaining continuity with previously written content

Creating the Action

Let's build this action step by step.

Step 1: Initial Setup

  1. Open the Actions panel in Chibi

  2. Click "Create Action"

  3. Name your action "Long Writer"

  4. Add a description: "Breaks down and writes long-form content section by section"

Step 2: Adding the Input Task

First, we'll add a task to collect writing instructions from the user.

  1. Click "Add Task"

  2. Select "Ask for Input"

  3. Configure the task:

    • Task Name: "Get Writing Instructions"

    • Task Variable Name: "Instructions"

    • Placeholder: "Enter detailed instructions for what you want written. Include any requirements about length, style, tone, or specific content needs."

Step 3: Setting Up the Planning Task

Next, we'll add a task that breaks down the writing instructions into a detailed plan.

  1. Click "Add Task"

  2. Select "Run Prompt"

  3. Configure the task:

    • Task Name: "Create Writing Plan"

    • Task Variable Name: "WritingPlan"

    • Prompt:

<Writing Instructions>
{{Instructions}}
</Writing Instructions>
<additional context>
{{MemoryStack}}
</additional context>

Take your time and think step by step. Break down the writing instructions into multiple subtasks such that they will fulfill the writing instructions completely.

Each subtask will guide the writing of one section in the story, and should include the main points and word count requirements for that section.

Break the writing instruction down in the following format, with each subtask taking up one line:
Section 1 - Main Point: {Describe the main point of the section, in detail} - Word Count: {Word count requirement, e.g., 400 words}.
Section 2 - Main Point: {Describe the main point of the section, in detail} - Word Count: {word count requirement, e.g. 1000 words}.
...

Make sure that each subtask is clear and specific, and that all subtasks cover the entire content expected of the writing instruction.
ALWAYS make sure there are enough subtasks to write the amount of words asked for in the writing instructions.
Do not split the subtasks too finely; each subtask's section should be no less than 300 words and no more than 700 words.
Do not output any other content.
  1. For AI settings:

    • Choose "Custom AI Settings"

    • Select a capable model (needs strong planning abilities)

    • Set temperature to 0.35-0.5 to balance creativity with consistency

    • Set maximum length appropriately for your needs

Step 4: Creating the Writing Loop

Finally, we'll set up the loop that processes each section of the plan.

  1. Click "Add Task"

  2. Select "Line by Line"

  3. Configure the task:

    • Task Name: "Write Each Section"

    • Task Variable Name: "StepPlan"

  4. Inside the Line by Line task, add a Stream Prompt:

    • Task Name: "Write Section"

    • Prompt:

<Original Writing Instructions>
{{Instructions}}
</Original Writing Instructions>

<Next Section Writing Plan>
{{StepPlan}}
</Next Section Writing Plan>

<Already Written Text>
{{WholeDocument}}
</Already Written Text>

Write the next section based on the next section writing plan. Weave the story along and don't repeat scenes, dialogue, etc. from the already written text. Use the already written text as a guide for what to write next based on the next section writing plan.
  1. Configure the Stream Prompt's AI settings:

    • Choose "Custom AI Settings"

    • Select a model that can accept a large input (consider a low-cost model too, such as Google Gemini 1.5 Flash)

    • Set temperature to 0.8 for creative writing, lower for article writing

    • Set maximum length high enough to accommodate the section word counts

    • Enable "Add a line break after writing ends" and also the "Wait for Fresh Context" option

Wait for Fresh Context is very important here. If you do not turn this on then the {{WholeDocument}} variable will not contain the new content written by the action. This is a key part of this technique.

Using the Action

  1. Place your cursor where you want the content to appear in your document

  2. Run the "Long Writer" action

  3. Enter your writing instructions, being as specific as possible about:

    • Overall topic or story

    • Desired length

    • Style and tone

    • Key points to cover

    • Any specific requirements

The action will then:

  1. Process your instructions

  2. Create a sectioned plan

  3. Write each section while maintaining continuity

Tips for Best Results

  1. Be detailed in your initial instructions. The more specific you are, the better the results will be.

  2. Consider using document memory to provide additional context about style, characters, or other important elements.

  3. Review the generated plan in the action's log if you want to see how it's breaking down the content.

  4. The action works best when your instructions include a clear target length (e.g., "write a 2000-word article about...")

Customizing the Action

Take time to adjust the prompts and AI settings to match your specific needs. You might want to:

  • Modify the planning prompt to break sections down differently

  • Adjust the writing prompt to emphasize different aspects of continuity, style, etc.

  • Fine-tune the AI settings for different types of content

  • Add additional context or style instructions to the prompts

Remember that you can always refine the prompts and AI settings to better match your writing style and needs. The success of this action largely depends on how well you customize these elements for your specific use case.

Was this helpful?