A modern React playground built with Vite to test and experiment with ResilientLLM.
Note: This is an upgrade from the older playground-js. This one has hot module replacement, ES modules, and a clean component-based architecture.
- Multiple Prompts Management - Create, rename, and organize multiple prompt sessions
- Version Control - Save prompts/conversation snapshots as immutable versions
- Conversation Branching - Branch conversations at any message to explore different paths
- System Prompts - Configure system-level instructions for your conversations
- Undo/Redo - Undo message edits and deletions (⌘Z / Ctrl+Z)
- Regenerate Messages - Regenerate any assistant response with a single click
- Copy Messages - Copy any message content to clipboard
- Multiple LLM Service Providers - Support for OpenAI, Anthropic, Google, local models via Ollama or any custom provider you want to configure
- JSON Mode - Toggle between text and structured JSON responses
- Markdown Rendering - Beautiful markdown rendering for AI responses
- Status Bar - Quick access to settings from chat panel header
- Local Storage - All data persisted locally in your browser
playground-react/
├── server/ # Backend API server
│ ├── app.js # Express server with ResilientLLM integration
│ └── devutility.js # Development utilities
├── client/ # Frontend React application
│ ├── index.html # HTML entry point
│ ├── main.jsx # React entry point
│ ├── App.jsx # Main App component
│ ├── styles.css # Global styles
│ ├── context/
│ │ └── AppContext.jsx # Global state management
│ ├── components/ # React components
│ │ ├── Header.jsx # App header with status bar
│ │ ├── Footer.jsx # Library info footer
│ │ ├── PromptsSidebar.jsx # Left sidebar with prompts list
│ │ ├── PromptHeader.jsx # Prompt title and save version
│ │ ├── VersionBar.jsx # Versions and conversations bar
│ │ ├── SystemPrompt.jsx # Collapsible system prompt editor
│ │ ├── MessageList.jsx # Message container with version separator
│ │ ├── Message.jsx # Individual message component
│ │ ├── MessageInput.jsx # Text input with role toggle
│ │ ├── SettingsDrawer.jsx # Configuration panel
│ │ └── UndoNotification.jsx # Undo toast notification
│ └── utils/ # Utility functions
│ ├── constants.js # App constants
│ ├── storage.js # LocalStorage abstraction
│ ├── helpers.js # Formatting and markdown utilities
│ ├── apiKeys.js # API key management
│ ├── providerUtils.js # Provider display names and utilities
│ └── index.js # Utility exports
├── vite.config.js # Vite configuration
└── package.json # Dependencies and scripts
The easiest way to start the playground is from the root of the ResilientLLM repository:
npm run playgroundThis will automatically:
- Link the local
resilient-llmpackage - Install dependencies
- Start both the API server and Vite dev server
If you prefer to run it manually:
cd examples/playground-react
npm installNote: Requires Node.js >= 20.19.0
Set your API key and choose the default LLM service and model:
# OpenAI
export OPENAI_API_KEY=your_key_here
export AI_SERVICE=openai
export AI_MODEL=gpt-4o-mini
# Or Anthropic
export ANTHROPIC_API_KEY=your_key_here
export AI_SERVICE=anthropic
export AI_MODEL=claude-3-5-sonnet-20240620
# Or Google
export GEMINI_API_KEY=your_key_here
export AI_SERVICE=google
export AI_MODEL=gemini-2.0-flash
# Or Local (Ollama)
export AI_SERVICE=local
export AI_MODEL=llama2Note: You can also configure API keys directly in the playground UI via the settings panel.
npm run devThis starts both servers concurrently:
- API Server:
http://localhost:3000(Express backend) - Vite Dev Server:
http://localhost:5173(React frontend with HMR)
Navigate to http://localhost:5173 in your browser.
The Vite dev server automatically proxies API requests to the backend server, so all /api/* requests are forwarded to http://localhost:3000.
npm run dev- Start both API server and Vite dev server concurrentlynpm run client- Start only the Vite dev server (port 5173)npm run server- Start only the API server (port 3000)npm run build- Build the React app for productionnpm run preview- Preview the production buildnpm start- Start only the API server (production mode)
The playground uses Vite for lightning-fast development:
- Instant updates - Changes to React components update immediately without page refresh
- State preservation - Component state is preserved during updates
- Fast builds - Optimized for development speed
All code uses modern ES module syntax (import/export), making it:
- Easy to navigate and understand
- Tree-shakeable for smaller production builds
- Compatible with modern tooling
The app is organized into:
- Context - Global state management via React Context
- Components - Reusable UI components
- Utils - Pure utility functions
- Create a Prompt - Click "+ New" in the sidebar to create a new prompt session
- Save Versions - Click "Save Version" to create an immutable snapshot of your conversation
- Branch Conversations - Click the branch icon on any message to create a new conversation starting from that point
- Edit Messages - Click on any message to edit it inline
- Regenerate Messages - Click the regenerate icon on assistant messages to regenerate the response
- Copy Messages - Click the copy icon on any message to copy its content to clipboard
- Undo Actions - Use ⌘Z (Mac) or Ctrl+Z (Windows/Linux) to undo edits or deletions
- System Prompts - Click on the system prompt area to add/edit system-level instructions
- Settings - Click the ☰ icon in the header or status bar to configure models, temperature, and response mode
To build for production:
npm run buildThe built files will be in the dist/ directory. You can preview the production build with:
npm run previewIf port 3000 or 5173 is already in use, you can change them:
- API Server: Set
PORTenvironment variable (e.g.,PORT=3001 npm run server) - Vite Dev Server: Edit
vite.config.jsand change theserver.portvalue
- API keys can be set via environment variables or in the playground settings
- Keys stored in the UI are saved locally in your browser's localStorage
- Environment variables take precedence over UI-configured keys
If you see module resolution errors:
- Make sure you've run
npm install - Check that you're using Node.js >= 20.0.0
- Try deleting
node_modulesandpackage-lock.json, then runnpm installagain
- React 19 - UI framework
- Vite - Build tool and dev server
- Express - Backend API server
- ResilientLLM - Resilient LLM interface with circuit breaker, rate limiting, and retry logic
- Marked - Markdown rendering
- React Icons - Icon library
- Concurrently - Run multiple commands concurrently
MIT License
