Create personalized stories for young readers. This AI-powered prototype generates unique tales and illustrations to make reading more engaging.
The project is divided into two main components:
- Backend (Python/FastAPI)
- Frontend (Vue.js/Vite/Tailwind CSS)
The backend is a FastAPI application that uses OpenAI's API and/or OpenRouter's API to generate stories based on user input. It can also generate images using OpenAI's DALL-E 3 or Black Forest Labs's FLUX1.1 [pro] via their official API. The backend is located in the backend directory and consists of the following key files:
app.py: The main FastAPI applicationprompts.py: Contains the system and user prompts for the AIsafety_prompts.py: Contains the system and user prompts for safety evaluation of user inputsrequirements.txt: Lists the Python dependencies
The frontend is a Vue.js application that provides the user interface for the story generator. It's located in the frontend directory and uses Vite as the build tool. Key files include:
src/App.vue: The main Vue componentsrc/components/InputForm.vue: View for user inputsrc/components/StoryModal.vue: View for displaying the generated storysrc/components/SettingsModal.vue: View for selecting the color themesrc/services/ai.js: Utility functions for interacting with the backend
To set up this project locally, follow these steps:
-
Clone the repository.
-
Set up the backend:
cd backend python -m venv .venv # Create a virtual environment source .venv/bin/activate # On Windows, use `.venv\Scripts\activate` pip install -r requirements.txt -
Set up environment variables: Copy the
backend/.env.templatefile to a new file called.env. Update the.envfile with your API keys and other environment variables. -
Set up the frontend:
cd frontend npm install -
Copy the
frontend/.env.templatefile to a new file called.env. For local development, you can keep all the default values.
-
Start the backend server:
cd backend source .venv/bin/activate python app.py -
In a new terminal, start the frontend development server:
cd frontend npm run dev -
Open your browser and navigate to
http://localhost:5173(or the URL provided by Vite).
- Select the appropriate grade level for the story.
- Enter the vocabulary words to include in the story.
- Specify a main character for the story.
- Enter a setting for where the story takes place.
- Adjust the humor level.
- Click "Go" to create a custom story.
Additionally, you can choose the color theme for the prototype by clicking on the Settings gear button in the lower-left.
All themes are managed by Tailwind using the tailwindcss-themer package.
Copyright (c) 2024-present, Mike Creighton