Skip to content

Alena0490/Chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🐱 Mojo Chatbot

Mojo Chatbot Screenshot

A modern, interactive AI chatbot built with React and powered by Groq API. Mojo is a friendly turquoise cat assistant that provides helpful responses with personality and style.

React Vite License

✨ Features

  • πŸ€– AI-Powered Responses - Integration with Groq API (Llama 3.3 70B model)
  • ⌨️ Typewriter Effect - Smooth character-by-character message animation
  • 😺 Mood Detection - Dynamic avatar changes based on conversation context (10 different moods)
  • 🎨 Glassmorphism Design - Modern UI with frosted glass effects and gradient animations
  • πŸ“± Fully Responsive - Optimized for desktop, tablet, and mobile devices
  • β™Ώ Accessibility - ARIA labels and keyboard navigation support
  • πŸ’Ύ Session Persistence - Conversation history maintained during session
  • 🎯 Smart Focus Management - Auto-focus on input field for better UX
  • ⚑ Skip Animation - Click messages to instantly display full text

πŸ› οΈ Tech Stack

  • React 18.3.1 - UI library
  • Vite 6.0.3 - Build tool and dev server
  • Groq API - LLM provider (Llama 3.3 70B Versatile)
  • React Icons - Icon library (Lucide React)
  • CSS3 - Styling with custom properties and animations

πŸ“¦ Installation

Prerequisites

Setup

  1. Clone the repository

    git clone <your-repo-url>
    cd mojo-chatbot
  2. Install dependencies

    npm install
  3. Configure API proxy

The project uses a proxy server to handle Groq API calls. Update the API_URL in src/services/groqService.js:

const API_URL = 'https://your-proxy-url.vercel.app/api/chat';

πŸš€ Development

Start the development server:

npm run dev

The app will be available at http://localhost:5173

πŸ—οΈ Build

Create a production build:

npm run build

Preview the production build:

npm run preview

πŸ“ Project Structure

β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ avatars/          # Mood-based avatar images
β”‚   └── img/              # Background images
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ Chatbot.jsx           # Main chatbot component
β”‚   β”‚   β”œβ”€β”€ Chatbot.css           # Chatbot styling
β”‚   β”‚   β”œβ”€β”€ TypewriterMessage.jsx # Typewriter animation component
β”‚   β”‚   └── TypewriterMessage.css # Typewriter styling
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── groqService.js        # Groq API integration
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── detectMood.js         # Mood detection logic
β”‚   β”œβ”€β”€ App.jsx           # Root component
β”‚   β”œβ”€β”€ index.css         # Global styles
β”‚   └── main.jsx          # Entry point
β”œβ”€β”€ index.html
β”œβ”€β”€ vite.config.js
└── package.json

βš™οΈ Configuration

Groq API Parameters

Modify parameters in src/services/groqService.js:

{
  model: 'llama-3.3-70b-versatile',
  temperature: 0.9,          // Creativity level (0-2)
  top_p: 0.95,              // Nucleus sampling
  max_tokens: 400,          // Response length limit
  presence_penalty: 0.3,    // Topic diversity
  frequency_penalty: 0.4    // Repetition penalty
}

Typewriter Speed

Adjust typing speed in src/components/Chatbot.jsx:

<TypewriterMessage
  cps={18}              // Characters per second
  startDelay={250}      // Initial delay (ms)
  showCaret={true}      // Show blinking cursor
  enableSkip={true}     // Allow click to skip
/>

Mood Detection

Add or modify mood keywords in src/utils/detectMood.js:

const partyKeywords = [
  'hurΓ‘', 'oslav', 'gratuluj', 'vΓ½hra', // Add your keywords
];

🎨 Customization

Color Scheme

Edit CSS variables in src/index.css:

:root {
  --leo-primary: #94d7f1;      /* Main accent color */
  --leo-secondary: #d5192e;    /* Button color */
  --leo-bg: #1a1a1a;           /* Background */
  --leo-text: #e0e0e0;         /* Text color */
}

System Prompt

Customize the AI personality in src/services/groqService.js:

{
  role: 'system',
  content: 'You are MOJO, a turquoise cat. You are an AI assistant...'
}

🌐 Deployment

Vercel

  1. Push your code to GitHub
  2. Import project in Vercel
  3. Configure environment variables
  4. Deploy

πŸ“ API Proxy Setup

For security, API calls go through a proxy server. Here's a basic example:

// api/chat.js (Vercel Serverless Function)
export default async function handler(req, res) {
  const response = await fetch('https://api.groq.com/openai/v1/chat/completions', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.GROQ_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify(req.body)
  });
  
  const data = await response.json();
  res.status(200).json(data);
}

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

πŸ“„ License

This project is licensed under the MIT License.

πŸ™ Acknowledgments

  • Groq for providing the AI infrastructure
  • React team for the excellent framework
  • Vite team for the blazing fast build tool

πŸ“§ Contact

For questions or feedback, please open an issue on GitHub.


Made with ❀️ and React

About

Rect AI Chatbot, fully responsive.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors