Back to .md Directory

KadiRail AI Agent Specification

Specifies a Thai legal case navigation tool that reduces understanding time by 96% using OCR, simulation, and bias detection.

May 2, 2026
0 downloads
1 views
ai agent openai
View source

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

StreamlitPythonpythainlptransformersMermaid.jsgraphviz

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

  1. Document Scanner - LINE OCR API integration for Thai legal documents
  2. Case Map Engine - Transform legal procedures into interactive Mermaid.js train station maps
  3. WhatIf Simulator - Predict case outcomes based on different choices
  4. Bias Engine - Detect and correct bias in legal text

Challenge-Specific Modules

ChallengeModuleDescription
2.1Document ValidatorTranslate legal language → self-file capability
2.2Document ValidatorCheck document completeness
3PII MaskingPrivacy protection for case data
3Case Law SearchSearch Thai court precedents
4Document SummarizerSummarize 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)

TypeThaiDescription
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)

  1. ยื่นฟ้อง (File Complaint)
  2. ขานคำให้การ (Answer)
  3. ไต่สวน (Hearing)
  4. พิพากษา (Judgment)
  5. อุทธรณ์/ฎีกา (Appeal)

Ethical Guidelines

  1. Privacy First - Always mask PII before processing
  2. Bias Detection - Check for gender, socioeconomic bias
  3. Transparency - Show confidence scores for predictions
  4. 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/reply with your LINE OCR endpoint
  • Replace Dr-SoloDev/kadirail-ai with 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