A complete Next.js application that demonstrates the full workflow of collecting data, fine-tuning models, and chatting with your custom AI models using PremAI.
# Install dependencies
npm install
# Set up your API key (see Setup section)
cp .env.example .env
# Start the development server
npm run devVisit http://localhost:3000 to start chatting with your fine-tuned models!
Use the integrated scraper to gather training data from any blog:
# Scrape Sam Altman's blog (perfect for AI/tech content) - it uses rss feed
npm run scrape https://blog.samaltman.com/What happens:
- 🔍 Automatically finds RSS/Atom feeds
- 💾 Saves in batches of 10 posts to
./scraper/scraped/
Output: Text files ready for building dataset (e.g., batch_1_posts_1-10.txt)
Step 1: Create Dataset
- Visit PremAI Studio Datasets
- Create a new dataset based on synthetic data
- Upload your text files from
./scraper/scraped/(the batch files you generated)
Step 2: Prepare Training Data
- Move data to training/validation samples (you can use the autosplit feature for automatic data splitting)
- Create a snapshot based on your training and validation datasets
Step 3: Fine-tune Your Model
- Go to PremAI Studio Fine-tuning
- Run a fine-tuning job using your prepared dataset snapshot
- Run experiments and track training progress
- After completion - your custom models are ready to use in the chat interface!
Your model will now have knowledge from the blogs you scraped!
Launch the Chat Interface:
npm run devAsk questions about the content you trained on and see how your model responds with domain-specific knowledge.
Create a .env file in the root directory:
PREMAI_API_KEY=your_api_key_here- Sign up at PremAI
- Get your API key from API Keys page
- Add it to your
.envfile
├── src/
│ ├── app/
│ │ ├── api/
│ │ │ ├── chat/route.ts # Chat API endpoint
│ │ │ └── models/route.ts # Models listing API
│ │ ├── page.tsx # Main chat interface
│ │ └── layout.tsx # App layout
│ ├── components/ # React components
│ │ ├── ChatHeader.tsx
│ │ ├── MessageList.tsx
│ │ ├── MessageInput.tsx
│ │ └── ModelSelector.tsx
│ └── types/
│ └── errors.ts # Type-safe error handling
├── scraper/
│ ├── scrape.js # RSS/Atom feed scraper script
│ └── scraped/ # Generated content (gitignored)
└── package.json # Dependencies & scripts
# Development
npm run dev # Start Next.js dev server
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
# Data Collection
npm run scrape <url> # Scrape blog content for trainingSam Chat - Built with ❤️ using PremAI
