""" Test Enhanced Legal RAG Pipeline with Gemini 2.5 Pro Property fraud case involving land grabbing and document forgery """ from rag_service import evaluateCase import time propertyCase = """ Case involves Mr. Rakesh Malhotra who orchestrated an elaborate property fraud scheme in Delhi's Vasant Vihar area. The accused: 1) FORGED DOCUMENTS: Created fake sale deeds backdated to 2016 claiming purchase of Plot No. 247 (5000 sq ft) from deceased owner Mr. K.L. Verma who died in 2015 2) BRIBERY: Paid Rs 2 lakh to Sub-Registrar office clerk Suresh Yadav to insert forged documents into official registry records (confirmed by Anti-Corruption Bureau) 3) ILLEGAL CONSTRUCTION: Started construction of 4-story commercial building without proper permissions, violating building bylaws 4) FRAUDULENT SALE: Sold property to multiple buyers - Mr. Anil Kapoor (Rs 1.2 crore), Mrs. Sunita Reddy (Rs 95 lakhs), and Sharma Builders Ltd (Rs 1.5 crore) using the same forged documents 5) INTIMIDATION: Threatened original heir Ms. Kavita Verma (daughter of deceased owner) with violence when she objected, backed by hired goons EVIDENCE COLLECTED: - Forensic report confirmed signatures on deeds were forged (did not match K.L. Verma's authentic signatures) - Bank statements showing Rs 2 lakh payment to Suresh Yadav - Witness testimony from 5 neighbors confirming Rakesh had no connection to property before 2020 - Municipal records proving K.L. Verma's family owned land since 1998 - Video evidence of intimidation captured by Ms. Kavita Verma's security cameras - Three buyer complaints with proof of payment totaling Rs 3.65 crore - Property documents from legal heir Ms. Kavita Verma proving inheritance rights All three buyers lost their investments. Construction was halted by municipal authorities. """ print("=" * 100) print("TESTING ENHANCED LEGAL RAG PIPELINE WITH GEMINI 2.5 PRO") print("=" * 100) print("\nšŸ“‹ PROPERTY FRAUD CASE:") print(propertyCase) print("\n" + "=" * 100) print("šŸ”„ PROCESSING...") print(" - Running LegalBERT prediction (parallel)") print(" - Extracting keywords with Gemini 1.5 Flash (parallel)") print(" - Performing dual retrieval (semantic + keyword-based)") print(" - Generating judgment with Gemini 2.5 Pro") print("=" * 100) startTime = time.time() result = evaluateCase(propertyCase) endTime = time.time() print("\nāœ… PREDICTION RESULTS:") print(f" Verdict: {result['verdict'].upper()}") print(f" Confidence: {result['confidence'] * 100:.2f}%") print("\nšŸ”‘ EXTRACTED LEGAL KEYWORDS:") if result['extractedKeywords']: for i, keyword in enumerate(result['extractedKeywords'], 1): print(f" {i}. {keyword}") else: print(" No keywords extracted") print("\nšŸ“š RETRIEVED CHUNKS (Dual Retrieval):") totalChunks = 0 for category, chunks in result['retrievedChunks'].items(): chunkCount = len(chunks) totalChunks += chunkCount print(f" {category}: {chunkCount} chunks") print(f" TOTAL: {totalChunks} chunks retrieved") print("\n" + "=" * 100) print("āš–ļø FINAL JUDGMENT (Generated by Gemini 2.5 Pro):") print("=" * 100) print(result['explanation']) print("=" * 100) print("\nšŸ“Š PERFORMANCE METRICS:") print(f" Total processing time: {endTime - startTime:.2f} seconds") print(f" Judgment word count: {len(result['explanation'].split())} words") print(f" Judgment character count: {len(result['explanation']):,} characters") print(f" Keywords extracted: {len(result['extractedKeywords'])}") print(f" Model used: Gemini 2.5 Pro") print("\n✨ Enhanced features demonstrated:") print(" āœ“ Parallel execution (LegalBERT + Keyword Extraction)") print(" āœ“ Dual retrieval (Semantic + Keyword-based)") print(" āœ“ Gemini 2.5 Pro for superior reasoning") print(" āœ“ Similar case precedent references") print(" āœ“ Concise 400-600 word judgment")