lexibot-api / README.md
Mrigank005's picture
Update README.md
63a9040 verified
metadata
title: Lexibot Api
emoji: πŸ”₯
colorFrom: red
colorTo: gray
sdk: docker
pinned: false
license: mit

LexiBot API πŸ€–βš–οΈ

Headless RAG API for Indian Legal Information

LexiBot is an AI-powered legal assistant that provides accurate information about Indian laws. Built with FastAPI, LangChain, and Pinecone for scalable, serverless deployment.


🌟 Features

  • Legal RAG System - Retrieval-Augmented Generation for accurate legal information
  • Context Injection - Prevents section overlap between different Acts
  • Session Memory - Maintains conversation context per session
  • REST API - Clean, headless API for frontend integration
  • Serverless Ready - Optimized for Hugging Face Spaces deployment

πŸ“š Supported Legal Documents

Act Description
Consumer Protection Act, 2019 Consumer rights and grievance redressal
Motor Vehicles Act, 2019 Traffic laws, licensing, penalties
IPC Harassment Sections Criminal harassment provisions
Domestic Violence Act, 2005 Protection of women from domestic violence
POCSO Act, 2012 Protection of children from sexual offences
Workplace Harassment Act, 2013 Prevention of sexual harassment at workplace

πŸš€ Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/yourusername/lexibot-api.git
cd lexibot-api

# Create virtual environment
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

Configuration

# Copy environment template
cp .env.example .env

# Edit .env with your API keys
GOOGLE_API_KEY=your_google_api_key
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX_NAME=lexibot-legal-docs

Data Ingestion (One-time)

# Process legal documents and upload to Pinecone
python ingest_optimized.py

Run the API

# Development mode
uvicorn app:app --reload --port 7860

# Production mode
uvicorn app:app --host 0.0.0.0 --port 7860

πŸ“‘ API Endpoints

Health Check

GET /health

Response:

{
  "status": "ok"
}

Chat

POST /chat
Content-Type: application/json

Request Body:

{
  "message": "What are the penalties for drunk driving?",
  "session_id": "unique-session-id"
}

Response:

{
  "response": "Under the Motor Vehicles Act, 2019, drunk driving penalties include...",
  "sources": ["Motor Vehicles (Amendment) Act, 2019"]
}

🐳 Docker Deployment

Build and Run Locally

docker build -t lexibot-api .
docker run -p 7860:7860 --env-file .env lexibot-api

Deploy to Hugging Face Spaces

  1. Create a new Space with Docker SDK
  2. Push this repository to the Space
  3. Add secrets in Settings:
    • GOOGLE_API_KEY
    • PINECONE_API_KEY

πŸ—οΈ Project Structure

lexibot-api/
β”œβ”€β”€ app.py                 # FastAPI application
β”œβ”€β”€ ingest_optimized.py    # Data ingestion with Context Injection
β”œβ”€β”€ requirements.txt       # Python dependencies
β”œβ”€β”€ Dockerfile             # HuggingFace Spaces optimized
β”œβ”€β”€ .env.example           # Environment template
β”œβ”€β”€ RawData/               # Raw legal documents (.txt)
└── README.md              # This file

πŸ”§ Technical Stack

Component Technology
API Framework FastAPI
Vector Database Pinecone (Serverless)
LLM Google Gemini 2.0 Flash
Embeddings Google embedding-001
Orchestration LangChain
Hosting Hugging Face Spaces

⚠️ Legal Disclaimer

This bot provides informational content only and is NOT a substitute for professional legal advice.

Always consult a qualified lawyer for specific legal matters. Laws are subject to change; verify current status before relying on any information.


πŸ“„ License

MIT License - See LICENSE for details.


🀝 Contributing

Contributions are welcome! Please open an issue or submit a pull request.


Built with ❀️ for Indian Legal Accessibility