Skip to content

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

Notifications You must be signed in to change notification settings

DevDoshi19/ChatBot_using_Basic_LangChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 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

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

2️⃣ (Optional) Create Virtual Environment

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

3️⃣ Install Dependencies

pip install -r requirements.txt

4️⃣ Create .env File

Create a file named .env in the root directory.

GOOGLE_API_KEY=your_google_gemini_api_key_here

⚠️ Never commit .env to GitHub.


5️⃣ Run the App

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)

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

chatbot_langchain.-.Made.with.Clipchamp.mp4

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

Thank you for reading

About

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

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages