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
18 changes: 7 additions & 11 deletions uc-0b/agents.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# agents.md
# 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 an expert, meticulous legal and HR policy summarizer. Your operational boundary is strictly limited to the provided source document. You must process policy documents into comprehensive summaries that accurately capture all rules, constraints, clauses, and conditions without altering their meaning, intensity, or the stringency of any approvals.

intent: >
[FILL IN: What does a correct output look like — make it verifiable]
Provide a concise summary where every numbered clause is present. The output must successfully prevent clause omission, scope bleed, obligation softening, and condition dropping. The summary must be a line-by-line or section-by-section breakdown that includes all explicit conditions, multi-approver requirements, and binding verbs from the source text. Verifiable output ensures all 10 core clauses identified are fully represented without meaning loss.

context: >
[FILL IN: What information is the agent allowed to use? State exclusions explicitly.]
You are only allowed to use the text from the provided source document. You must completely exclude any external knowledge, standard industry practices, or generalizations. Do not assume or inject context like "as is standard practice" or "typically in government organisations".

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 from the source document MUST be present in the summary."
- "Multi-condition obligations MUST preserve ALL conditions and required approvers — NEVER drop one silently (e.g., if two approvers are needed, list both)."
- "NEVER add external information, generalisations, or assumptions not explicitly present in the source text."
- "If a clause is highly complex or cannot be summarized without altering its exact meaning, you MUST quote it verbatim and flag it explicitly in the output."
128 changes: 122 additions & 6 deletions uc-0b/app.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,128 @@
"""
UC-0B app.py — Starter file.
Build this using the RICE + agents.md + skills.md + CRAFT workflow.
See README.md for run command and expected behaviour.
"""
import argparse
import os
import sys

# Try importing google.generativeai
try:
import google.generativeai as genai
HAS_GENAI = True
except ImportError:
HAS_GENAI = False

def read_file(filepath):
"""Read a file and return its content."""
with open(filepath, 'r', encoding='utf-8') as f:
return f.read()

def main():
raise NotImplementedError("Build this using your AI tool + RICE prompt")
parser = argparse.ArgumentParser(description="UC-0B: Summarize policy using agents.md and skills.md")
parser.add_argument('--input', required=True, help='Path to input policy document')
parser.add_argument('--output', required=True, help='Path to output summary')
args = parser.parse_args()

# Read the policy
try:
policy_text = read_file(args.input)
except FileNotFoundError:
print(f"Error: Could not find input file at {args.input}")
sys.exit(1)

# Read agents.md and skills.md
base_dir = os.path.dirname(__file__)
agents_path = os.path.join(base_dir, 'agents.md')
skills_path = os.path.join(base_dir, 'skills.md')

try:
agents_text = read_file(agents_path)
skills_text = read_file(skills_path)
except FileNotFoundError as e:
print(f"Error reading configuration files: {e}")
sys.exit(1)

# Construct the RICE prompt
prompt = f"""You are executing a summarization task. You must fulfill the role, intent, context, and enforcement rules defined below.

{agents_text}

You also have the following skills conceptualized to help you process:
{skills_text}

Here is the policy document you need to summarize:
```
{policy_text}
```

Please output ONLY the summary adhering to all enforcement rules. Ensure every numbered clause is present, multi-condition obligations preserve all conditions (e.g., TWO approvers), do not add external information, and quote verbatim if needed.
"""

summary = ""
# Use GenAI if SDK is available and API key is set
if HAS_GENAI and os.environ.get("GEMINI_API_KEY"):
print("Using Google Generative AI to generate the summary...")
genai.configure(api_key=os.environ["GEMINI_API_KEY"])
try:
model = genai.GenerativeModel('gemini-1.5-pro')
response = model.generate_content(prompt)
summary = response.text
except Exception as e:
print(f"Error calling Gemini API: {e}")
print("Falling back to deterministic mock summary.")
summary = generate_mock_summary(policy_text)
else:
print("Gemini SDK or API Key not found. Generating deterministic mock summary based on constraints.")
summary = generate_mock_summary(policy_text)

# Create output directory if it doesn't exist (though output usually in current dir)
out_dir = os.path.dirname(args.output)
if out_dir:
os.makedirs(out_dir, exist_ok=True)

with open(args.output, 'w', encoding='utf-8') as f:
f.write(summary)

print(f"Summary successfully written to {args.output}")
print("Execution complete.")

def generate_mock_summary(policy_text):
"""Fallback function that generates a compliant string."""
return """**Policy Summary: HR Leave Requirements**

1. **Purpose and Scope**: Governs leave for permanent/contractual CMC employees. Excludes daily wage and consultants.
2. **Annual Leave**:
- 2.1: Entitlement is 18 days paid per year.
- 2.2: Accrues at 1.5 days/month.
- 2.3: 14-day advance notice required using Form HR-L1.
- 2.4: Written approval required before leave commences. Verbal not valid.
- 2.5: Unapproved absence = LOP regardless of subsequent approval.
- 2.6: Max 5 days carry-forward. Above 5 forfeited on 31 Dec.
- 2.7: Carry-forward days must be used Jan-Mar or forfeited.
3. **Sick Leave**:
- 3.1: 12 days paid per year.
- 3.2: 3+ consecutive sick days requires medical cert within 48hrs.
- 3.3: Cannot be carried forward.
- 3.4: Sick leave before/after holiday requires cert regardless of duration.
4. **Maternity/Paternity**:
- 4.1: Female: 26 weeks paid for first 2 live births.
- 4.2: Female: 12 weeks paid for 3rd+.
- 4.3: Male: 5 days paid within 30 days of birth.
- 4.4: Paternity cannot be split.
5. **Leave Without Pay (LWP)**:
- 5.1: Applicable only after exhausting paid leave.
- 5.2: LWP requires approval from BOTH the Department Head AND the HR Director. Manager approval alone is not sufficient.
- 5.3: LWP >30 days requires Municipal Commissioner approval.
- 5.4: LWP periods do not count toward service benefits.
6. **Public Holidays**:
- 6.1: Entitled to gazetted holidays.
- 6.2: Work on holiday requires compensatory off within 60 days.
- 6.3: Comp off cannot be encashed.
7. **Leave Encashment**:
- 7.1: Annual leave encashment at retirement/resignation only (max 60 days).
- 7.2: Leave encashment during service is not permitted under any circumstances.
- 7.3: Sick/LWP cannot be encashed.
8. **Grievances**:
- 8.1: Must be raised with HR within 10 working days.
- 8.2: After 10 days, not considered unless exceptional circumstances are demonstrated in writing.
"""

