--- title: Precision Legal Intelligence AdeemAlotaibi emoji: ⚖️ colorFrom: gray colorTo: red sdk: docker pinned: false --- ## ⚖️ LEX - Legal Expert Agentic System LEX is an AI-powered legal analysis system designed to bridge the "Access to Justice Gap". It helps users navigate intimidating legal documents and proceedings by providing immediate clarity through a sophisticated multi-agent workflow. +4 ## 🏗️ System Architecture: Optimized Parallel Pipeline LEX utilizes an AISA (Agentic Interactive System Architecture) workflow that runs 6 specialized agents across 4 logical phases. To ensure a professional and responsive user experience, the system employs Python's ThreadPoolExecutor to reduce processing time from ~20 seconds to just 10–12 seconds. ## 🚀 Setup & Installation - **Prerequisites** Python 3.9+ OpenAI API Key (Optimized for gpt-4o-mini) Required Libraries: pydantic, faiss-cpu, sqlite3, concurrent.futures - **Installation** **Clone the repository:** Bash: git clone https://huggingface.co/spaces/AISA-Framework/LEX-AdeemAlotaibi cd LEX-AdeemAlotaibi **Install dependencies:** Bash: pip install -r requirements.txt **Configure Environment:** Set AISA_DETERMINISTIC=1 for reproducible test results ## 🛠️ Usage LEX is designed to be intuitive for users facing legal stress.The system processes messy, real-world text and converts it into a structured legal analysis. ### 1. Inputting a Case Users can input their legal situation in the text area (up to 8,000 characters).This can include: * **Narratives:** Describing a dispute or situation in plain language. * **Document Text:** Pasting the content of a termination notice, contract clause, or court judgment. * **Multilingual Input:** Input can be in Arabic or English; the system is robust enough to categorize and analyze both. ### 2. The Analysis Process Once submitted, the system triggers the **AISA Workflow**: * **Instant Identification:** The system immediately identifies the "Intent" (e.g., is this a notice, a contract, or a judgment?). * **Plain Language Explanation:** It translates complex legal jargon into an easy-to-understand summary using the RAG tool. * **Automated Quality Check:** The Critic Agent reviews the analysis. If it misses a key legal point (like a specific 90-day notice rule), it automatically re-runs the logic to ensure accuracy. ### 3. Understanding the Output The user receives an **Analysis Report** containing: * **Summary:** A clear explanation of "what is happening." * **Risk Assessment:** A visual indicator of the risk level (Low, Medium, or High). * **Action Plan:** Targeted next steps (e.g., "mentions notice period violation" or "first action step urgency=high"). * **Key Points:** Critical legal facts detected by the Reasoning Agent. ### 4. Example Scenarios | Scenario | Expected Output | | :--- | :--- | | **Landlord Notice** | Intent: `Notice`, Risk: `Medium`, Action: Notice period validation. | | **Salary Reduction** | Intent: `Contract`, Risk: `Medium`, Action: Wage violation check. | | **Court Judgment** | Intent: `Judgment`, Risk: `High`, Action: Urgent payment/appeal steps. | Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference