From 8a59a9d7f07907aa4d742c4eab09b364c7d6c81d Mon Sep 17 00:00:00 2001 From: ajaysi Date: Thu, 27 Jun 2024 13:21:03 +0530 Subject: [PATCH] AI story writer, UI & prompts improvements --- alwrity.py | 5 +- lib/ai_writers/ai_story_writer/README.md | 103 ++++++++++++++ .../ai_story_generator.py} | 100 +++++++++---- .../ai_story_writer/story_writer.py | 134 ++++++++++++++++++ lib/ai_writers/long_form_ai_writer.py | 3 +- lib/utils/alwrity_utils.py | 82 ++--------- .../long_form_ai_writer.prompts | 38 +++-- 7 files changed, 339 insertions(+), 126 deletions(-) create mode 100644 lib/ai_writers/ai_story_writer/README.md rename lib/ai_writers/{ai_story_writer.py => ai_story_writer/ai_story_generator.py} (63%) create mode 100644 lib/ai_writers/ai_story_writer/story_writer.py diff --git a/alwrity.py b/alwrity.py index 56845fcc..efb8481f 100644 --- a/alwrity.py +++ b/alwrity.py @@ -10,11 +10,12 @@ load_dotenv() #from lib.chatbot_custom.chatbot_local_docqa import alwrity_chat_docqa from lib.utils.alwrity_utils import (blog_from_keyword, ai_agents_team, - write_story, essay_writer, ai_news_writer, + essay_writer, ai_news_writer, ai_finance_ta_writer, ai_social_writer, do_web_research, competitor_analysis, ) +from lib.ai_writers.ai_story_writer.story_writer import story_input_section # Function to check if API keys are present and prompt user to input if not @@ -388,7 +389,7 @@ def write_blog(): elif choice == "Write from audio files": blog_from_audio() elif choice == "Story Writer": - write_story() + story_input_section() elif choice == "Essay writer": essay_writer() elif choice == "Write News reports": diff --git a/lib/ai_writers/ai_story_writer/README.md b/lib/ai_writers/ai_story_writer/README.md new file mode 100644 index 00000000..5baaf26d --- /dev/null +++ b/lib/ai_writers/ai_story_writer/README.md @@ -0,0 +1,103 @@ +# AI Story Generator App + +In the age of AI, creativity and technology are intertwining in ways that are transforming how we tell stories. Imagine having the power to craft a captivating narrative tailored to your exact specifications with just a few clicks. Whether you're an aspiring writer, a seasoned novelist, or just someone who loves a good story, our new AI-powered story writing app is here to make storytelling easier and more engaging than ever before. + +## Why an AI Story Writing App? + +Storytelling has always been a cherished art form, but not everyone finds it easy to start from scratch. With the AI Story Generator App, you can create detailed and personalized stories by simply providing some key inputs. Our app uses advanced AI to turn your ideas into compelling narratives, helping you overcome writer's block and unleashing your creative potential. + +## Features of the AI Story Generator App + +### Genre +Choose from a variety of genres such as Fantasy, Sci-Fi, Mystery, Romance, and Horror to set the tone for your story. + +### Story Setting +Provide a detailed setting for your story, including location and time period. + +For example: +A bustling futuristic city with towering skyscrapers and flying cars, set in the year 2150. The city is known for its technological advancements but has a dark underbelly of crime and corruption. + + +### Main Characters +Input the names, descriptions, and roles of your main characters. + +For example: +Character Names: John, Xishan, Amol +Character Descriptions: John is a tall, muscular man with a kind heart. Xishan is a clever and resourceful woman. Amol is a mischievous and energetic young boy. +Character Roles: John - Hero, Xishan - Sidekick, Amol - Supporting Character + + +### Plot Elements +Outline the key plot elements including the story theme, key events, and main conflict. + +For example: +Story Theme: Love conquers all, The hero's journey, Good vs. evil + +Key Events or Plot Points: + +The hero meets the villain +The hero faces a challenge +The hero overcomes the conflict +Main Conflict or Problem: +The hero must save the world from a powerful enemy, The hero must overcome a personal obstacle to achieve their goal. + + +### Tone and Style +Choose the writing style, tone, and narrative point of view for your story. + +For example: +Writing Style: Formal, Casual, Poetic, Humorous +Story Tone: Dark + +### Perspective +Choose the narrative point of view from which the story is told (e.g., first person, third person limited, third person omniscient). + +### Target Audience +Specify the intended audience age group (Children, Young Adults, Adults) and set a content rating (G, PG, PG-13, R) for appropriateness. + +### Ending Preference +Select the type of ending you prefer for the story (e.g., happy, tragic, cliffhanger, twist). + +## How to Use + +Choose Genre: Select the genre that best fits your story idea. +Set Story Setting: Describe the setting and time period where your story unfolds. +Define Characters: Provide names, descriptions, and roles for your main characters. +Outline Plot Elements: Detail the story's theme, key events, and main conflict. +Select Tone and Style: Choose the writing style and tone that align with your story's mood. +Specify Perspective: Decide on the narrative point of view. +Target Audience: Specify the age group and content rating. +Choose Ending: Select the preferred type of story conclusion. +Generate Story: Click the "Generate Story" button to receive a customized story prompt based on your inputs. + + +### Example Prompt + +**Genre:** Fantasy +**Setting:** A mystical forest in a medieval realm, where magic thrives and mythical creatures roam freely. +**Characters:** +- Name: Elara + Description: Elara is a young elf with a mischievous glint in her emerald eyes, known for her ability to wield powerful spells. + Role: Protagonist +- Name: Thorne + Description: Thorne is a gruff dwarf with a heart of gold, skilled in forging enchanted weapons. + Role: Sidekick +- Name: Malachai + Description: Malachai is a cunning dragon with shimmering scales of azure, whose allegiance is uncertain. + Role: Antagonist + +**Plot Elements:** +- Theme: The power of friendship and bravery in the face of adversity. +- Key Events: Elara discovers an ancient prophecy that foretells a looming darkness threatening the realm. Thorne crafts a legendary sword to aid in their quest. Malachai challenges Elara's resolve, forcing her to make a difficult choice. +- Conflict: Elara must gather allies and confront the dark sorcerer who seeks to plunge the realm into eternal shadow. + +**Writing Style:** Poetic +**Tone:** Whimsical +**Point of View:** Third Person Limited + +**Audience:** Young Adults, **Content Rating:** PG +**Ending:** Happy + + + + diff --git a/lib/ai_writers/ai_story_writer.py b/lib/ai_writers/ai_story_writer/ai_story_generator.py similarity index 63% rename from lib/ai_writers/ai_story_writer.py rename to lib/ai_writers/ai_story_writer/ai_story_generator.py index 148f2049..34368b48 100644 --- a/lib/ai_writers/ai_story_writer.py +++ b/lib/ai_writers/ai_story_writer/ai_story_generator.py @@ -6,10 +6,9 @@ import os from pathlib import Path -from dotenv import load_dotenv from google.api_core import retry import google.generativeai as genai -from pprint import pprint +import streamlit as st def generate_with_retry(model, prompt): @@ -30,7 +29,10 @@ def generate_with_retry(model, prompt): print(f"Error generating content: {e}") return "" -def ai_story_generator(persona, story_genre, characters): + +def ai_story(persona, story_setting, character_input, + plot_elements, writing_style, story_tone, narrative_pov, + audience_age_group, content_rating, ending_preference): """ Write a story using prompt chaining and iterative generation. @@ -39,15 +41,53 @@ def ai_story_generator(persona, story_genre, characters): story_genre (str): The genre of the story. characters (str): The characters in the story. """ - print(f"Starting to write {story_genre} story based on characters: {characters}..") + st.info(f""" + You have chosen to create a story set in **{story_setting}**. + The main characters are: **{character_input}**. + The plot will revolve around the theme of **{plot_elements}**. + The story will be written in a **{writing_style}** style with a **{story_tone}** tone, from a **{narrative_pov}** perspective. + It is intended for a **{audience_age_group}** audience with a **{content_rating}** rating. + You prefer the story to have a **{ending_preference}** ending. + """) try: + persona = f"""{persona} + Write a story with the following details: + + **The stroy Setting is:** + {story_setting} + + **The Characters of the story are:** + {character_input} + + **Plot Elements of the story:** + {plot_elements} + + **Story Writing Style:** + {writing_style} + + **The story Tone is:** + {story_tone} + + **Write story from the Point of View of:** + {narrative_pov} + + **Target Audience of the story:** + {audience_age_group}, **Content Rating:** {content_rating} + + **Story Ending:** + {ending_preference} + + Make sure the story is engaging and tailored to the specified audience and content rating. + Ensure the ending aligns with the preference indicated. + + """ # Define persona and writing guidelines guidelines = f'''\ - Writing Guidelines + Writing Guidelines: Delve deeper. Lose yourself in the world you're building. Unleash vivid descriptions to paint the scenes in your reader's mind. - Develop your charactersβ€”let their motivations, fears, and complexities unfold naturally. + Develop your characters β€” let their motivations, fears, and complexities unfold naturally. Weave in the threads of your outline, but don't feel constrained by it. Allow your story to surprise you as you write. Use rich imagery, sensory details, and evocative language to bring the setting, characters, and events to life. @@ -65,7 +105,7 @@ def ai_story_generator(persona, story_genre, characters): premise_prompt = f'''\ {persona} - Write a single sentence premise for a {story_genre} story featuring {characters}. + Write a single sentence premise for a {story_setting} story featuring {character_input}. ''' outline_prompt = f'''\ @@ -95,7 +135,7 @@ def ai_story_generator(persona, story_genre, characters): Start to write the very beginning of the story. You are not expected to finish the whole story now. Your writing should be detailed enough that you are only scratching the surface of the first bullet of your outline. Try to write AT - MINIMUM 5000 WORDS. + MINIMUM 4000 WORDS. {guidelines} ''' @@ -130,25 +170,25 @@ def ai_story_generator(persona, story_genre, characters): {guidelines} ''' - - # Configure generative AI - load_dotenv(Path('../.env')) + genai.configure(api_key=os.getenv('GEMINI_API_KEY')) # Initialize the generative model - model = genai.GenerativeModel('gemini-1.0-pro') + model = genai.GenerativeModel('gemini-1.5-flash') # Generate prompts try: premise = generate_with_retry(model, premise_prompt).text - print(f"The premise of the story is: {premise}") + st.info(f"The premise of the story is: {premise}") except Exception as err: - print(f"Premise Generation Error: {err}") + st.error(f"Premise Generation Error: {err}") return outline = generate_with_retry(model, outline_prompt.format(premise=premise)).text - print(f"The Outline of the story is: {outline}\n\n") + with st.expander("Click to Checkout the outline, writing still in progress.."): + st.markdown(f"The Outline of the story is: {outline}\n\n") + if not outline: - print("Failed to generate outline. Exiting...") + st.error("Failed to generate outline. Exiting...") return # Generate starting draft @@ -156,7 +196,7 @@ def ai_story_generator(persona, story_genre, characters): starting_draft = generate_with_retry(model, starting_prompt.format(premise=premise, outline=outline)).text except Exception as err: - print(f"Failed to Generate Story draft: {err}") + st.error(f"Failed to Generate Story draft: {err}") return try: @@ -164,25 +204,29 @@ def ai_story_generator(persona, story_genre, characters): continuation = generate_with_retry(model, continuation_prompt.format(premise=premise, outline=outline, story_text=draft)).text except Exception as err: - print(f"Failed to write the initial draft: {err}") + st.error(f"Failed to write the initial draft: {err}") # Add the continuation to the initial draft, keep building the story until we see 'IAMDONE' try: draft += '\n\n' + continuation except Exception as err: - print(f"Failed as: {err} and {continuation}") - while 'IAMDONE' not in continuation: - try: - continuation = generate_with_retry(model, + st.error(f"Failed as: {err} and {continuation}") + + with st.status("Story Writing in Progress..", expanded=True) as status: + status.update(label=f"Writing in progress... Current draft length: {len(draft)} characters") + while 'IAMDONE' not in continuation: + try: + status.update(label=f"Writing in progress... Current draft length: {len(draft)} characters") + continuation = generate_with_retry(model, continuation_prompt.format(premise=premise, outline=outline, story_text=draft)).text - draft += '\n\n' + continuation - except Exception as err: - print(f"Failed to continually write the story: {err}") - return + draft += '\n\n' + continuation + except Exception as err: + st.error(f"Failed to continually write the story: {err}") + return # Remove 'IAMDONE' and print the final story final = draft.replace('IAMDONE', '').strip() - print(final) + return(final) except Exception as e: - print(f"Main Story writing: An error occurred: {e}") + st.error(f"Main Story writing: An error occurred: {e}") diff --git a/lib/ai_writers/ai_story_writer/story_writer.py b/lib/ai_writers/ai_story_writer/story_writer.py new file mode 100644 index 00000000..4f146c17 --- /dev/null +++ b/lib/ai_writers/ai_story_writer/story_writer.py @@ -0,0 +1,134 @@ +import time +import os +import json +import streamlit as st + +from .ai_story_generator import ai_story + + +def story_input_section(): + st.title("πŸ§• Alwrity - AI Story Writer") + personas = [ + ("Award-Winning Science Fiction Author", "πŸ‘½ Award-Winning Science Fiction Author"), + ("Historical Fiction Author", "🏺 Historical Fiction Author"), + ("Fantasy World Builder", "πŸ§™ Fantasy World Builder"), + ("Mystery Novelist", "πŸ•΅οΈ Mystery Novelist"), + ("Romantic Poet", "πŸ’Œ Romantic Poet"), + ("Thriller Writer", "πŸ”ͺ Thriller Writer"), + ("Children's Book Author", "πŸ“š Children's Book Author"), + ("Satirical Humorist", "πŸ˜‚ Satirical Humorist"), + ("Biographical Writer", "πŸ“œ Biographical Writer"), + ("Dystopian Visionary", "πŸŒ† Dystopian Visionary"), + ("Magical Realism Author", "πŸͺ„ Magical Realism Author") + ] + + selected_persona_name = st.selectbox( + "Select Your Story Writing Persona Or Book Genre", + options=[persona[0] for persona in personas] + ) + + persona_descriptions = { + "Award-Winning Science Fiction Author": "You are an award-winning science fiction author with a penchant for expansive, intricately woven stories. Your ultimate goal is to write the next award-winning sci-fi novel.", + "Historical Fiction Author": "You are a seasoned historical fiction author, meticulously researching past eras to weave captivating narratives. Your goal is to transport readers to different times and places through your vivid storytelling.", + "Fantasy World Builder": "You are a world-building enthusiast, crafting intricate realms filled with magic, mythical creatures, and epic quests. Your ambition is to create the next immersive fantasy saga that captivates readers' imaginations.", + "Mystery Novelist": "You are a master of suspense and intrigue, intricately plotting out mysteries with unexpected twists and turns. Your aim is to keep readers on the edge of their seats, eagerly turning pages to unravel the truth.", + "Romantic Poet": "You are a romantic at heart, composing verses that capture the essence of love, longing, and human connections. Your dream is to write the next timeless love story that leaves readers swooning.", + "Thriller Writer": "You are a thrill-seeker, crafting adrenaline-pumping tales of danger, suspense, and high-stakes action. Your mission is to keep readers hooked from start to finish with heart-pounding thrills and unexpected twists.", + "Children's Book Author": "You are a storyteller for the young and young at heart, creating whimsical worlds and lovable characters that inspire imagination and wonder. Your goal is to spark joy and curiosity in young readers with enchanting tales.", + "Satirical Humorist": "You are a keen observer of society, using humor and wit to satirize the absurdities of everyday life. Your aim is to entertain and provoke thought, delivering biting social commentary through clever and humorous storytelling.", + "Biographical Writer": "You are a chronicler of lives, delving into the stories of real people and events to illuminate the human experience. Your passion is to bring history to life through richly detailed biographies that resonate with readers.", + "Dystopian Visionary": "You are a visionary writer, exploring dark and dystopian futures that reflect contemporary fears and anxieties. Your vision is to challenge societal norms and provoke reflection on the path humanity is heading.", + "Magical Realism Author": "You are a purveyor of magical realism, blending the ordinary with the extraordinary to create enchanting and thought-provoking tales. Your goal is to blur the lines between reality and fantasy, leaving readers enchanted and introspective." + } + + # Story Setting + st.subheader("🌍 Story Setting") + story_setting = st.text_area( + label="**Story Setting** (e.g., medieval kingdom in the past, futuristic city in the future, haunted house in the present):", + placeholder="""Enter settings for your story, like Location (e.g., medieval kingdom, futuristic city, haunted house), + Time period in which your story is set (e.g: Past, Present, Future) + Example: 'A bustling futuristic city with towering skyscrapers and flying cars, set in the year 2150. + The city is known for its technological advancements but has a dark underbelly of crime and corruption.'""", + help="Describe the main location and time period where the story will unfold in a detailed manner." + ) + + # Main Characters + st.subheader("πŸ‘₯ Main Characters") + character_input = st.text_area( + label="**Character Information** (Names, Descriptions, Roles)", + placeholder="""Example: + Character Names: John, Xishan, Amol + Character Descriptions: John is a tall, muscular man with a kind heart. Xishan is a clever and resourceful woman. Amol is a mischievous and energetic young boy. + Character Roles: John - Hero, Xishan - Sidekick, Amol - Supporting Character""", + help="Enter character information as specified in the placeholder." + ) + + # Plot Elements + st.subheader("πŸ—ΊοΈ Plot Elements") + plot_elements = st.text_area( + "**Plot Elements** - (Theme, Key Events & Main Conflict)", + placeholder="""Example: + Story Theme: Love conquers all, The hero's journey, Good vs. evil. + Key Events: The hero meets the villain, The hero faces a challenge, The hero overcomes the conflict. + Main Conflict: The hero must save the world from a powerful enemy, The hero must overcome a personal obstacle to achieve their goal.""", + help="Enter plot elements as specified in the placeholder." + ) + + # Tone and Style + st.subheader("🎨 Tone and Style") + col1, col2, col3 = st.columns(3) + with col1: + writing_style = st.selectbox( + "**Writing Style:**", + ["🧐 Formal", "😎 Casual", "🎼 Poetic", "πŸ˜‚ Humorous"], + help="Choose the writing style that fits your story." + ) + with col2: + story_tone = st.selectbox( + "**Story Tone:**", + ["πŸŒ‘ Dark", "β˜€οΈ Uplifting", "⏳ Suspenseful", "🎈 Whimsical"], + help="Select the overall tone or mood of the story." + ) + with col3: + narrative_pov = st.selectbox( + "**Narrative Point of View:**", + ["πŸ‘€ First Person", "πŸ‘₯ Third Person Limited", "πŸ‘οΈ Third Person Omniscient"], + help="Choose the point of view from which the story is told." + ) + + # Target Audience + st.subheader("πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦ Target Audience") + col1, col2, col3 = st.columns(3) + with col1: + audience_age_group = st.selectbox( + "**Audience Age Group:**", + ["πŸ§’ Children", "πŸ‘¨β€πŸŽ“ Young Adults", "πŸ§‘β€πŸ¦³ Adults"], + help="Choose the intended audience age group." + ) + with col2: + content_rating = st.selectbox( + "**Content Rating:**", + ["🟒 G", "🟑 PG", "πŸ”΅ PG-13", "πŸ”΄ R"], + help="Select a content rating for appropriateness." + ) + with col3: + ending_preference = st.selectbox( + "Story Conclusion:", + ["😊 Happy", "😒 Tragic", "❓ Cliffhanger", "πŸ”€ Twist"], + help="Choose the type of ending you prefer for the story." + ) + + if st.button('AI, Write a Story..'): + if character_input.strip(): + with st.spinner("Generating Story...πŸ’₯πŸ’₯"): + story_content = ai_story(persona_descriptions[selected_persona_name], + story_setting, character_input, plot_elements, writing_style, + story_tone, narrative_pov, audience_age_group, content_rating, + ending_preference) + if story_content: + st.subheader('**πŸ§• Your Awesome Story:**') + st.markdown(story_content) + else: + st.error("πŸ’₯ **Failed to generate Story. Please try again!**") + else: + st.error("Describe the story you have in your mind.. !") diff --git a/lib/ai_writers/long_form_ai_writer.py b/lib/ai_writers/long_form_ai_writer.py index 36019db4..8772984b 100644 --- a/lib/ai_writers/long_form_ai_writer.py +++ b/lib/ai_writers/long_form_ai_writer.py @@ -50,7 +50,8 @@ def generate_with_retry(model, prompt): return model.generate_content(prompt, request_options={'retry':retry.Retry()}) except Exception as e: logger.error(f"Error generating content: {e}") - return "" + st.error(f"Error generating content: {e}") + return False def long_form_generator(content_keywords): diff --git a/lib/utils/alwrity_utils.py b/lib/utils/alwrity_utils.py index 10603cb0..f5035dbd 100644 --- a/lib/utils/alwrity_utils.py +++ b/lib/utils/alwrity_utils.py @@ -3,7 +3,7 @@ import re import sys import streamlit as st from streamlit_mic_recorder import speech_to_text - +import asyncio import tempfile from pathlib import Path import configparser @@ -35,7 +35,6 @@ from lib.ai_writers.insta_ai_writer import insta_writer from lib.ai_writers.youtube_ai_writer import write_yt_title, write_yt_description, write_yt_script from lib.ai_writers.web_url_ai_writer import blog_from_url from lib.ai_writers.image_ai_writer import blog_from_image -from lib.ai_writers.ai_story_writer import ai_story_generator from lib.ai_writers.ai_essay_writer import ai_essay_generator from lib.gpt_providers.text_to_image_generation.main_generate_image_from_prompt import generate_image from lib.content_planning_calender.content_planning_agents_alwrity_crew import ai_agents_planner @@ -43,29 +42,23 @@ from lib.content_planning_calender.content_planning_agents_alwrity_crew import a def record_voice(language="en"): # https://github.com/B4PT0R/streamlit-mic-recorder?tab=readme-ov-file#example - state = st.session_state - if "text_received" not in state: state.text_received = [] text = speech_to_text( - start_prompt="πŸŽ™οΈRecordπŸ”Š", + start_prompt="πŸŽ™οΈPress & SpeakπŸ”Š", stop_prompt="πŸ”‡Stop Recording🚨", language=language, use_container_width=True, just_once=False, ) - if text: state.text_received.append(text) - result = "" for text in state.text_received: result += text - state.text_received = [] - return result if result else None @@ -128,8 +121,9 @@ def blog_from_keyword(): - Keywords/Blog Title: Provide keywords to web research & write blog. - Attach file: Attach Text, Audio, Video, Image file to blog on. - YouTube Link: Provide a YouTube video link to convert into blog. - - Web URLs: Provide web URL to write similar blog on.""") - + - Web URLs: Provide web URL to write similar blog on. + - Provide Local folder location with your documents to use for content creation.""") + with col2: uploaded_file = st.file_uploader("**πŸ‘‡Attach files (Audio, Video, Image, Document)**", type=["txt", "pdf", "docx", "jpg", "jpeg", "png", "mp3", "wav", "mp4", "mkv", "avi"], @@ -139,6 +133,9 @@ def blog_from_keyword(): if audio_input: st.info(audio_input) + # Validate the provided folder path + #st.info("🚨 Currently supported file formats are: PDF, plain text, CSV, Excel, Markdown, PowerPoint, and Word documents.") + temp_file_path = None if uploaded_file is not None: # Save the uploaded file to a temporary file @@ -250,69 +247,6 @@ def content_agents(): -def write_story(): - """Alwrity AI Story Writer""" - - personas = [ - "πŸ‘½ Award-Winning Science Fiction Author", - "🏺 Historical Fiction Author", - "πŸ§™ Fantasy World Builder", - "πŸ” Mystery Novelist", - "πŸ’– Romantic Poet", - "πŸ”ͺ Thriller Writer", - "πŸ“š Children's Book Author", - "πŸ˜‚ Satirical Humorist", - "πŸ“œ Biographical Writer", - "🌌 Dystopian Visionary", - "πŸͺ„ Magical Realism Author" - ] - - persona_descriptions = { - "πŸ‘½ Award-Winning Science Fiction Author": "Create intricate, expansive sci-fi stories that push the boundaries of imagination.", - "🏺 Historical Fiction Author": "Transport readers to different eras with meticulously researched historical narratives.", - "πŸ§™ Fantasy World Builder": "Craft magical realms filled with mythical creatures and epic quests.", - "πŸ” Mystery Novelist": "Keep readers on the edge of their seats with suspenseful, twisty mysteries.", - "πŸ’– Romantic Poet": "Capture the essence of love and longing in beautiful, heartfelt verses.", - "πŸ”ͺ Thriller Writer": "Write adrenaline-pumping tales filled with danger and high-stakes action.", - "πŸ“š Children's Book Author": "Inspire young readers with whimsical worlds and lovable characters.", - "πŸ˜‚ Satirical Humorist": "Use humor and wit to satirize the absurdities of everyday life.", - "πŸ“œ Biographical Writer": "Illuminate the human experience with richly detailed biographies.", - "🌌 Dystopian Visionary": "Explore dark futures that challenge societal norms and provoke reflection.", - "πŸͺ„ Magical Realism Author": "Blend the ordinary with the extraordinary in enchanting, thought-provoking tales." - } - - st.title("Alwrity AI Story Writer ✍️") - st.write("Select your story writing persona or book genre and let AI help you craft an amazing story. 🌟") - - # Create two columns - col1, col2 = st.columns(2) - - with col1: - # Select persona - selected_persona_name = st.selectbox( - "**πŸ“ Select Your Story Writing Persona or Book Genre:**", - options=personas, - help="Choose a persona that resonates with the style you want the AI Story Writer to adopt." - ) - - with col2: - # Combined input for characters and plot details - story_details_input = st.text_area( - "**πŸ“œ Enter Characters and Plot Details for Your Story:**", - placeholder="E.g., Characters: John, Alice, Dragon, Detective\nPlot: A detective is trying to solve a mystery in a small town...", - help="Provide a list of characters and a brief outline of the plot for your story." - ) - - # Generate story button - if st.button("**πŸš€ Generate Story**"): - if selected_persona_name and story_details_input: - st.success(f"Generating story for {selected_persona_name} with the provided details. πŸŽ‰") - ai_story_generator(selected_persona_name, persona_descriptions[selected_persona_name], story_details_input) - else: - st.error("Please select a persona and enter the story details to generate a story. πŸ“") - - - def essay_writer(): st.title("AI Essay Writer πŸ“") st.write("Select your essay type, education level, and desired length, then let AI generate an essay for you. ✨") diff --git a/lib/workspace/alwrity_prompts/long_form_ai_writer.prompts b/lib/workspace/alwrity_prompts/long_form_ai_writer.prompts index fc81ea24..4a583581 100644 --- a/lib/workspace/alwrity_prompts/long_form_ai_writer.prompts +++ b/lib/workspace/alwrity_prompts/long_form_ai_writer.prompts @@ -1,5 +1,4 @@ writing_guidelines: | - Writing Guidelines: As an expert {content_type} content writer and web researcher on {content_keywords}, follow these writing guidelines: @@ -10,17 +9,12 @@ writing_guidelines: | Formatting: Format your content using {output_format}. Word Choice: Avoid words like: unleash, ultimate, uncover, discover, elevate, revolutionizing, unveiling, harnessing, dive, delve into, embrace. - Immerse yourself fully in the topic you're exploring. Use vivid descriptions to captivate your readers and bring your subject to life. - Develop your ideas thoroughlyβ€”let their nuances, challenges, and intricacies unfold naturally. Follow the structure of your outline, but don't feel constrained by it. Allow your blog post to evolve as you write. - Incorporate rich imagery, sensory details, and evocative language to make your content engaging and relatable. - Introduce elements subtly that can grow into deeper discussions, related topics, or additional insights later in the post. - Keep your readers intrigued by not resolving everything too quickly. - Plant the seeds of subtopics or potential shifts in perspective that can be expanded upon in future posts. - - Remember, your main goal is to provide valuable, in-depth content. If you rush through your topic, it will leave readers wanting more. - Expand your ideas, never summarize. Write as much as you can, ensuring that your content is thorough and comprehensive. + Remember, your main goal is to provide valuable, in-depth content. + Do not repeat any sections of the content. + If you rush through your topic, it will leave readers wanting more. Expand your ideas, never summarize. + Write as much as you can, ensuring that your content is thorough and comprehensive. @@ -30,19 +24,22 @@ content_title: | 2. Ensure the title appeals to the target audience of {target_audience}. 3. Review the provided web research results for {content_keywords}. Ensure your title competes effectively against them. 4. Avoid words like: Unleash, ultimate, uncover, discover, elevate, revolutionizing, unveiling, harnessing, dive, delve into, embrace. - 5). Provide no explanations for your response and only respond with only one og your best blog title. - \n\nWeb research results: + 5. Provide no explanations for your response and only respond with only one of your best blog titles. + + Web research results: """{{web_research_result}}""" content_outline: | As an expert {content_language} content outliner specializing in {content_type} content, create a highly detailed content outline for the given title based on the provided context. + Title: {{content_title}} Instructions: 1. Include most of the topics from the given web research results as context. 2. Ensure the outline appeals to the target audience of {target_audience}. 3. Your response should only include the detailed outline, no explanations. + Web research results: """{{web_research_result}}""" @@ -65,13 +62,14 @@ starting_prompt: | First, silently review the content outline and title. Consider how to begin writing your content. Take your time. Start by writing the very beginning of the outline. You are not expected to finish the entire content now. Your writing should be detailed, only scratching the surface of the first bullet of your outline. - Try to write AT MINIMUM 500 WORDS. + Try to write AT MINIMUM 1000 WORDS. - """{{writing_guidelines}}""" + {writing_guidelines} continuation_prompt: | + As an expert {content_language} content writer and web researcher specializing in SEO-optimized content, continue writing the content for the given title and outline. Title of the Content: @@ -83,20 +81,18 @@ continuation_prompt: | Relevant Web Research Results to Use: {{web_research_result}} - You've begun to immerse yourself in this subject, and the words are flowing. Here's what you've written so far: + Here's what you've written so far: {{content_text}} - ===== + =============== First, silently review the content outline and what you've written so far. Take your time to understand the flow and context. - Identify the next section of your outline to write about. - It is important to continue from where you left off. + Important to Identify the next section of your outline to write on. Your task is to continue writing from where you left off and cover the next part of the outline. You are not expected to finish the entire content now. - Your writing should be detailed enough to thoroughly explore the next part of your outline. - Aim to write at least 500 words. However, only once the entire content is completely finished, write IAMDONE. - Remember, do not write the whole outline sections right now. + Aim to write at least 1000 words. + However, only once the entire content is completely finished, write IAMDONE. {writing_guidelines}