Learn 🧠 All Concepts (20) 🤖 What is an LLM? 📚 RAG Explained ⚡ AI Agents 💻 Run AI Locally 🇮🇳 AI in India 📖 Learn Tracks 🔧 DevOps Track ⚙️ AI Ops Track 🗺️ AI Engineer Roadmap
Tools 🔧 AI Tools Directory 🔓 Open Source AI ⭐ Top GitHub Repos ✦ Claude Skill Repos 🚀 Ready-to-Deploy Projects
Build 🏗️ Build Hub 🎯 Master Prompts 🧩 RAG Agents 🚀 App Megaprompts
Workflows ⚡ All Workflows (22) 🎥 Text to Video 🎞️ Image to Video 🔊 Text to Speech ♻️ Automation
Resources 🧪 Colab Notebooks ⚙️ n8n Workflows 📈 Algo Trading 💰 Passive Income
🗂️ Browse All Topics About AItheGuru
← RAG agents
⚖️ RAG Agent · Legal

Contract Review and Risk Flagging Agent

Upload any contract and get instant risk analysis: unusual clauses, missing protections, liability caps.

Legal Intermediate RenderRailway

Quick info

CategoryLegal
DifficultyIntermediate
Deploy onRender

Get the code

Includes install commands in comments

What it does

Risk level classification (High/Medium/Low)
Missing clause detection
Indian law compliance notes
PDF and text input support
JSON structured output

Stack

PythonAnthropic ClaudePyPDF2FastAPI

Deploy on

✓ Render✓ Railway✓ FastAPI

Full source code

Install commands are in the top comments. Copy and run.

from anthropic import Anthropic import PyPDF2, io, json, re from fastapi import FastAPI, UploadFile app = FastAPI() client = Anthropic() PROMPT = ('Analyse this contract. Return JSON with:\n' '- risk_summary: list of {level,issue,explanation}\n' '- missing_protections: absent clauses\n' '- unusual_clauses: non-standard terms\n' '- key_numbers: {payment_terms,notice_period,liability_cap}\n' '- india_law_notes: jurisdiction,arbitration,GST\n\nContract: {text}') def extract_pdf(b): return '\n'.join(p.extract_text() or '' for p in PyPDF2.PdfReader(io.BytesIO(b)).pages) @app.post('/review') async def review(file: UploadFile): content = await file.read() text = extract_pdf(content) if file.filename.endswith('.pdf') else content.decode() resp = client.messages.create(model='claude-sonnet-4-6', max_tokens=3000, messages=[{'role':'user','content':PROMPT.format(text=text[:15000])}]) raw = resp.content[0].text m = re.search(r'\{.*\}', raw, re.DOTALL) return {'analysis': json.loads(m.group()) if m else {'raw':raw}}