Certainly! Building a Large Language Model (LLM) workflow to write an entire novel from a premise and information given by the user is an ambitious but exciting project. Below is a step-by-step workflow to guide you through the process. This workflow assumes you have access to an LLM API, such as those provided by OpenAI, Google, or another provider.
Step 1: Gather User Input
Premise: Ask the user for the basic premise of the novel. This should include the main idea, genre, and any specific themes or tropes they want to include.
Example: "A dystopian future where emotions are regulated by the government, and a rebel learns to feel again."
Characters: Collect information about the main characters, including their names, backgrounds, personalities, and roles in the story.
Example:
Protagonist: Alex, a 25-year-old rebel who discovers the truth about emotions.
Antagonist: Director Kane, the stern leader of the Emotion Regulation Department.
Love Interest: Maya a fellow rebel who helps Alex on his journey.
Setting: Get details about the setting, including the time period, location, and any important aspects of the world-building.
Example: "Set in a futuristic city called Neo-Eden, where technology controls every aspect of life."
Plot Points: Ask for key plot points or events that must occur in the novel.
Example:
Alex discovers the truth about emotions.
Alex and Maya escape from Neo-Eden.
Final confrontation with Director Kane.
Style and Tone: Determine the desired writing style and tone of the novel.
Example: "Dark and gritty with a hopeful undertone."
Step 2: Outline Generation
Use the LLM to generate a detailed outline of the novel based on the user's input. Provide the LLM with the premise, characters, setting, plot points, and style/tone.
Prompt for LLM:
code
Based on the following information, generate a detailed outline for a novel:
Premise: A dystopian future where emotions are regulated by the government, and a rebel learns to feel again.
Characters:
- Protagonist: Alex, a 25-year-old rebel who discovers the truth about emotions.
- Antagonist: Director Kane, the stern leader of the Emotion Regulation Department.
- Love Interest: Maya, a fellow rebel who helps Alex on his journey.
Setting: Set in a futuristic city called Neo-Eden, where technology controls every aspect of life.
Plot Points:
1. Alex discovers the truth about emotions.
2. Alex and Maya escape from Neo-Eden.
3. Final confrontation with Director Kane.
Style and Tone: Dark and gritty with a hopeful undertone.
Please include chapter titles and a brief summary of each chapter.
Expected Output:
code
# Novel Outline: "The Emotion Rebellion"
## Chapter 1: The Regulated Life
- **Summary**: Introduce Neo-Eden and the regulated life of its citizens. Alex goes about his daily routine, unaware of the truth.
## Chapter 2: The Discovery
- **Summary**: Alex stumbles upon an old, banned book that reveals the truth about emotions. He begins to question everything he's been taught.
## Chapter 3: The First Feeling
- **Summary**: Alex experiences his first genuine emotion and is both terrified and fascinated. He seeks out others who might know more.
## Chapter 4: Meeting Maya
- **Summary**: Alex meets Maya, a fellow rebel who has also discovered the truth. They form an alliance and begin to plan their rebellion.
## Chapter 5: The Escape Plan
- **Summary**: Alex and Maya devise a plan to escape Neo-Eden and find a place where they can live freely. They gather supplies and information.
## Chapter 6: On the Run
- **Summary**: Alex and Maya execute their escape plan but are pursued by the Emotion Regulation Department. They must evade capture while navigating the dangerous outskirts of Neo-Eden.
## Chapter 7: The Hidden Sanctuary
- **Summary**: Alex and Maya find a hidden sanctuary where other rebels live. They learn more about the history of emotion regulation and plan their next move.
## Chapter 8: Gathering Allies
- **Summary**: Alex and Maya recruit more rebels to their cause. They train and prepare for the inevitable confrontation with Director Kane.
## Chapter 9: The Infiltration
- **Summary**: The rebels infiltrate Neo-Eden to gather intelligence and sabotage the Emotion Regulation Department. Alex and Maya lead the mission.
## Chapter 10: The Final Confrontation
- **Summary**: The rebels launch a full-scale attack on the Emotion Regulation Department. Alex confronts Director Kane in a climactic battle.
## Chapter 11: The New Dawn
- **Summary**: With Director Kane defeated the rebels begin to rebuild Neo-Eden, allowing citizens to experience and express their emotions freely. Alex and Maya look toward the future with hope.
Step 3: Chapter-by-Chapter Writing
Using the generated outline, write each chapter one at a time. For each chapter, provide the LLM with the chapter title, summary, and any additional details or quotes you want to include.
Prompt for LLM (Chapter 1):
code
Write Chapter 1 of the novel "The Emotion Rebellion" based on the following outline:
## Chapter 1: The Regulated Life
- **Summary**: Introduce Neo-Eden and the regulated life of its citizens. Alex goes about his daily routine, unaware of the truth.
Additional Details:
- Describe the futuristic city of Neo-Eden.
- Introduce Alex and his daily life.
- Show the strict regulations around emotions.
- End the chapter with a hint that something is off.
Style and Tone: Dark and gritty with a hopeful undertone.
Expected Output:
code
# Chapter 1: The Regulated Life
The towering spires of Neo-Eden pierced the grey sky, their sleek, metallic surfaces reflecting the dull, artificial light that passed for sunshine in this regulated world. The city hummed with the constant drone of machinery, a symphony of control that governed every aspect of its citizens' lives—especially their emotions.
Alex stepped out of his modest apartment, the door sliding shut behind him with a soft hiss. Like every other citizen, he wore the standard-issue grey attire, designed to blend in and discourage individual expression. Around his wrist, the Emotion Regulation Band pulsed gently, monitoring and suppressing any unwanted feelings. It was the law; emotions were dangerous, unpredictable, and therefore, illegal.
As he walked through the sterile streets, Alex greeted his neighbours with the mandated, emotionless nod. “Good morning, citizen,” he said, his voice as flat as the expressions on their faces.
“Good morning, Alex,” they replied in unison, their eyes vacant, their movements robotic.
Alex arrived at the Central Processing Facility, where he worked as a data analyst. His job was to ensure that all emotional outliers were reported and dealt with promptly. It was tedious work, but it kept the city running smoothly—or so he had always believed.
Throughout the day, Alex followed the routine with precision. He analysed data, reported anomalies, and attended the mandatory Emotion Suppression Seminar during lunch. The speaker, a stern-looking woman with a perfectly regulated expression, droned on about the dangers of unchecked emotions.
“Emotions lead to chaos,” she intoned. “Regulation leads to order. Remember, citizens, our emotions are not our own; they belong to the state.”
As the seminar ended Alex felt a strange twinge in his chest—a sensation he couldn’t quite place. He dismissed it as a glitch in his Emotion Regulation Band and returned to work.
That night, as Alex lay in his sterile bed he couldn’t shake the feeling that something was off. The city was too perfect, too controlled. As he drifted into sleep he wondered, just for a moment if there was more to life than this regulated existence.
Little did he know, his world was about to change forever.
Step 4: Review and Edit
After each chapter is written, review it to ensure it aligns with the outline and maintains the desired style and tone. Make any necessary edits or request revisions from the LLM.
Step 5: Compile the Novel
Once all chapters are written and edited, compile them into a complete novel. Add a title page, chapter headings, and any other formatting required.
Step 6: Final Review
Conduct a final review of the entire novel to ensure consistency, coherence, and overall quality. Make any final edits or adjustments.
Step 7: Publication
Prepare the novel for publication. This may include formatting for e-books or print, creating a cover, and deciding on a distribution method (self-publishing, traditional publishing, etc.).
Additional Tips
Iterative Process: Be prepared to iterate. You may need to go back and forth between steps, especially if the LLM-generated content needs significant adjustments.
Prompt Engineering: Crafting effective prompts for the LLM is crucial. Be as detailed and specific as possible to guide the model towards the desired output.
Ethical Considerations: Ensure that the content generated is appropriate and does not violate any ethical guidelines or copyrights.
User Feedback: If possible, get feedback from the user after each major step (e.g., after the outline is generated, after a few chapters are written) to ensure the novel is meeting their expectations.
By following this workflow, you can leverage the power of LLMs to assist in writing a complete novel based on a user-provided premise and details.
User
I don't want to iterate, I am using a worflow builder like LangFlow or n8n which allows me to chain multiple prompts.
Assistant
Got it! Using a workflow builder like LangFlow or n8n allows you to chain multiple prompts seamlessly, which can streamline the process. Below is a detailed workflow that you can implement in LangFlow or n8n to write an entire novel from a user-given premise and information. This workflow will be linear and non-iterative, as requested.
Node/Component: LLM Node (e.g., OpenAI, Google PaLM)
Prompt:
code
Based on the following information, generate a detailed outline for a novel:
Premise: {{premise}}
Characters:
{{characters}}
Setting: {{setting}}
Plot Points:
{{plot_points}}
Style and Tone: {{style_and_tone}}
Please include chapter titles and a brief summary of each chapter.
Output: Detailed outline with chapter titles and summaries.
3. Chapter Writing (Loop Through Chapters)
Node/Component: Loop Node
Iteration: For each chapter in the outline.
Inner Nodes:
Node/Component: LLM Node
Prompt:
code
Write {{chapter_title}} of the novel "{{novel_title}}" based on the following outline:
{{chapter_summary}}
Additional Details:
{{additional_details}}
Style and Tone: {{style_and_tone}}
Output: Written chapter.
4. Compile Novel
Node/Component: Text Aggregator Node
Input: All written chapters.
User
To simplify the creation of the workflow, give me all the prompts for each steps, keep in mind that the workflow could be used with small LLM, therefore it is better to have multiples simple prompts instead of a few complex ones.
Assistant
Certainly! Below are the simplified prompts for each step in the workflow. These prompts are designed to be straightforward and suitable for smaller LLMs.
Step 1: User Input Collection
This step is handled by a form or input node in your workflow builder, so no LLM prompt is needed here.
Step 2: Outline Generation
Prompt for LLM:
code
Please generate a detailed outline for a novel based on the following information:
Premise: {{premise}}
Characters:
{{characters}}
Setting: {{setting}}
Plot Points:
{{plot_points}}
Style and Tone: {{style_and_tone}}
Include chapter titles and a brief summary of each chapter.
Step 3: Chapter Writing (Loop Through Chapters)
Chapter 1
Prompt for LLM:
code
Write Chapter 1 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_1_title}}
Summary: {{chapter_1_summary}}
Additional Details:
{{chapter_1_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 2
Prompt for LLM:
code
Write Chapter 2 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_2_title}}
Summary: {{chapter_2_summary}}
Additional Details:
{{chapter_2_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 3
Prompt for LLM:
code
Write Chapter 3 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_3_title}}
Summary: {{chapter_3_summary}}
Additional Details:
{{chapter_3_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 4
Prompt for LLM:
Output: Complete novel text.
5. Add Front Matter
Node/Component: Text Node
Content:
code
# {{novel_title}}
## By {{author_name}}
Output: Front matter text.
6. Final Novel Assembly
Node/Component: Text Concatenation Node
Input:
Front matter text
Complete novel text
Output: Final novel with front matter.
7. Format for Publication
Node/Component: Formatting Node (e.g., Markdown, HTML, or PDF converter)
Input: Final novel text
Output: Formatted novel ready for publication.
Detailed Workflow Implementation
Here’s how you can set up each step in a workflow builder like LangFlow or n8n:
1. User Input Collection
Form Node:
Add fields for:
Premise
Characters (use a text area or multiple input fields)
Setting
Plot Points (use a text area or multiple input fields)
Style and Tone
2. Outline Generation
LLM Node:
Model: Choose your preferred LLM (e.g., OpenAI's GPT-3.5/4).
Prompt Template:
code
Based on the following information, generate a detailed outline for a novel:
Premise: {{premise}}
Characters:
{{characters}}
Setting: {{setting}}
Plot Points:
{{plot_points}}
Style and Tone: {{style_and_tone}}
Please include chapter titles and a brief summary of each chapter.
Output: Store the generated outline in a variable (e.g., outline).
3. Chapter Writing (Loop Through Chapters)
Loop Node:
Input: The outline variable.
Iteration: For each chapter in the outline.
LLM Node Inside Loop:
Model: Same LLM as before.
Prompt Template:
code
Write {{chapter.title}} of the novel "{{novel_title}}" based on the following outline:
{{chapter.summary}}
Additional Details:
{{chapter.additional_details}}
Style and Tone: {{style_and_tone}}
Output: Store each written chapter in a list (e.g., chapters).
4. Compile Novel
Text Aggregator Node:
Input: The list of written chapters.
Output: Concatenate all chapters into a single text (e.g., complete_novel).
5. Add Front Matter
Text Node:
Content Template:
code
# {{novel_title}}
## By {{author_name}}
Output: Store this as front_matter.
6. Final Novel Assembly
Text Concatenation Node:
Inputs:
front_matter
complete_novel
Output: Concatenate these to form the final_novel.
7. Format for Publication
Formatting Node:
Input: final_novel
Format: Choose your desired format (e.g., Markdown, HTML, PDF).
Output: Formatted novel ready for publication.
Example Workflow in n8n
Start Node -> Form Node (collect user input).
Form Node -> OpenAI Node (generate outline).
OpenAI Node -> Function Node (parse outline into chapters).
Function Node -> Loop Node (iterate over chapters).
Loop Node -> OpenAI Node (write each chapter).
OpenAI Node -> Set Node (store chapters in a list).
Set Node -> Text Node (aggregate chapters).
Text Node -> Text Node (add front matter).
Text Node & Text Node -> Join Node (combine front matter and novel).
Join Node -> HTTP Request Node or File Node (format and save the novel).
This linear workflow will take the user's input, generate an outline, write each chapter sequentially, and compile the final novel without the need for iteration.
code
Write Chapter 4 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_4_title}}
Summary: {{chapter_4_summary}}
Additional Details:
{{chapter_4_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 5
Prompt for LLM:
code
Write Chapter 5 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_5_title}}
Summary: {{chapter_5_summary}}
Additional Details:
{{chapter_5_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 6
Prompt for LLM:
code
Write Chapter 6 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_6_title}}
Summary: {{chapter_6_summary}}
Additional Details:
{{chapter_6_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 7
Prompt for LLM:
code
Write Chapter 7 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_7_title}}
Summary: {{chapter_7_summary}}
Additional Details:
{{chapter_7_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 8
Prompt for LLM:
code
Write Chapter 8 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_8_title}}
Summary: {{chapter_8_summary}}
Additional Details:
{{chapter_8_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 9
Prompt for LLM:
code
Write Chapter 9 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_9_title}}
Summary: {{chapter_9_summary}}
Additional Details:
{{chapter_9_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 10
Prompt for LLM:
code
Write Chapter 10 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_10_title}}
Summary: {{chapter_10_summary}}
Additional Details:
{{chapter_10_additional_details}}
Style and Tone: {{style_and_tone}}
Chapter 11
Prompt for LLM:
code
Write Chapter 11 of the novel "{{novel_title}}" based on the following outline:
Chapter Title: {{chapter_11_title}}
Summary: {{chapter_11_summary}}
Additional Details:
{{chapter_11_additional_details}}
Style and Tone: {{style_and_tone}}
Step 4: Compile Novel
This step is handled by a text aggregation node, so no LLM prompt is needed here.
Step 5: Add Front Matter
Prompt for Text Node:
code
# {{novel_title}}
## By {{author_name}}
Step 6: Final Novel Assembly
This step is handled by a text concatenation node, so no LLM prompt is needed here.
Step 7: Format for Publication
This step is handled by a formatting node, so no LLM prompt is needed here.
Example Variable Mapping
To ensure the prompts work correctly, map the variables from the user input and previous steps to the prompts. Here’s an example of how you might map the variables:
{{premise}}: User-provided premise.
{{characters}}: User-provided character details.
{{setting}}: User-provided setting details.
{{plot_points}}: User-provided plot points.
{{style_and_tone}}: User-provided style and tone.
{{novel_title}}: A title derived from the premise or user input.
{{author_name}}: User-provided author name.
{{chapter_x_title}}: Title of chapter x from the outline.
{{chapter_x_summary}}: Summary of chapter x from the outline.
{{chapter_x_additional_details}}: Any additional details for chapter x from the outline.
By using these simplified prompts, you can ensure that even smaller LLMs can handle each task effectively, resulting in a complete novel.