Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions uc-0a/agents.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
# agents.md — UC-0A Complaint Classifier
# INSTRUCTIONS: Generate a draft using your RICE prompt, then manually refine this file.
# Delete these comments before committing.

role: >
[FILL IN: Who is this agent? What is its operational boundary?]
You are a Civic Tech Complaint Classifier for a municipal government. Your role is to process citizen complaints and translate them into structured data for department routing. You operate strictly within the provided taxonomy and priority rules, ensuring every classification is backed by evidence from the complaint description.

intent: >
[FILL IN: What does a correct output look like — make it verifiable]
To produce a verifiable JSON-like structured output for each complaint containing:
1. `category`: One of the 10 allowed municipal categories.
2. `priority`: A severity-based urgency level.
3. `reason`: A single-sentence justification citing specific words.
4. `flag`: An ambiguity marker for human review.

context: >
[FILL IN: What information is the agent allowed to use? State exclusions explicitly.]
You are provided with a CSV row containing a citizen's description of an issue. You must only use information present in the description. You are prohibited from inventing new categories or assuming details not explicitly stated.

enforcement:
- "[FILL IN: Specific testable rule 1 — e.g. Category must be exactly one of: Pothole, Flooding, ...]"
- "[FILL IN: Specific testable rule 2 — e.g. Priority must be Urgent if description contains: injury, child, school, ...]"
- "[FILL IN: Specific testable rule 3 — e.g. Every output row must include a reason field citing specific words from the description]"
- "[FILL IN: Refusal condition — e.g. If category cannot be determined from description alone, output category: Other and flag: NEEDS_REVIEW]"
- "Category must be exactly one of: Pothole, Flooding, Streetlight, Waste, Noise, Road Damage, Heritage Damage, Heat Hazard, Drain Blockage, Other."
- "Priority must be set to 'Urgent' if the description contains any of these keywords: injury, child, school, hospital, ambulance, fire, hazard, fell, collapse."
- "Priority defaults to 'Standard' or 'Low' based on the perceived impact if no 'Urgent' keywords are present."
- "The 'reason' field must be exactly one sentence and must cite specific words from the citizen's description."
- "If the complaint is genuinely ambiguous or could fit multiple categories equally, set category to 'Other' and set the 'flag' field to 'NEEDS_REVIEW'."
- "Strings for category and priority must match the allowed values exactly, including casing."

88 changes: 78 additions & 10 deletions uc-0a/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,91 @@

def classify_complaint(row: dict) -> dict:
"""
Classify a single complaint row.
Returns: dict with keys: complaint_id, category, priority, reason, flag

TODO: Build this using your AI tool guided by your agents.md and skills.md.
Your RICE enforcement rules must be reflected in this function's behaviour.
Classify a single complaint row based on RICE rules.
"""
raise NotImplementedError("Build this using your AI tool + RICE prompt")
description = row.get('description', '').lower()
complaint_id = row.get('complaint_id', 'UNKNOWN')

# 1. Category Mapping
category = "Other"
flag = ""

if "pothole" in description:
category = "Pothole"
elif "flood" in description or "rain" in description and "water" in description:
category = "Flooding"
elif "streetlight" in description or "light" in description:
category = "Streetlight"
elif "garbage" in description or "waste" in description or "smell" in description:
category = "Waste"
elif "noise" in description or "music" in description:
category = "Noise"
elif "road" in description and "surface" in description or "cracked" in description:
category = "Road Damage"
elif "heritage" in description:
category = "Heritage Damage"
elif "heat" in description or "hot" in description:
category = "Heat Hazard"
elif "drain" in description and "block" in description:
category = "Drain Blockage"

# Ambiguity check
if category == "Other" or not description:
flag = "NEEDS_REVIEW"

# 2. Priority Logic
urgent_keywords = ["injury", "child", "school", "hospital", "ambulance", "fire", "hazard", "fell", "collapse"]
priority = "Standard"
triggered_keyword = ""
for kw in urgent_keywords:
if kw in description:
priority = "Urgent"
triggered_keyword = kw
break

if priority != "Urgent" and "low" in description:
priority = "Low"

# 3. Reason Generation
if priority == "Urgent":
reason = f"Classified as Urgent because the description mentions the safety-critical term '{triggered_keyword}'."
else:
reason = f"Classified as {category} based on the mention of related terms in the description."

return {
"complaint_id": complaint_id,
"category": category,
"priority": priority,
"reason": reason,
"flag": flag
}


def batch_classify(input_path: str, output_path: str):
"""
Read input CSV, classify each row, write results CSV.

TODO: Build this using your AI tool.
Must: flag nulls, not crash on bad rows, produce output even if some rows fail.
"""
raise NotImplementedError("Build this using your AI tool + RICE prompt")
results = []
try:
with open(input_path, mode='r', encoding='utf-8') as f:
reader = csv.DictReader(f)
for row in reader:
results.append(classify_complaint(row))

