Skip to content

yugandher2000/LangChain

Repository files navigation

LangChain Projects Repository

A comprehensive collection of LangChain-based applications demonstrating various AI-powered use cases including chatbots, document Q&A, language translation, and more.


πŸ“ Repository Structure

This repository contains multiple independent projects, each showcasing different LangChain capabilities:

LangChain/
β”œβ”€β”€ IntroSection/              # LangChain basics and middleware concepts
β”œβ”€β”€ Building-chatBot/          # Basic chatbot implementation
β”œβ”€β”€ E2E_QA_ChatBot/           # End-to-end Q&A chatbot with multiple models
β”œβ”€β”€ LanguageTranslation/      # Translation API with LangServe
β”œβ”€β”€ RAG_document_QA/          # RAG-based document question answering
└── Text-summarization/       # Web page content summarizer

πŸš€ Projects Overview

1. IntroSection - LangChain Fundamentals

Introduction to LangChain concepts, basic chains, and middleware patterns.

Contents:

  • LangchainIntro.ipynb - Getting started with LangChain
  • Middlewares.ipynb - Understanding LangChain middlewares

2. Building-chatBot - Basic ChatBot

Simple chatbot implementation demonstrating core LangChain chat functionality.

Contents:

  • ChatBot.ipynb - Basic chatbot notebook

3. E2E_QA_ChatBot - Multi-Model Q&A Chatbot

A fully-featured Streamlit chatbot supporting multiple AI models from Groq - all 100% FREE!

Features:

  • βœ… 9 Different Models: OpenAI-compatible, LLaMA, Mixtral, Gemma
  • βœ… Runtime API Key Input: No .env file needed
  • βœ… Configurable Parameters: Temperature, max tokens
  • βœ… Persistent Chat History: Session-based conversations

Quick Start:

cd E2E_QA_ChatBot
streamlit run app.py

Models Available:

  • OpenAI GPT OSS 120B (OpenAI-compatible)
  • Meta LLaMA 3.3 70B, 3.1 8B/70B, 3.2 1B/3B
  • Mixtral 8x7B
  • Google Gemma 2 9B, 7B

πŸ“– Full Documentation


4. LanguageTranslation - Translation API

A FastAPI-based translation service using LangChain and LangServe.

Features:

  • 🌐 Multi-language Translation: English to any language
  • ⚑ REST API: FastAPI with automatic Swagger docs
  • πŸ”— LangServe Integration: Easy-to-use API routes

Quick Start:

cd LanguageTranslation
python serve.py

API Endpoint:

  • POST http://localhost:8000/chain/invoke

Example Request:

{
  "input": {
    "language": "French",
    "text": "Hello, how are you?"
  },
  "config": {},
  "kwargs": {}
}

Interactive Docs: http://localhost:8000/docs


5. RAG_document_QA - Document Q&A with RAG

Retrieval-Augmented Generation application for asking questions about PDF documents.

Features:

  • πŸ“„ PDF Processing: Automatic document loading and chunking
  • πŸ” Semantic Search: FAISS vector store for similarity search
  • πŸ€– AI-Powered Answers: Groq ChatGroq model with context
  • πŸ’Ύ Ollama Embeddings: Local embeddings generation
  • πŸ“Š Context Display: View source chunks used for answers

Quick Start:

cd RAG_document_QA
# Make sure Ollama is running: ollama serve
streamlit run app.py

Prerequisites:

  • Ollama installed and running
  • PDF documents in research_papers/ folder
  • Groq API key

πŸ“– Full Documentation


6. Text-summarization - Web Page Content Summarizer

AI-powered content summarization tool that extracts and summarizes content from web pages.

Features:

  • 🌐 Web Page Summarization: Summarizes articles, blogs, and documentation
  • πŸ€– ChatGroq AI: Uses LLaMA 3.3 70B (128K context) for intelligent summarization
  • πŸ”‘ Runtime API Key: Enter API key in UI - no .env file required
  • πŸ‘οΈ Content Preview: View original content before summary
  • πŸ“Š Metadata Display: Shows source information
  • ⚑ Handles Long Content: Automatic chunking for large articles

Quick Start:

cd Text-summarization
streamlit run app.py
# Enter Groq API key in sidebar
# Paste any webpage URL

Example URLs:

  • Web page: https://example.com/article
  • News articles, blogs, technical docs

πŸ“– Full Documentation


πŸ› οΈ Setup & Installation

Prerequisites

  • Python 3.8+ (3.10+ recommended)
  • Ollama (for RAG_document_QA project)
  • Groq API Key (get it FREE at console.groq.com)

Installation Steps

  1. Clone or navigate to the repository:

    cd "C:\Users\LangChain"
  2. Create and activate a virtual environment:

    python -m venv .myvenv
    .\.myvenv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Set up environment variables:

    Create a .env file in the project root:

    GROG_API_KEY=your_groq_api_key_here
    GROQ_API_KEY=your_groq_api_key_here

    Note: Some projects use GROG_API_KEY and others use GROQ_API_KEY

  5. Install Ollama (for RAG project):

    • Download from ollama.ai
    • Pull required model: ollama pull llama3.1

πŸ“¦ Dependencies

Core packages used across projects:

  • LangChain - Framework for LLM applications
  • LangServe - API deployment for LangChain
  • LangChain-Groq - Groq model integration
  • Streamlit - Web UI framework
  • FastAPI - REST API framework
  • FAISS - Vector similarity search
  • Ollama - Local embeddings
  • PyPDF - PDF processing

Install all dependencies:

pip install -r requirements.txt

🎯 Quick Start Guide

For Chatbots (E2E_QA_ChatBot):

cd E2E_QA_ChatBot
streamlit run app.py
# Enter Groq API key in UI

For Translation API (LanguageTranslation):

cd LanguageTranslation
python serve.py
# Visit http://localhost:8000/docs

For Document Q&A (RAG_document_QA):

# Start Ollama first
ollama serve

# In another terminal
cd RAG_document_QA
streamlit run app.py

For Content Summarization (Text-summarization):

cd Text-summarization
streamlit run app.py
# Enter Groq API key in sidebar
# Paste webpage URL

πŸ”‘ API Keys

All projects use Groq models, which are:

  • βœ… 100% FREE - No credit card required
  • ⚑ Lightning Fast - Extremely fast inference
  • πŸ”„ Generous Limits - Suitable for development and production

Get your free API key: console.groq.com/keys

Two Ways to Use API Keys:

  1. Runtime Input (Recommended): Enter in the UI sidebar when the app starts
  2. Environment Variable (Optional): Set in .env file for convenience

Most projects support entering the API key at runtime through the UI!


πŸ“– Documentation

Each project has its own detailed README:


🀝 Contributing

Feel free to explore, modify, and extend these projects for your own use cases.


πŸ“ Notes

  • Projects are independent and can be run separately
  • Shared dependencies are in the root requirements.txt
  • Environment variables can be set globally in root .env
  • Each project may have specific setup requirements (see individual READMEs)

πŸ› Troubleshooting

Common Issues:

  1. Import errors: Make sure virtual environment is activated and dependencies are installed
  2. API key errors: Check .env file exists with correct key names
  3. Ollama errors: Ensure Ollama is running with ollama serve
  4. Port conflicts: Change ports in respective app files if 8000/8501 are in use

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors