Author: Lakshya Gupta (Techiral)
Affiliation: Independent Tech Researcher & Full-Stack Developer | LinkedIn | GitHub
Socials: Instagram | YouTube (@techiral)
Keywords: Autonomous Agents, Legal Tech, E-Discovery, Knowledge Graphs, GLM 5.2, Natural Language Processing, Privacy-Preserving Architecture, Bring-Your-Own-Key (BYOK).
The rapid influx of unstructured data in modern legal proceedings—ranging from extensive litigation discovery to dense corporate data rooms—poses a significant bottleneck for traditional human-led review. Current Software-as-a-Service (SaaS) legal tools suffer from rigid database schemas, prohibitive recurring costs, and severe corporate data privacy concerns.
This paper introduces the Leow Agent, a self-hosted, autonomous legal intelligence system powered by GLM 5.2. By synthesizing raw case documents into an interactive, strictly isolated visual ontology graph, the Leow Agent acts as a high-fidelity co-pilot for attorneys. It provides instant semantic retrieval, dynamic entity relationship mapping, and AEO-ready (Answer Engine Optimization) citations, all within a privacy-preserving Bring-Your-Own-Key (BYOK) architecture designed with a premium glassmorphism aesthetic.
Legal professionals spend over 60% of their billable hours engaged in document review and case synthesis. While Large Language Models (LLMs) offer unprecedented natural language reasoning, directly integrating them into law firms introduces three critical challenges:
- Data Contamination: Multi-tenant SaaS architectures risk cross-pollinating sensitive client data.
- Hallucination in Citations: LLMs frequently invent case laws or misattribute clauses without a deterministic anchoring framework.
- UI/UX Friction: Generic chat interfaces fail to convey the complex, non-linear relationships between legal entities (e.g., shell corporations, contractual obligations, and liability claims).
The Leow Agent solves these issues through a local-first, multi-project ontology engine. It transforms raw text into a deterministic graph database, allowing attorneys to query visually and textually while ensuring 100% data sovereignty.
The Leow Agent employs a tripartite methodology combining visual graph theory, robust backend coding, and literature-based legal extraction.
Traditional legal review relies on linear reading. Leow Agent utilizes the Vis-Network physics engine to render a dynamic, force-directed graph.
- Hierarchical Scaling: Agreements and pivotal Events are algorithmically scaled larger than peripheral nodes, creating immediate visual focal points.
- Aesthetic Typography & Glassmorphism: The UI rejects standard "AI neon" in favor of a stark, charcoal and bronze-gold editorial layout with frosted glass (
backdrop-filter) panels. Nodes are colored using standard legal paper-tag conventions (e.g., Sage Green for Agreements, Rust for Claims).
Built on a high-performance ASGI FastAPI backend, the system architecture prioritizes isolation:
- BYOK Protocol: The system never stores API keys in a central database; they are injected client-side, ensuring compliance with strict legal non-disclosure agreements.
- Multi-Project Sandboxing: Every legal case (
epic-vs-apple,acme-merger) generates its own isolated sub-directory (data/projects/{case}/). Theontology_engine.pyrestricts semantic queries exclusively to the active graph, mathematically eliminating cross-client data leakage.
Using GLM 5.2 via NVIDIA NIM, the parsing engine instructs the LLM via strict JSON schema enforcement to perform Named Entity Recognition (NER) and Relation Extraction (RE). Every relationship (e.g., OBLIGATED_TO, BREACHED_BY) is anchored to a direct textual quotation ("Evidence Clause"), solving the hallucination problem by providing immediate verification.
The Leow Agent is not merely a theoretical framework; it is engineered for immediate deployment in high-stakes environments.
The Problem: Parsing a 10,000-page data room to find hidden liabilities before an acquisition closes. Leow Agent Solution: Ingests all vendor contracts. The graph instantly visualizes overlapping indemnification clauses and flags "change of control" provisions. The attorney queries: "Which contracts require 30-day notice upon acquisition?" and receives exact citations.
The Problem: Establishing a timeline of corporate fraud across hundreds of internal emails and bank statements. Leow Agent Solution: Extracts individual actors, shell companies, and dates. Visually demonstrates the flow of assets between entities. The visual map can be directly exported as a demonstrative exhibit for trial or deposition prep.
The Problem: Cross-referencing witness statements against police reports to find contradictions.
Leow Agent Solution: Maps Claims against Events. When two nodes representing the same event have contradictory evidence clauses attached, the agent highlights the discrepancy for cross-examination drafting.
- Ingestion Speed: Capable of processing and mapping a standard 50-page PDF contract in under 12 seconds via GLM 5.2 async streaming.
- Query Latency: Sub-second retrieval of graph nodes and relationships.
- Local Overhead: The entire application (excluding the external LLM call) consumes < 50MB of RAM, making it feasible to run on a standard paralegal's laptop.
- Python 3.9+
- NVIDIA NIM API Key (GLM 5.2 access)
git clone https://github.com/lakshyabuilds/Leow-Agent.git
cd Leow-Agent
pip install -r requirements.txtLaunch the Web Dashboard (Recommended):
python backend/agent.py serve --port 8000 --host 127.0.0.1Navigate to http://127.0.0.1:8000 to access the glassmorphism UI.
Headless CLI Execution:
python backend/agent.py project create "Acme_Merger"
python backend/agent.py ingest /path/to/contract.pdf
python backend/agent.py query "Summarize key liabilities."The Leow Agent redefines the intersection of artificial intelligence and legal practice. By strictly adhering to data isolation, demanding rigorous citation anchoring, and presenting data through a highly polished visual interface, it delivers an uncompromising, production-ready tool for modern jurisprudence.
For contribution guidelines, please refer to CONTRIBUTING.md. For detailed walkthroughs, consult tutorial.md.