|
1 |
| -This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://nextjs.org/docs/app/api-reference/cli/create-next-app). |
| 1 | +# Next-Generation AI Model Playground |
2 | 2 |
|
3 |
| -## Getting Started |
| 3 | +A sophisticated real-time AI model interaction platform with streaming capabilities, built with Next.js 15 and React 19. |
4 | 4 |
|
5 |
| -First, run the development server: |
| 5 | +## Features |
| 6 | + |
| 7 | +- ✨ Real-time AI model interaction with streaming responses |
| 8 | +- 📊 Live metrics tracking (tokens/sec, total tokens) |
| 9 | +- 🔄 Automatic retry logic with exponential backoff |
| 10 | +- 🔧 Configurable model parameters |
| 11 | +- 📱 Progressive Web App (PWA) support |
| 12 | +- 🔌 Offline functionality |
| 13 | +- ⚡ Performance optimized with React memoization |
| 14 | +- 📐 LaTeX equation support |
| 15 | +- 🎨 Dark/Light mode support |
| 16 | + |
| 17 | +## Quick Start |
6 | 18 |
|
7 | 19 | ```bash
|
| 20 | +# Install dependencies (use legacy peer deps due to React 19 RC) |
| 21 | +npm install --legacy-peer-deps |
| 22 | + |
| 23 | +# Start development server |
8 | 24 | npm run dev
|
9 |
| -# or |
10 |
| -yarn dev |
11 |
| -# or |
12 |
| -pnpm dev |
13 |
| -# or |
14 |
| -bun dev |
| 25 | + |
| 26 | +# Build for production |
| 27 | +npm run build |
| 28 | + |
| 29 | +# Start production server |
| 30 | +npm start |
15 | 31 | ```
|
16 | 32 |
|
17 |
| -Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. |
| 33 | +## Architecture Overview |
| 34 | + |
| 35 | +### Core Components |
| 36 | + |
| 37 | +1. **Playground (`components/playground/playground.tsx`)** |
| 38 | + |
| 39 | + - Main interface component |
| 40 | + - Handles user input and AI interactions |
| 41 | + - Manages conversation state |
| 42 | + |
| 43 | +2. **Message System** |
| 44 | + |
| 45 | + - `MessageWindow`: Virtualized message display |
| 46 | + - `MessageItem`: Individual message rendering |
| 47 | + - LaTeX equation support via KaTeX |
| 48 | + - Code syntax highlighting |
| 49 | + |
| 50 | +3. **Model Controls** |
| 51 | + |
| 52 | + - Temperature adjustment |
| 53 | + - Top-P configuration |
| 54 | + - Frequency/Presence penalty settings |
| 55 | + |
| 56 | +4. **Error Handling** |
| 57 | + - Error boundaries for component isolation |
| 58 | + - Automatic retry logic |
| 59 | + - Sentry integration for monitoring |
| 60 | + |
| 61 | +### State Management |
| 62 | + |
| 63 | +- React hooks for local state |
| 64 | +- IndexedDB for conversation persistence |
| 65 | +- Local storage for user preferences |
| 66 | + |
| 67 | +## Performance Considerations |
| 68 | + |
| 69 | +1. **Optimizations** |
| 70 | + |
| 71 | + - Component memoization |
| 72 | + - Virtualized list rendering |
| 73 | + - Service worker for offline support |
| 74 | + - Asset caching strategies |
| 75 | + |
| 76 | +2. **Memory Management** |
| 77 | + - Message virtualization |
| 78 | + - Efficient state updates |
| 79 | + - Cleanup on unmount |
| 80 | + |
| 81 | +## Error Handling |
18 | 82 |
|
19 |
| -You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. |
| 83 | +1. **Retry Logic** |
20 | 84 |
|
21 |
| -This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel. |
| 85 | + - Exponential backoff |
| 86 | + - Configurable attempts |
| 87 | + - Error context preservation |
22 | 88 |
|
23 |
| -## Learn More |
| 89 | +2. **Monitoring** |
| 90 | + - Sentry integration |
| 91 | + - Error logging |
| 92 | + - User feedback |
24 | 93 |
|
25 |
| -To learn more about Next.js, take a look at the following resources: |
| 94 | +## Future Improvements |
26 | 95 |
|
27 |
| -- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. |
28 |
| -- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. |
| 96 | +1. **Features** |
29 | 97 |
|
30 |
| -You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome! |
| 98 | + - Multiple model support |
| 99 | + - Conversation branching |
| 100 | + - Export/Import conversations |
| 101 | + - Collaborative features |
31 | 102 |
|
32 |
| -## Deploy on Vercel |
| 103 | +2. **Technical** |
| 104 | + - WebSocket implementation |
| 105 | + - Stream compression |
| 106 | + - Worker thread processing |
| 107 | + - Enhanced caching strategies |
| 108 | + |
| 109 | +## Known Limitations |
| 110 | + |
| 111 | +1. **Browser Support** |
| 112 | + |
| 113 | + - Service workers require HTTPS |
| 114 | + - IndexedDB storage limits |
| 115 | + - PWA installation requirements |
| 116 | + |
| 117 | +2. **Performance** |
| 118 | + - Initial load time with full bundle |
| 119 | + - Memory usage with long conversations |
| 120 | + - Mobile device considerations |
| 121 | + |
| 122 | +## Edge Cases |
| 123 | + |
| 124 | +1. **Network** |
| 125 | + |
| 126 | + - Intermittent connectivity |
| 127 | + - Failed retry attempts |
| 128 | + - Partial message delivery |
| 129 | + |
| 130 | +2. **User Input** |
| 131 | + |
| 132 | + - Large message handling |
| 133 | + - Special character processing |
| 134 | + - Rate limiting |
| 135 | + |
| 136 | +3. **Storage** |
| 137 | + - Quota exceeded handling |
| 138 | + - Data corruption recovery |
| 139 | + - Cross-device sync limitations |
| 140 | + |
| 141 | +## Development |
| 142 | + |
| 143 | +### Prerequisites |
| 144 | + |
| 145 | +- Node.js 18+ |
| 146 | +- npm or yarn |
| 147 | +- Modern browser with service worker support |
| 148 | + |
| 149 | +### Environment Setup |
| 150 | + |
| 151 | +1. Clone the repository |
| 152 | +2. Install dependencies with `npm install --legacy-peer-deps` |
| 153 | +3. Create `.env.local` with required variables |
| 154 | +4. Start development server |
| 155 | + |
| 156 | +### Testing |
| 157 | + |
| 158 | +```bash |
| 159 | +npm run test # Run unit tests |
| 160 | +npm run test:e2e # Run end-to-end tests |
| 161 | +npm run lint # Run linting |
| 162 | +``` |
33 | 163 |
|
34 |
| -The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. |
| 164 | +## License |
35 | 165 |
|
36 |
| -Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details. |
| 166 | +MIT License - see LICENSE file for details |
0 commit comments