This project is an interactive story generation application that uses AI to create unique stories based on user input. It consists of a FastAPI backend for story generation and a Next.js frontend for user interaction.
- Dynamic story generation based on user-selected parameters
- Intuitive user interface with dropdown menus for story customization
- Real-time story display
- Responsive design for various screen sizes
- FastAPI
- Python 3.8+
- OpenAI GPT model (via OpenRouter)
- Pydantic for data validation
- CORS middleware for cross-origin requests
- Next.js
- React
- Axios for API requests
- Tailwind CSS for styling
- Radix UI for accessible component primitives
llm-story-writing-app/
├── app/
│ ├── main.py
│ ├── story_prompt.py
│ └── story_writer.py
├── src/
│ ├── components/
│ │ └── ui/
│ │ ├── button.tsx
│ │ ├── card.tsx
│ │ └── select.tsx
│ ├── lib/
│ │ └── utils.ts
│ ├── pages/
│ │ ├── _app.tsx
│ │ └── index.tsx
│ └── styles/
│ └── globals.css
├── requirements.txt
└── ...other_files
-
Navigate to the project root directory:
cd llm-story-writing-app
-
Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
-
Install dependencies:
pip install -r requirements.txt
-
Create a
.env
file in theapp
directory and add your OpenRouter API key:OPENROUTER_API_KEY=your_api_key_here
-
Run the server:
python app/main.py
The server will start at http://localhost:8000.
-
Navigate to the project root directory:
cd llm-story-writing-app
-
Install dependencies:
npm install
-
Run the development server:
npm run dev
-
Open http://localhost:3000 in your browser to see the application.
- Select a story type from the first dropdown menu.
- Choose a background setting from the second dropdown menu.
- Pick a story theme from the third dropdown menu.
- Click the "Generate Story" button to create your unique story.
- Wait for the AI to generate the story, which will then be displayed on the screen.
Once the server is running, you can access the API documentation and test the endpoints using Swagger UI at:
This interactive interface allows you to:
- Explore available endpoints
- View request and response schemas
- Test API endpoints directly from your browser
-
POST /api/v1/generate_story
: Generates a story based on the provided parameters.Request body:
{ "story_type": string, "background_setting": string, "story_theme": string }
Response:
{ "prompt": string, "story": string }
Contributions are welcome! Please feel free to submit a Pull Request.
This project is open source and available under the MIT License.