CoolFace
Apppublic

BHaritha/msme-openenv

sourceHugging Faceupdated 6mo agoView on Hugging Face
1likes
App README

MSME Payment Dispute — OpenEnv Environment

An AI agent training environment for handling MSME (Micro, Small and Medium Enterprise) payment disputes in India. Built for the OpenEnv Hackathon × Scaler Round 1.

Problem Context

Millions of small businesses in India face delayed payments from buyers. Most MSME owners lack access to affordable legal drafting support. This environment trains AI agents to classify disputes, extract facts, and draft formal demand letters — practical tasks with real-world impact.

Why this matters: This is not a toy problem. Delayed payments are a systemic issue in India, and automating the legal drafting process (MSMED Act 2006 demands) directly solves a major bottleneck for small businesses. Environment Design: The environment features a unique Sequential Chaining Mode, where an agent's errors in early tasks (e.g., misclassifying a dispute) directly degrade the context provided in later tasks (e.g., drafting the letter). It also supports Multi-turn Revision Loops via an LLM+Rule based judge that provides actionable feedback on missing legal clauses.

Tasks

TaskDifficultyDescriptionScoring
1EasyClassify dispute type from emailExact match (0.999), adjacent class (0.40), wrong (0.001)
2MediumExtract structured facts from formal noticeWeighted field accuracy across 5 fields, clamped to (0, 1)
3HardDraft a formal demand letterRule-based + LLM-as-judge, clamped to (0, 1)

Action & Observation Spaces

Task 1

  • —Observation: {email: {subject, body}, valid_labels: [...]}
  • —Action: {label: "delayed_payment" | "partial_payment" | "payment_denial"}

Task 2

  • —Observation: {email: {subject, body}}
  • —Action: {claimant: str, opponent: str, amount: int, due_date: str, days_overdue: int}

Task 3

  • —Observation: {context: {claimant, opponent, amount, invoice_no, due_date, days_overdue, dispute_type, evidence}}
  • —Action: {letter: str} (minimum 150 words)

API Endpoints

MethodEndpointDescription
GET/Health check
GET/healthHealth check
GET/tasksList all tasks
POST/resetStart new episode {task_id: 1-3, seed: int?}
POST/stepSubmit action {action: {...}}
GET/stateCurrent environment state

Setup

bash
pip install -r requirements.txt
uvicorn env.server:app --host 0.0.0.0 --port 7860

# In another terminal:
python inference.py

Baseline Scores

TaskModelScoreAgent Steps
1. Classifygpt-4o-mini0.4001
2. Extract Factsgpt-4o-mini0.9501
3. Draft Lettergpt-4o-mini0.3753 (Multi-turn)

Sample Inference Output

text
[START] task=draft_demand_letter env=msme-dispute model=gpt-4o-mini
[STEP] step=1 action={"letter": "..."} reward=0.25 done=false error=null
[STEP] step=2 action={"letter": "..."} reward=0.38 done=true error=null
[END] success=true steps=2 score=0.38 rewards=0.25,0.38

Environment Variables

VariableDescription
API_BASE_URLLLM API endpoint
MODEL_NAMEModel identifier
HF_TOKENAPI key
ENV_URLEnvironment server URL for inference.py

Reward Function

All task rewards are clamped strictly to (0, 1) for validator compatibility.
Task 1: exact_match=0.999, adjacent_class=0.40, wrong/invalid=0.001
Task 2: weighted field accuracy (claimant/opponent/amount/days_overdue/due_date), clamped to (0,1)
Task 3: 0.5*(completeness+legal+tone+length) + 0.5*llm_judge, clamped to (0,1)