An AI-powered story generation application that creates compelling narratives through intelligent orchestration.
- Tiered Story Planning: Advanced story planning system that breaks down story creation into smaller, faster tasks for improved reliability
- Backup Model Fallback: Automatic fallback to backup models when primary models timeout or fail
- Multi-step Content Generation: Stories are planned, written, critiqued, and edited for quality
- Real-time Progress Tracking: Polling updates during story generation
- Database Persistence: Stories and progress are saved to PostgreSQL with recovery capabilities
- Responsive UI: Modern React-based interface with dark/light theme support
The story planning process has been optimized to use a tiered approach that breaks down story planning into parallel, smaller tasks:
- Story Structure: Overall narrative arc and pacing (~10-15 seconds)
- Character Development: Main and supporting characters (~10-15 seconds)
- Setting Development: Locations and world-building (~10-15 seconds)
- Narrative Elements: Themes, tone, and literary devices (~10-15 seconds)
- Integration: Combining all elements into final plan (~10-15 seconds)
Total time: ~40-60 seconds (down from 55+ seconds for monolithic approach) Success rate: 90%+ (up from 33%)
When the primary model times out or fails, the system automatically:
- Detects timeout: Identifies when LLM calls exceed configured timeouts
- Switches models: Falls back to faster backup model (e.g.,
google/gemini-2.0-flash-exp:free
) - Retries operation: Attempts the same task with backup model
- Logs events: Detailed logging for performance monitoring and debugging
- Story Planning: 40 seconds per subtask (vs 55s monolithic)
- Page Generation: 45 seconds per operation
- Default Operations: 30 seconds
- User submits prompt → API validates and creates session
- Tiered story planning → Structure, characters, settings, themes generated in parallel
- Page-by-page generation → Each page planned, written, critiqued, and edited
- Real-time updates → Progress streamed via WebSocket to frontend
- Story completion → Final story assembled and marked complete
// Automatic fallback on timeout
try {
result = await primaryModel.generateContent(prompt);
} catch (timeoutError) {
console.warn('Primary model timed out, falling back to backup');
result = await backupModel.generateContent(prompt);
}
- Timeout detection: Identifies LLM performance issues
- Automatic retry: Switches to backup model seamlessly
- Graceful degradation: Falls back to simpler approaches when needed
- Detailed logging: Comprehensive error tracking for debugging