Spaces:
Running
Running
Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
# Jan-Contract: Your Digital Workforce Assistant 🇮🇳
|
| 3 |
+
|
| 4 |
+
Jan-Contract is a multi-functional AI-powered platform designed to empower India's informal workforce. It provides accessible tools to create simple digital agreements, discover relevant government schemes, and understand complex legal documents, all through a simple web interface.
|
| 5 |
+
|
| 6 |
+
## 🚀 Key Features
|
| 7 |
+
|
| 8 |
+
This application is a unified suite of three powerful agents:
|
| 9 |
+
|
| 10 |
+
1. **📝 Contract Generator**
|
| 11 |
+
* Creates simple, clear digital agreements from plain-text descriptions (e.g., "Paint my house for ₹5000").
|
| 12 |
+
* Provides contextually relevant legal trivia based on the agreement's content.
|
| 13 |
+
* Generates a professionally formatted, downloadable **PDF** of the final agreement.
|
| 14 |
+
* Captures undeniable proof of consent with a **video recording** feature.
|
| 15 |
+
|
| 16 |
+
2. **🏦 Government Scheme Finder**
|
| 17 |
+
* Takes a user's profile (e.g., "a woman farmer in Maharashtra") and finds relevant government schemes.
|
| 18 |
+
* Uses live web search to provide up-to-date information.
|
| 19 |
+
* Returns a structured list of schemes with descriptions and direct links to official government websites.
|
| 20 |
+
|
| 21 |
+
3. **📜 Document Demystifier & Chat**
|
| 22 |
+
* **Analyze:** Upload any legal PDF document to receive a concise, easy-to-understand summary and a breakdown of key legal terms.
|
| 23 |
+
* **Chat:** After the analysis, engage in an interactive Q&A session with the document to clarify specific doubts.
|
| 24 |
+
|
| 25 |
+
## 🛠️ Tech Stack
|
| 26 |
+
|
| 27 |
+
* **Frontend:** Streamlit
|
| 28 |
+
* **Backend API:** FastAPI
|
| 29 |
+
* **AI Orchestration:** LangChain & LangGraph
|
| 30 |
+
* **LLMs:** Google Gemini, Llama 3 (via Groq)
|
| 31 |
+
* **Embeddings:** `FastEmbed` (BAAI/bge-base-en-v1.5)
|
| 32 |
+
* **Vector Store:** FAISS (for in-memory semantic search)
|
| 33 |
+
* **Tools & Libraries:**
|
| 34 |
+
* Tavily AI (for live web search)
|
| 35 |
+
* `fpdf2` (for PDF generation)
|
| 36 |
+
* `streamlit-webrtc` (for video recording)
|
| 37 |
+
* PyMuPDF (for reading PDFs)
|
| 38 |
+
|
| 39 |
+
## 📂 Project Structure
|
| 40 |
+
|
| 41 |
+
```
|
| 42 |
+
D:\jan-contract
|
| 43 |
+
|
|
| 44 |
+
+-- agents
|
| 45 |
+
| +-- legal_agent.py
|
| 46 |
+
| +-- scheme_chatbot.py
|
| 47 |
+
| +-- demystifier_agent.py
|
| 48 |
+
|
|
| 49 |
+
+-- components
|
| 50 |
+
| +-- video_recorder.py
|
| 51 |
+
|
|
| 52 |
+
+-- core_utils
|
| 53 |
+
| +-- core_model_loaders.py
|
| 54 |
+
|
|
| 55 |
+
+-- tools
|
| 56 |
+
| +-- legal_tools.py
|
| 57 |
+
| +-- scheme_tools.py
|
| 58 |
+
|
|
| 59 |
+
+-- utils
|
| 60 |
+
| +-- model_loaders.py
|
| 61 |
+
| +-- pdf_generator.py
|
| 62 |
+
|
|
| 63 |
+
+-- .env # Your secret API keys
|
| 64 |
+
+-- requirements.txt # Project dependencies
|
| 65 |
+
+-- main_streamlit.py # The main frontend application
|
| 66 |
+
+-- main_fastapi.py # The backend API server
|
| 67 |
+
+-- README.md # This file
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
## ⚙️ Setup and Installation
|
| 71 |
+
|
| 72 |
+
Follow these steps to set up and run the project on your local machine.
|
| 73 |
+
|
| 74 |
+
### 1. Clone the Repository
|
| 75 |
+
|
| 76 |
+
```bash
|
| 77 |
+
git clone <your-repository-url>
|
| 78 |
+
cd jan-contract
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
### 2. Create and Activate a Python Virtual Environment
|
| 82 |
+
|
| 83 |
+
This keeps your project dependencies isolated.
|
| 84 |
+
|
| 85 |
+
```bash
|
| 86 |
+
# Create the virtual environment
|
| 87 |
+
python -m venv venv
|
| 88 |
+
|
| 89 |
+
# Activate it (on Windows)
|
| 90 |
+
venv\Scripts\activate
|
| 91 |
+
|
| 92 |
+
# On MacOS/Linux, you would use:
|
| 93 |
+
# source venv/bin/activate
|
| 94 |
+
```
|
| 95 |
+
|
| 96 |
+
### 3. Install Dependencies
|
| 97 |
+
|
| 98 |
+
Install all the required Python libraries from the `requirements.txt` file.
|
| 99 |
+
|
| 100 |
+
```bash
|
| 101 |
+
pip install -r requirements.txt
|
| 102 |
+
```
|
| 103 |
+
|
| 104 |
+
### 4. Set Up Your API Keys
|
| 105 |
+
|
| 106 |
+
You will need API keys from Google, Tavily, and Groq.
|
| 107 |
+
|
| 108 |
+
1. Create a file named `.env` in the root of the project directory.
|
| 109 |
+
2. Copy and paste the following content into the `.env` file, replacing the placeholders with your actual keys.
|
| 110 |
+
|
| 111 |
+
```env
|
| 112 |
+
# D:\jan-contract\.env
|
| 113 |
+
|
| 114 |
+
GOOGLE_API_KEY="YOUR_GOOGLE_AI_STUDIO_API_KEY"
|
| 115 |
+
TAVILY_API_KEY="YOUR_TAVILY_AI_API_KEY"
|
| 116 |
+
GROQ_API_KEY="YOUR_GROQ_API_KEY"
|
| 117 |
+
```
|
| 118 |
+
**Important:** The `.env` file contains secrets and should **never** be committed to GitHub. Ensure `.env` is listed in your `.gitignore` file.
|
| 119 |
+
|
| 120 |
+
## ▶️ How to Run the Application
|
| 121 |
+
|
| 122 |
+
You can run the Streamlit frontend and the FastAPI backend independently.
|
| 123 |
+
|
| 124 |
+
### 1. Running the Streamlit Web App (Frontend)
|
| 125 |
+
|
| 126 |
+
This is the main user interface for the project.
|
| 127 |
+
|
| 128 |
+
```bash
|
| 129 |
+
streamlit run main_streamlit.py```
|
| 130 |
+
|
| 131 |
+
Your browser will automatically open a new tab with the application running.
|
| 132 |
+
|
| 133 |
+
### 2. Running the FastAPI Server (Backend API)
|
| 134 |
+
|
| 135 |
+
This exposes the project's logic as a professional API.
|
| 136 |
+
|
| 137 |
+
```bash
|
| 138 |
+
uvicorn main_fastapi:app --reload
|
| 139 |
+
```
|
| 140 |
+
* The API server will be running at `http://127.0.0.1:8000`.
|
| 141 |
+
* You can access the interactive API documentation (powered by Swagger UI) at **`http://127.0.0.1:8000/docs`**.
|