An open API service indexing awesome lists of open source software.

https://github.com/devdoshi19/chatbot_using_basic_langchain

A professional AI Chatbot built with LangChain and Google Gemini, featuring a custom UI using Streamlit.
https://github.com/devdoshi19/chatbot_using_basic_langchain

chat-application chatbot gemini-api generative-ai langchain python python3 streamlit

Last synced: about 2 months ago
JSON representation

A professional AI Chatbot built with LangChain and Google Gemini, featuring a custom UI using Streamlit.

Awesome Lists containing this project

README

          

πŸ€– Gemini-Powered Chatbot (LangChain + Streamlit)

###


🧠 A basic AI chatbot built using LangChain and Google Gemini

⚑ Features real-time streaming responses and session-based memory

🧩 Clean separation between UI and LLM logic

###




---

## πŸ“ Project Structure

```

.
β”œβ”€β”€ app.py # Streamlit UI
β”œβ”€β”€ chatbot_stremlit.py # LangChain + Gemini logic
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ .gitignore
β”œβ”€β”€ README.md
└── .env # API keys (created by user)

````

---

## 🌟 Key Features

- 🧠 **Session-based Conversational Memory**
Maintains chat history using `st.session_state`

- ⚑ **Streaming Responses**
Uses LangChain `.stream()` for live output

- 🧩 **Clean Architecture**
- `chatbot_stremlit.py` β†’ AI logic
- `app.py` β†’ UI and interaction

- πŸ” **Secure API Management**
Uses `.env` file with `python-dotenv`

---



---

## πŸ› οΈ Tech Stack

- **Language:** Python 3.10+
- **LLM:** Google Gemini (`gemini-2.5-flash-lite`)
- **Frameworks:** LangChain (LCEL), Streamlit
- **Utilities:** python-dotenv

---

## πŸš€ Complete Setup Guide

### 1️⃣ Clone the Repository

```bash
git clone https://github.com/DevDoshi19/ChatBot_using_Basic_LangChain.git
````

---

### 2️⃣ (Optional) Create Virtual Environment

```bash
python -m venv venv
source venv/bin/activate # macOS / Linux
venv\Scripts\activate # Windows
```

---

### 3️⃣ Install Dependencies

```bash
pip install -r requirements.txt
```

---

### 4️⃣ Create `.env` File

Create a file named **`.env`** in the root directory.

```env
GOOGLE_API_KEY=your_google_gemini_api_key_here
```

⚠️ Never commit `.env` to GitHub.

---

### 5️⃣ Run the App

```bash
streamlit run app.py
```

The chatbot will open in your browser.

---

## 🧠 How It Works (High-Level)

```
User β†’ Streamlit UI β†’ LangChain Prompt
β†’ Gemini Model β†’ Streamed Response
```

* Chat history is injected using `MessagesPlaceholder`
* Responses stream live using `st.write_stream`
* Memory persists within the session

---

## πŸ“¦ requirements.txt (Example)

```txt
streamlit
langchain
langchain-google-genai
python-dotenv
```

---

## 🧠 What I Learned

* Using **LangChain Expression Language (LCEL)**
* Handling Streamlit reruns via **Session State**
* Implementing **real-time LLM streaming**
* Structuring AI apps cleanly and scalably

---

## πŸ‘¨β€πŸ’» Author

**Dev Doshi**
B.Tech | AI / ML | LangChain | Streamlit | Generative AI

---

## πŸ”— Let’s Connect





---
## πŸš€ Demo

https://github.com/user-attachments/assets/6d8c7f3a-f731-4fb2-8406-1e566a351270

---

⭐ If you found this useful, consider starring the repository.

```
Thank you for reading
```