KadiRail AI Agent Specification
Specifies a Thai legal case navigation tool that reduces understanding time by 96% using OCR, simulation, and bias detection.
What this file does
Specifies a Thai legal case navigation tool that reduces understanding time by 96% using OCR, simulation, and bias detection.
When to use it
- Building a legal AI assistant for Thai labor cases
- Participating in a hackathon with Thai court data
- Creating a document scanner with LINE OCR integration
- Designing a case outcome simulator with Mermaid.js maps
Assumes this stack
KadiRail AI Agent Specification
Overview
KadiRail AI - Legal Case Navigation Tool for Thailand
Hackathon: Responsible AI Hackathon 2026 (ศาลยุติธรรม × ETDA × AWS)
Goal: Reduce case understanding time from 120 min → 5 min (-96%)
Agent Capabilities
Core Features
- Document Scanner - LINE OCR API integration for Thai legal documents
- Case Map Engine - Transform legal procedures into interactive Mermaid.js train station maps
- WhatIf Simulator - Predict case outcomes based on different choices
- Bias Engine - Detect and correct bias in legal text
Challenge-Specific Modules
| Challenge | Module | Description |
|---|---|---|
| 2.1 | Document Validator | Translate legal language → self-file capability |
| 2.2 | Document Validator | Check document completeness |
| 3 | PII Masking | Privacy protection for case data |
| 3 | Case Law Search | Search Thai court precedents |
| 4 | Document Summarizer | Summarize documents + draft reports |
Technical Stack
- Frontend: Streamlit (Python)
- NLP: pythainlp, transformers
- Visualization: Mermaid.js, graphviz
- Data: Pandas, mock case generator (10,000+ cases)
Supported Case Types (MVP)
| Type | Thai | Description |
|---|---|---|
| Wage Theft | โกงค่าจ้าง | Employer doesn't pay or pays incomplete |
| Unfair Termination | ถูกเลิกจ้าง | Unjust dismissal |
| Bonus Dispute | ไม่จ่ายโบนัส | Employer refuses to pay bonus |
File Structure
kadirail/
├── app/main.py # Streamlit 9 pages
├── core/
│ ├── scanner.py # LINE OCR
│ ├── map_engine.py # Mermaid rendering
│ ├── simulator.py # WhatIf simulation
│ ├── bias_engine.py # Bias detection
│ └── document_validator.py # Challenge 2.2
├── utils/
│ ├── thai_nlp.py # Thai NLP utilities
│ ├── pii_masking.py # Challenge 3
│ ├── case_law_search.py # Challenge 3
│ ├── document_summarizer.py # Challenge 4
│ └── mermaid_gen.py
├── data/
│ └── mock_generator.py # 10,000+ mock cases
└── requirements.txt
Running the Agent
cd kadirail
uv venv && source .venv/bin/activate
pip install -r requirements.txt
streamlit run app/main.py
API Integration Points
LINE OCR API
- Endpoint:
https://api.line.me/v2/bot/message/reply - Used in:
core/scanner.py
(Future) Azure OpenAI
- For: Document summarization, legal translation
- Config:
utils/azure_config.py
Thai Legal Domain Knowledge
Key Concepts
- ค่าจ้าง (Wage): Payment for work
- ค่าชดเชย (Compensation): Severance pay
- ค่าล่วงเวลา (Overtime): OT pay
- การไล่ออก (Dismissal): Termination
- ศาลแรงงาน (Labor Court): Labor disputes
Court Process Flow (Labor Case)
- ยื่นฟ้อง (File Complaint)
- ขานคำให้การ (Answer)
- ไต่สวน (Hearing)
- พิพากษา (Judgment)
- อุทธรณ์/ฎีกา (Appeal)
Ethical Guidelines
- Privacy First - Always mask PII before processing
- Bias Detection - Check for gender, socioeconomic bias
- Transparency - Show confidence scores for predictions
- Human Oversight - Recommendations, not legal advice
Contact
For Responsible AI Hackathon 2026
Team: KadiRail AI
What's inside
7 capability sections, 5 core modules, 3 case types, 1 file structure tree, 1 run command
Change this for your project
- Replace
kadirail/with your own project directory name - Replace
https://api.line.me/v2/bot/message/replywith your LINE OCR endpoint - Replace
Dr-SoloDev/kadirail-aiwith your repository name
Where it goes
Save as AGENTS.md in your repository root. Read by Codex, Cursor and other agents that follow the AGENTS.md convention.
Worth borrowing
- Using Mermaid.js to visualize legal procedures as interactive train station maps
- Combining a bias engine with PII masking for ethical legal document processing
- Structuring a hackathon project around challenge-specific modules
Related Documents
Browser-only development
Guides AI assistants on an Electron + React + TypeScript desktop app for browsing and organizing AI-generated images locally.
Claude Agents — Reference & Recommendations
Catalogues 40+ Claude agents and marketing skills for building a cat adoption charity landing page, with a ready-to-paste prompt and backend API reference.
Golden DKG Prototype -- Master Plan
Defines an 8-phase implementation plan for a Rust prototype of the Golden non-interactive DKG protocol using BLS12-381 and tokio.
Swarms Examples Index
Lists 60+ example scripts for building single and multi-agent systems with the Swarms framework, organized by category and use case.