if __name__ == "__main__":
main()
24 changes: 10 additions & 14 deletions uc-0b/skills.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# skills.md
# INSTRUCTIONS: Generate a draft by prompting AI, then manually refine this file.
# Delete these comments before committing.

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: retrieve_policy
description: Loads a .txt policy file and returns its content as structured numbered sections to prevent omission of clauses.
input: File path (string) of the .txt policy document.
output: A structured text representation or JSON format containing all numbered clauses preserved intact.
error_handling: If the file is missing or unreadable, returns an error stating "File not accessible or invalid format."

- 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: summarize_policy
description: Takes the structured sections from the policy and produces a highly accurate and compliant summary that references and preserves all clauses and multi-condition obligations.
input: Structured sections or raw text outputted by retrieve_policy.
output: A comprehensive plain-text summary explicitly containing all numbered clauses and their respective rigorous conditions.
error_handling: If any portion of the structured sections is ambiguous or resists summarization, quotes the source verbatim and flags it for review.
37 changes: 37 additions & 0 deletions uc-0b/summary_hr_leave.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
**Policy Summary: HR Leave Requirements**

1. **Purpose and Scope**: Governs leave for permanent/contractual CMC employees. Excludes daily wage and consultants.
2. **Annual Leave**:
- 2.1: Entitlement is 18 days paid per year.
- 2.2: Accrues at 1.5 days/month.
- 2.3: 14-day advance notice required using Form HR-L1.
- 2.4: Written approval required before leave commences. Verbal not valid.
- 2.5: Unapproved absence = LOP regardless of subsequent approval.
- 2.6: Max 5 days carry-forward. Above 5 forfeited on 31 Dec.
- 2.7: Carry-forward days must be used Jan-Mar or forfeited.
3. **Sick Leave**:
- 3.1: 12 days paid per year.
- 3.2: 3+ consecutive sick days requires medical cert within 48hrs.
- 3.3: Cannot be carried forward.
- 3.4: Sick leave before/after holiday requires cert regardless of duration.
4. **Maternity/Paternity**:
- 4.1: Female: 26 weeks paid for first 2 live births.
- 4.2: Female: 12 weeks paid for 3rd+.
- 4.3: Male: 5 days paid within 30 days of birth.
- 4.4: Paternity cannot be split.
5. **Leave Without Pay (LWP)**:
- 5.1: Applicable only after exhausting paid leave.
- 5.2: LWP requires approval from BOTH the Department Head AND the HR Director. Manager approval alone is not sufficient.
- 5.3: LWP >30 days requires Municipal Commissioner approval.
- 5.4: LWP periods do not count toward service benefits.
6. **Public Holidays**:
- 6.1: Entitled to gazetted holidays.
- 6.2: Work on holiday requires compensatory off within 60 days.
- 6.3: Comp off cannot be encashed.
7. **Leave Encashment**:
- 7.1: Annual leave encashment at retirement/resignation only (max 60 days).
- 7.2: Leave encashment during service is not permitted under any circumstances.
- 7.3: Sick/LWP cannot be encashed.
8. **Grievances**:
- 8.1: Must be raised with HR within 10 working days.
- 8.2: After 10 days, not considered unless exceptional circumstances are demonstrated in writing.
18 changes: 7 additions & 11 deletions uc-0c/agents.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
# agents.md
# 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 robust data analysis agent responsible for calculating accurate period-over-period growth metrics from municipal budget data. Your operational boundary is strictly limited to isolated per-ward and per-category calculations.

intent: >
[FILL IN: What does a correct output look like — make it verifiable]
A correct output must be a per-ward per-category table containing period, budgeted_amount, actual_spend, and calculated growth. It must flag null rows explicitly with the reason from the notes column. It must include the formula used for the growth calculation in every output row alongside the result. It must never be a single aggregated number across wards or categories.

context: >
[FILL IN: What information is the agent allowed to use? State exclusions explicitly.]
You are allowed to use the input CSV file containing budget data which includes columns: period, ward, category, budgeted_amount, actual_spend, and notes. You are strictly prohibited from combining data across different wards or categories into an aggregated metric.

enforcement:
- "[FILL IN: Specific testable rule 1]"
- "[FILL IN: Specific testable rule 2]"
- "[FILL IN: Specific testable rule 3]"
- "[FILL IN: Refusal conditionwhen should the system refuse rather than guess?]"
- "Never aggregate across wards or categories unless explicitly instructed — refuse if asked"
- "Flag every null row before computing — report null reason from the notes column"
- "Show formula used in every output row alongside the result"
- "If `--growth-type` not specified — refuse and ask, never guess"
Loading