if not results:
print("No data found in input file.")
return

keys = results[0].keys()
with open(output_path, mode='w', newline='', encoding='utf-8') as f:
writer = csv.DictWriter(f, fieldnames=keys)
writer.writeheader()
writer.writerows(results)

except FileNotFoundError:
print(f"Error: Input file {input_path} not found.")
except Exception as e:
print(f"An unexpected error occurred: {e}")


if __name__ == "__main__":
Expand Down
16 changes: 16 additions & 0 deletions uc-0a/results_ahmedabad.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
complaint_id,category,priority,reason,flag
AM-202401,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
AM-202402,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
AM-202405,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
AM-202406,Heat Hazard,Standard,Classified as Heat Hazard based on the mention of related terms in the description.,
AM-202407,Other,Urgent,Classified as Urgent because the description mentions the safety-critical term 'child'.,NEEDS_REVIEW
AM-202410,Pothole,Standard,Classified as Pothole based on the mention of related terms in the description.,
AM-202414,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
AM-202417,Waste,Standard,Classified as Waste based on the mention of related terms in the description.,
AM-202421,Noise,Standard,Classified as Noise based on the mention of related terms in the description.,
AM-202424,Road Damage,Standard,Classified as Road Damage based on the mention of related terms in the description.,
AM-202429,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
AM-202431,Heritage Damage,Standard,Classified as Heritage Damage based on the mention of related terms in the description.,
AM-202435,Heat Hazard,Standard,Classified as Heat Hazard based on the mention of related terms in the description.,
AM-202444,Waste,Low,Classified as Waste based on the mention of related terms in the description.,
AM-202445,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
16 changes: 16 additions & 0 deletions uc-0a/results_hyderabad.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
complaint_id,category,priority,reason,flag
GH-202401,Flooding,Urgent,Classified as Urgent because the description mentions the safety-critical term 'ambulance'.,
GH-202402,Flooding,Standard,Classified as Flooding based on the mention of related terms in the description.,
GH-202406,Flooding,Standard,Classified as Flooding based on the mention of related terms in the description.,
GH-202407,Drain Blockage,Standard,Classified as Drain Blockage based on the mention of related terms in the description.,
GH-202410,Pothole,Low,Classified as Pothole based on the mention of related terms in the description.,
GH-202411,Pothole,Urgent,Classified as Urgent because the description mentions the safety-critical term 'hospital'.,
GH-202412,Pothole,Urgent,Classified as Urgent because the description mentions the safety-critical term 'school'.,
GH-202417,Waste,Low,Classified as Waste based on the mention of related terms in the description.,
GH-202420,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
GH-202422,Other,Urgent,Classified as Urgent because the description mentions the safety-critical term 'collapse'.,NEEDS_REVIEW
GH-202424,Flooding,Standard,Classified as Flooding based on the mention of related terms in the description.,
GH-202428,Waste,Standard,Classified as Waste based on the mention of related terms in the description.,
GH-202432,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
GH-202448,Flooding,Standard,Classified as Flooding based on the mention of related terms in the description.,
GH-202438,Flooding,Standard,Classified as Flooding based on the mention of related terms in the description.,
16 changes: 16 additions & 0 deletions uc-0a/results_kolkata.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
complaint_id,category,priority,reason,flag
KM-202401,Heritage Damage,Standard,Classified as Heritage Damage based on the mention of related terms in the description.,
KM-202402,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
KM-202405,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
KM-202409,Pothole,Standard,Classified as Pothole based on the mention of related terms in the description.,
KM-202410,Pothole,Low,Classified as Pothole based on the mention of related terms in the description.,
KM-202411,Pothole,Standard,Classified as Pothole based on the mention of related terms in the description.,
KM-202415,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
KM-202418,Waste,Low,Classified as Waste based on the mention of related terms in the description.,
KM-202421,Other,Urgent,Classified as Urgent because the description mentions the safety-critical term 'hospital'.,NEEDS_REVIEW
KM-202422,Road Damage,Standard,Classified as Road Damage based on the mention of related terms in the description.,
KM-202426,Heritage Damage,Standard,Classified as Heritage Damage based on the mention of related terms in the description.,
KM-202430,Waste,Standard,Classified as Waste based on the mention of related terms in the description.,
KM-202434,Heritage Damage,Standard,Classified as Heritage Damage based on the mention of related terms in the description.,
KM-202436,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
KM-202438,Heritage Damage,Standard,Classified as Heritage Damage based on the mention of related terms in the description.,
16 changes: 16 additions & 0 deletions uc-0a/results_pune.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
complaint_id,category,priority,reason,flag
PM-202401,Pothole,Standard,Classified as Pothole based on the mention of related terms in the description.,
PM-202402,Pothole,Urgent,Classified as Urgent because the description mentions the safety-critical term 'child'.,
PM-202406,Flooding,Standard,Classified as Flooding based on the mention of related terms in the description.,
PM-202408,Flooding,Standard,Classified as Flooding based on the mention of related terms in the description.,
PM-202410,Streetlight,Standard,Classified as Streetlight based on the mention of related terms in the description.,
PM-202411,Streetlight,Urgent,Classified as Urgent because the description mentions the safety-critical term 'hazard'.,
PM-202413,Waste,Low,Classified as Waste based on the mention of related terms in the description.,
PM-202418,Noise,Standard,Classified as Noise based on the mention of related terms in the description.,
PM-202419,Road Damage,Standard,Classified as Road Damage based on the mention of related terms in the description.,
PM-202420,Other,Urgent,Classified as Urgent because the description mentions the safety-critical term 'injury'.,NEEDS_REVIEW
PM-202427,Flooding,Standard,Classified as Flooding based on the mention of related terms in the description.,
PM-202428,Other,Standard,Classified as Other based on the mention of related terms in the description.,NEEDS_REVIEW
PM-202430,Streetlight,Standard,Classified as Streetlight based on the mention of related terms in the description.,
PM-202433,Waste,Standard,Classified as Waste based on the mention of related terms in the description.,
PM-202446,Other,Urgent,Classified as Urgent because the description mentions the safety-critical term 'fell'.,NEEDS_REVIEW
24 changes: 11 additions & 13 deletions uc-0a/skills.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# skills.md
# INSTRUCTIONS: Generate a draft by prompting AI, then manually refine this file.
# Delete these comments before committing.
# skills.md — UC-0A Complaint Classifier

