Skip to content

πŸ€– AI Chatbot using React & Bootstrap | Supports Together AI, Fireworks AI, and Hugging Face | Real-time Responses & Typing Indicator πŸš€

Notifications You must be signed in to change notification settings

amankkamboj/chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ AI Chatbot with Multiple AI Models (React + Bootstrap)

Chatbot Preview

A powerful React-based AI Chatbot that supports multiple AI models (Together AI, Fireworks AI, and Hugging Face). This chatbot features real-time streaming, a typing indicator, and a simple UI built with Bootstrap.


πŸ”Ή Features

βœ” Multi-Model Support: Choose between Together AI, Fireworks AI, and Hugging Face
βœ” Real-Time Streaming: AI responses appear word-by-word for a realistic chat experience
βœ” Typing Indicator: Shows "Bot is typing..." while waiting for a response
βœ” Bootstrap UI: Simple and responsive design
βœ” API Key Management: Uses environment variables for security


πŸ“Œ Demo

Try it live here: Live Demo


πŸ”§ Installation

1️⃣ Clone the Repository

git clone https://github.com/amankkamboj/ai-chatbot.git
cd ai-chatbot

 **2️⃣ Install Dependencies**

```sh
npm install


 **3️⃣ Set Up Environment Variables**

Create a `.env` file in the project root and add your API keys:


REACT_APP_TOGETHER_AI_KEY=your_together_ai_api_key
REACT_APP_FIREWORKS_API_KEY=your_fireworks_api_key
REACT_APP_HUGGINGFACE_API_KEY=your_huggingface_api_key


**Get API Keys from:**

- πŸ”Ή [Together AI](https://together.ai/)
- πŸ”Ή [Fireworks AI](https://fireworks.ai/)
- πŸ”Ή [Hugging Face](https://huggingface.co/)

---

 **πŸš€ Run the Chatbot**


npm start


The chatbot will be available at:
πŸ”— `http://localhost:3000`

---

**πŸ› οΈ How It Works**

 **1️⃣ Select AI Model**

Choose from:

- πŸ”Ή **Together AI (DeepSeek-R1)**
- πŸ”Ή **Fireworks AI (LLaMA 2-13B)**
- πŸ”Ή **Hugging Face (Flan-T5 Large)**

 **2️⃣ Type a Message**

- The bot will show **"Typing..."** while generating a response.
- If **Together AI is selected**, the response is **streamed word-by-word**.
- The final AI-generated response is displayed.

---

 **πŸ“ Code Explanation**

 **πŸ”Ή `Chatbot.js` (Main Component)**

- **Handles user input** and **sends API requests**.
- **Displays responses** from the selected AI model.
- **Manages typing indicator and streaming responses**.

javascript
const [messages, setMessages] = useState([]);
const [input, setInput] = useState("");
const [selectedAI, setSelectedAI] = useState("together");
const [isTyping, setIsTyping] = useState(false);




 **πŸ”Ή AI API Calls**

Each AI model has **different response formats**, so we handle them correctly.

 **Together AI (DeepSeek-R1)**

- Uses **real-time streaming** for better UX.
- API: `https://api.together.xyz/v1/chat/completions`


{
  model: "deepseek-ai/DeepSeek-R1",
  messages: [{ role: "user", content: input }],
  stream: true
}


 **Fireworks AI (LLaMA 2-13B)**

- API: `https://api.fireworks.ai/inference/v1/completions`

```javascript
{
  model: "accounts/fireworks/models/llama-v2-13b-chat",
  prompt: input,
  max_tokens: 100
}
```

 **Hugging Face (Flan-T5 Large)**

- API: `https://api-inference.huggingface.co/models/google/flan-t5-large`


{
  inputs: input;
}
```

---

 **🎨 UI Design**

- Built with **React Bootstrap** for a clean and responsive UI.
- **Typing Indicator** shows an animated **spinner** while waiting for AI response.


{
  isTyping && (
    <div className="text-start text-muted">
      <Spinner animation="grow" size="sm" /> Bot is typing...
    </div>
  );
}


 **πŸ“Œ Future Enhancements**

πŸ”Ή **Support more AI models** (e.g., OpenAI GPT, Cohere)
πŸ”Ή **Add voice input & text-to-speech**
πŸ”Ή **Dark mode support**
πŸ”Ή **Host on Vercel or Netlify**

---

 **πŸ™Œ Contributing**

1. **Fork the repo**
2. **Create a feature branch** (`git checkout -b feature-name`)
3. **Commit your changes** (`git commit -m "Added new feature"`)
4. **Push to GitHub** (`git push origin feature-name`)
5. **Open a Pull Request**

---

 **πŸ“œ License**

This project is **open-source** under the **MIT License**.

---

 **πŸ“ž Contact**

πŸ’‘ Created by [**Aman Kamboj**]
πŸ“§ Email: **amankamboj2387@gmail.com**
πŸ”— GitHub: [**https://github.com/amankkamboj/**]
πŸ”— LinkedIn: [**https://www.linkedin.com/in/freelancer-aman-webdeveloper/**]

About

πŸ€– AI Chatbot using React & Bootstrap | Supports Together AI, Fireworks AI, and Hugging Face | Real-time Responses & Typing Indicator πŸš€

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published