The Interactive Children's Storytelling System is an AI-powered storytelling application designed for children ages 5-10. It creates safe, engaging, and educational stories that adapt to user preferences and feedback in real-time.
- Python 3.8 or higher
- OpenAI API key
- Virtual environment (recommended)
-
Clone or download the project files
main.py requirements.txt README.md -
Set up a virtual environment (recommended)
python -m venv .venv .venv\Scripts\Activate.ps1 # On Windows source .venv/bin/activate # On macOS/Linux
-
Install dependencies
pip install -r requirements.txt
-
Set up your OpenAI API key
- Get an API key from OpenAI Platform
- Create a
.envfile in the project directory - Add your API key:
OPENAI_API_KEY=your_api_key_here
-
Run the application
python main.py
-
Launch the application
python main.py
-
Enter your story request
- The system will ask: "What kind of story would you like to hear?"
- Examples:
- "A story about a brave little mouse"
- "A magical adventure in a forest"
- "A story about friendship and sharing"
- "A Hindu mythological story about Prahlada and Narasimha"
-
Wait for story generation
- The system will generate and validate the story for safety
- It may take a few moments to create the perfect opening
After the story begins, you'll see a menu with 9 options:
๐ What would you like to do next?
1. Continue the story
2. End the story here
3. Continue with a suggestion
4. Request changes to the story
5. Change story tone or style
6. Add a new character
7. Change the setting
8. Start a new story
9. Exit the system
- The system continues the story naturally
- Maintains character consistency and plot flow
- Adds new story segments automatically
- Creates a satisfying conclusion
- Wraps up all plot threads
- Provides a positive ending message
- You can suggest what happens next
- Examples:
- "The character finds a magical key"
- "They meet a friendly dragon"
- "They solve the puzzle together"
- Make any type of change to the existing story
- Examples:
- "Make the character braver"
- "Add more magic to the story"
- "Make it more exciting"
- "Change character names"
- Modify how the story is told
- Examples:
- "Make it more funny"
- "Make it more magical"
- "Make it more adventurous"
- "Make it more educational"
- Introduce new characters to the story
- Examples:
- "Add a wise owl"
- "Add a friendly robot"
- "Add a magical fairy"
- Move the story to a different location
- Examples:
- "Change it to a space station"
- "Move it to an underwater city"
- "Set it in a magical forest"
- Begin a completely fresh story
- Resets all characters, setting, and plot
- Prompts for a new story request
- Perfect for when you want to try something completely different
- Safely exit the storytelling system
- Saves your current session
- Displays a friendly goodbye message
The system includes multiple safety measures:
- Age-Appropriate Content: All content is validated for children ages 5-10
- Content Filtering: Stories are checked for inappropriate themes
- Positive Messaging: Promotes good values and behaviors
- Educational Value: Includes learning opportunities
- Safe Language: Uses simple, clear language appropriate for young readers
- Built-in retry logic with exponential backoff
- Handles OpenAI API rate limits gracefully
- Automatic waiting between requests
- Graceful error recovery
- Fallback content if generation fails
- Clear error messages for users
- Tracks characters, setting, and theme
- Maintains story continuity
- Preserves user choices and modifications
๐ Welcome to the Interactive Children's Storytelling System! ๐
I'll create a safe, engaging story just for you!
------------------------------------------------------------
What kind of story would you like to hear? A story about a brave little mouse
๐ฏ Creating a story about: A story about a brave little mouse
โณ Generating and checking story safety...
============================================================
๐ YOUR STORY BEGINS:
============================================================
Once upon a time, there was a brave little mouse named Max who lived in a cozy burrow under an old oak tree...
============================================================
๐ What would you like to do next?
1. Continue the story
2. End the story here
3. Continue with a suggestion
4. Request changes to the story
5. Change story tone or style
6. Add a new character
7. Change the setting
============================================================
Your choice (1-9): 3
What would you like to happen next? Max finds a magical acorn
โณ Adding your idea: Max finds a magical acorn
============================================================
๐ STORY CONTINUES:
============================================================
As Max continued his journey, he noticed something special on the forest floor...
- Supervise young children while using the system
- Discuss the stories with children to enhance learning
- Use the change features to customize stories for specific lessons
- Encourage creativity by letting children suggest story elements
- Be specific when making suggestions
- Try different options to explore storytelling
- Ask for changes if you want something different
- Have fun experimenting with different story elements
- Start fresh when you want a completely new adventure
- Exit safely when you're done with your storytelling session
"Rate limit reached" error
- Wait a few minutes and try again
- The system includes automatic retry logic
"API key not found" error
- Check that your
.envfile exists - Verify your OpenAI API key is correct
- Ensure the
.envfile is in the project directory
Story generation fails
- The system will use fallback content
- Try again with a different story request
- Check your internet connection
- Ensure all dependencies are installed correctly
- Check that your OpenAI API key is valid and has credits
- Verify you're using Python 3.8 or higher
The system is designed to be flexible and adaptable:
- Story Themes: Request any type of story (adventure, friendship, learning, etc.)
- Character Types: Add any kind of character (animals, magical beings, robots, etc.)
- Settings: Change to any location (forest, space, underwater, etc.)
- Tones: Modify the storytelling style (funny, serious, magical, etc.)
This system supports learning in multiple ways:
- Language Development: Exposure to rich vocabulary and storytelling
- Creativity: Encourages imaginative thinking and story creation
- Critical Thinking: Interactive choices help develop decision-making skills
- Values Education: Stories promote positive behaviors and moral lessons
- Engagement: Interactive elements maintain attention and interest
The system is designed for future expansion:
- Character personality persistence
- Enhanced safety monitoring
- Story export functionality
- Audio narration capabilities
- Multi-language support
Enjoy your storytelling adventure! ๐