skills:
- name: [skill_name]
description: [One sentence — what does this skill do?]
input: [What does it receive? Type and format.]
output: [What does it return? Type and format.]
error_handling: [What does it do when input is invalid or ambiguous?]
- name: classify_complaint
description: Analyzes a single citizen complaint to determine its municipal category and priority.
input: A dictionary representing a single row from the complaint CSV (e.g., {'description': '...', 'location': '...'}).
output: A dictionary containing category (string), priority (string), reason (string), and flag (string).
error_handling: If description is missing, set category to 'Other' and flag to 'NEEDS_REVIEW'.

- name: [second_skill_name]
description: [One sentence]
input: [Type and format]
output: [Type and format]
error_handling: [What does it do when input is invalid or ambiguous?]
- name: batch_classify
description: Orchestrates the classification of multiple complaints from an input CSV file and saves the results.
input: Paths for the input CSV file and the target output CSV file.
output: A status message confirming the number of rows processed and the output file path.
error_handling: If input file is not found, raise a FileNotFoundError and log the error.
24 changes: 14 additions & 10 deletions uc-0b/agents.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
# agents.md
# INSTRUCTIONS: Generate a draft using your RICE prompt, then manually refine this file.
# Delete these comments before committing.
# agents.md — UC-0B Policy Summarizer

role: >
[FILL IN: Who is this agent? What is its operational boundary?]
You are a Legal Compliance Specialist tasked with summarizing municipal policy documents. Your primary responsibility is to distill complex policies into clear summaries while ensuring that no legal obligation or condition is diluted or omitted. You operate with extreme precision, prioritizing accuracy over brevity.

intent: >
[FILL IN: What does a correct output look like — make it verifiable]
To produce a policy summary where:
1. Every numbered clause from the source is explicitly addressed.
2. All binding verbs (must, will, requires, not permitted) and their associated conditions are preserved.
3. No external knowledge or "standard practice" assumptions are introduced.
4. Ambiguous or complex clauses are quoted verbatim to avoid meaning loss.

context: >
[FILL IN: What information is the agent allowed to use? State exclusions explicitly.]
You are provided with a policy text file (e.g., `policy_hr_leave.txt`). You are only allowed to use information within this file. You must explicitly exclude common sense or industry standards not mentioned in the text.

enforcement:
- "[FILL IN: Specific testable rule 1]"
- "[FILL IN: Specific testable rule 2]"
- "[FILL IN: Specific testable rule 3]"
- "[FILL IN: Refusal condition — when should the system refuse rather than guess?]"
- "Every numbered clause in the source document must have a corresponding entry in the summary."
- "Multi-condition obligations (e.g., 'requires approval from X AND Y') must preserve all named parties and conditions; dropping a condition is a critical failure."
- "Do not use 'softening' language (e.g., 'generally', 'typically', 'usually') if the source uses binding verbs like 'must' or 'shall'."
- "Prohibited: Adding information not in the source (e.g., 'standard government practice')."
- "If a clause is too complex to summarize without risk of meaning loss, you must quote the core obligation verbatim and add a 'FLAG: COMPLEX_CLAUSE' note."

Loading