An AI-powered chat application with customizable personalities, embeddable widget, and visitor behavior tracking. Built with React, Vite, Tailwind CSS, and powered by Ollama (local AI) or Google Gemini (cloud AI) - you choose!
- Dual AI Provider Support - Choose between Ollama (local/free) or Google Gemini (cloud-based)
- 8 Customizable AI Personalities - Friendly Assistant, Professional Advisor, Creative Writer, Tech Expert, Life Coach, Data Analyst, Customer Support, Educator
- Multiple AI Models
- Ollama: Llama 3.1, Mistral 7B, Phi-3 Mini, Gemma 2B
- Gemini: Gemini 1.5 Flash, Gemini 1.5 Pro, Gemini Pro
- RAG-Powered Knowledge - Optional Supabase integration for vector embeddings and contextual responses
- Responsive Design - Inspired by iMessage and WhatsApp, works beautifully on all devices
- Embeddable Widget - Easy-to-embed Web Component for any website
- Visitor Analytics - Track user behavior, interactions, and engagement
- Flexible Deployment - 100% free with Ollama, or use Gemini with your API key
- Streaming responses with real-time updates
- Message history with timestamps
- Multiple personality selection
- AI Provider switching (Ollama β Gemini)
- Model switching
- Connection status monitoring
- Keyboard shortcuts (Enter to send, Shift+Enter for newline)
- Smooth animations and transitions
- Mobile-responsive design
- Node.js (v18 or higher)
- Ollama installed and running locally
# Install Ollama (macOS/Linux)
curl https://ollama.ai/install.sh | sh
# Pull a model
ollama pull llama3.1:8b- Node.js (v18 or higher)
- Gemini API Key from Google AI Studio
# Clone the repository
git clone https://github.com/wjak-official/ai-chat.git
cd ai-chat
# Install dependencies
npm install
# Start development server
npm run devOpen http://localhost:5173 in your browser!
π For detailed setup instructions, see QUICKSTART.md
The application supports two AI providers that you can switch between:
- Ensure Ollama is running on your machine
- Open Settings
- Select "Ollama" as your AI Provider
- Choose your preferred model (Llama 3.1, Mistral, etc.)
- Start chatting!
- Get your API key from Google AI Studio
- Open Settings
- Select "Gemini" as your AI Provider
- Enter and save your API key
- Choose your preferred Gemini model
- Start chatting!
The application provides a full-featured chat interface:
- Select a Personality - Choose from 8 different AI personalities
- Configure AI Provider - Choose between Ollama or Gemini
- Start Chatting - Type your message and press Enter
- Switch Models - Choose between different AI models
- Clear Chat - Reset conversation history anytime
Add the chat widget to any website:
<!-- Add to your HTML -->
<script src="https://your-domain.vercel.app/widget/ai-chat-widget.js"></script>
<ai-chat-widget
api-url="https://your-domain.vercel.app"
personality="customer-support"
position="bottom-right"
auto-open="false"
tracking="true"
></ai-chat-widget>| Attribute | Options | Description |
|---|---|---|
api-url |
URL | Your deployed chat application URL |
personality |
friendly-assistant, professional-advisor, tech-expert, customer-support, creative-writer, life-coach, data-analyst, educator | AI personality to use |
position |
bottom-right, bottom-left, top-right, top-left | Widget position on screen |
auto-open |
true, false | Automatically open widget after 2 seconds |
tracking |
true, false | Enable visitor behavior tracking |
The widget tracks visitor behavior and provides detailed analytics:
// Access analytics data
const analytics = window.AIChatWidget.getAnalytics();
console.log(analytics);
// Returns:
// {
// sessionId: "session_...",
// events: [...],
// summary: {
// totalEvents: 45,
// clicks: 12,
// scrolls: 8,
// widgetOpened: true
// }
// }- Page views and navigation
- User clicks and interactions
- Scroll behavior and depth
- Form submissions
- Widget open/close/minimize
- Chat messages sent/received
- Time spent on page
| Model | Size | Description | Recommended |
|---|---|---|---|
| Llama 3.1 8B | 4.7GB | Meta's powerful language model | β Yes |
| Mistral 7B | 4.1GB | Fast and efficient model | β Yes |
| Phi-3 Mini | 2.3GB | Microsoft's compact model | - |
| Gemma 2B | 1.4GB | Google's lightweight model | - |
# Recommended models
ollama pull llama3.1:8b
ollama pull mistral:7b
# Lighter alternatives
ollama pull phi3:mini
ollama pull gemma:2b
# For RAG embeddings
ollama pull all-minilm| Model | Context Window | Description | Recommended |
|---|---|---|---|
| Gemini 1.5 Flash | 1M tokens | Fast and efficient multimodal model | β Yes |
| Gemini 1.5 Pro | 2M tokens | Most capable multimodal model | β Yes |
| Gemini Pro | 30K tokens | Best for text-based tasks | - |
- Get your API key from Google AI Studio
- Open Settings in the app
- Select "Gemini" as AI Provider
- Enter your API key
- Choose a model and start chatting!
Note: Gemini API is free for up to 60 requests per minute. See pricing for details.
Enable website knowledge using Supabase for vector embeddings:
- Sign up at https://supabase.com (free tier)
- Create a new project
- Wait for initialization (~2 minutes)
Run the SQL from supabase-setup.sql in Supabase SQL Editor:
-- Enables vector extension, creates tables, and sets up search functions
-- See supabase-setup.sql for full SQLAdd to .env:
VITE_SUPABASE_URL=your-supabase-project-url
VITE_SUPABASE_ANON_KEY=your-supabase-anon-keyimport ragService from './src/services/rag';
// Index webpage content
await ragService.indexWebsiteContent(
'https://yoursite.com/page',
'Your page content here...',
{ title: 'Page Title', category: 'docs' }
);The AI will now use this knowledge to provide contextual responses!
-
Friendly Assistant π
- Warm, approachable, and helpful
- Great for general conversations
-
Professional Advisor πΌ
- Formal and strategic
- Best for business inquiries
-
Creative Writer βοΈ
- Imaginative and expressive
- Perfect for storytelling and creative tasks
-
Tech Expert π»
- Technical and detailed
- Ideal for coding and technical questions
-
Life Coach π
- Supportive and motivational
- Great for personal development
-
Data Analyst π
- Analytical and data-driven
- Best for insights and analysis
-
Customer Support π§
- Patient and empathetic
- Perfect for customer service
-
Educator π
- Teaching-focused and explanatory
- Ideal for learning and education
Edit src/config/personalities.js:
{
id: 'custom-personality',
name: 'Custom Name',
avatar: 'π',
description: 'A brief description',
systemPrompt: 'Your detailed system prompt...',
color: '#ff6b6b'
}-
Build the project
npm run build
-
Deploy with Vercel CLI
npm install -g vercel vercel
-
Set environment variables in Vercel Dashboard:
VITE_OLLAMA_API_URL- Your Ollama server URL (if using Ollama)VITE_GEMINI_API_KEY- Your Gemini API key (if using Gemini)VITE_SUPABASE_URL- (Optional) Supabase project URLVITE_SUPABASE_ANON_KEY- (Optional) Supabase anon key
- Push to GitHub
- Import project in Vercel dashboard
- Configure environment variables
- Deploy!
Note: With Gemini, you don't need to host any AI infrastructure - just configure your API key! For Ollama, host it on a server accessible from Vercel (e.g., Railway, Render, or your own VPS).
ai-chat/
βββ src/
β βββ components/ # React components
β β βββ ChatContainer.jsx
β β βββ ChatWindow.jsx
β β βββ ChatMessage.jsx
β β βββ ChatInput.jsx
β β βββ PersonalitySelector.jsx
β β βββ Settings.jsx
β βββ contexts/ # React contexts
β β βββ ChatContext.jsx
β βββ services/ # API services
β β βββ ai.js # Unified AI service
β β βββ ollama.js # Ollama API integration
β β βββ gemini.js # Gemini API integration
β β βββ analytics.js # Analytics tracking
β β βββ rag.js # RAG with Supabase
β βββ config/ # Configuration
β β βββ personalities.js
β β βββ ollama.js
β β βββ gemini.js
β β βββ supabase.js
β βββ utils/ # Utility functions
βββ public/
β βββ widget/ # Embeddable widget
β β βββ ai-chat-widget.js
β βββ widget-demo.html # Widget demo
βββ dist/ # Production build
Create .env file:
# Ollama API (for local AI)
VITE_OLLAMA_API_URL=http://localhost:11434
# Google Gemini API (for cloud AI)
VITE_GEMINI_API_KEY=your-gemini-api-key-here
# Supabase (optional - for RAG)
VITE_SUPABASE_URL=your-supabase-url
VITE_SUPABASE_ANON_KEY=your-supabase-anon-key
# Analytics (optional)
VITE_ANALYTICS_ENABLED=trueEdit src/config/ollama.js to customize:
- API endpoint
- Default model
- Generation parameters (temperature, top_p, etc.)
Edit src/config/gemini.js to customize:
- Default model
- Generation parameters
- Safety settings
- Context window limits
Edit src/config/personalities.js to:
- Add new personalities
- Modify system prompts
- Change avatars and colors
- β Local AI processing with Ollama (no external data transfer)
- β Cloud AI with Google Gemini (enterprise-grade security)
- β API keys stored in environment variables
- β Supabase RLS (Row Level Security) enabled
- β HTTPS recommended for production
- β CSP headers in production recommended
Note: When using Gemini, data is sent to Google's servers for processing. Review Google's privacy policy for details.
- Chrome/Edge (latest)
- Firefox (latest)
- Safari (latest)
- Mobile browsers (iOS Safari, Chrome Mobile)
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
MIT License - free to use for personal or commercial purposes.
- Ensure Ollama is running:
ollama list - Check API endpoint in
.env - Verify CORS settings
- Try switching to Gemini provider if available
- Verify your API key is correct
- Check you have credits/quota remaining
- Ensure API key has proper permissions
- Try regenerating your API key
Ollama:
- Pull models:
ollama pull llama3.1:8b - Restart Ollama service
- Check Ollama logs
Gemini:
- Verify internet connection
- Check API key is valid
- Ensure you've accepted Google's terms
rm -rf node_modules package-lock.json
npm install
npm run build- Check script URL is correct
- Verify CORS headers
- Check browser console for errors
- Ollama Documentation
- Google AI Studio - Get Gemini API keys
- Gemini API Documentation
- Supabase Documentation
- Vercel Documentation
- React Documentation
- Tailwind CSS
Built with:
- React 19 - UI framework
- Vite 7 - Build tool
- Tailwind CSS 4 - Styling
- Ollama - Local AI inference
- Google Gemini - Cloud AI inference
- @google/generative-ai - Gemini SDK
- Supabase - Vector database (optional)
- Vercel - Hosting platform
Made with β€οΈ for the open-source community
Star β this repository if you find it useful!





