CoolFace
Apppublic

ashnaali22/phase-3-h2

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
priority_classifier.cpython-310.pyc62 linesDownload Raw Back to __pycache__
1o

2r:Fis�3@spdZddlmZmZddlmZgd�Zdedeedefdd	�Zdeedeed4edeedef5dd
�ZdS)a�6Priority Classification Service for Task Management7 8This module implements automatic priority classification based on task urgency9keywords and due date proximity, following the Skills & Subagents Architecture.10 11Classification Rules:12- VERY_IMPORTANT: Urgency keyword in title OR due date within 6 hours13- HIGH: Due date within 24 hours14- MEDIUM: Due date within 7 days15- LOW: Due date beyond 7 days OR no due date16�)�datetime�	timedelta)�Optional)ZurgentZasap�criticalZ	importantZ	emergency�title�due_date�returncs�|���t�fdd�tD��}|dur|rdSdSt��}|jdur/ddlm}|j|jd�}ddlm}|j|jd�}||}|t	d	d17�krIdS|t	dd18�krRdS|t	d
d�kr[dSdS)a�19    Classify task priority based on title urgency keywords and due date proximity.20 21    Args:22        title: Task title to check for urgency keywords23        due_date: Optional task due date (timezone-aware datetime)24 25    Returns:26        Priority level: 'VERY_IMPORTANT' | 'HIGH' | 'MEDIUM' | 'LOW'27 28    Examples:29        >>> classify_priority("Urgent: Fix production bug", None)30        'VERY_IMPORTANT'31 32        >>> from datetime import datetime, timezone, timedelta33        >>> now = datetime.now(timezone.utc)34        >>> classify_priority("Normal task", now + timedelta(hours=3))35        'VERY_IMPORTANT'36 37        >>> classify_priority("Normal task", now + timedelta(hours=20))38        'HIGH'39 40        >>> classify_priority("Normal task", now + timedelta(days=5))41        'MEDIUM'42 43        >>> classify_priority("Normal task", now + timedelta(days=10))44        'LOW'45 46        >>> classify_priority("Normal task", None)47        'LOW'48    c3s�|]}|�vVqdS)N�)�.0�keyword�Ztitle_lowerr	�SD:\code\Q4\hackathon-2\todo-app\phase-3\backend\src\services\priority_classifier.py�	<genexpr>8s�z$classify_priority.<locals>.<genexpr>N�VERY_IMPORTANT�LOWr)�timezone)�tzinfo�)�hours�ZHIGH�)�daysZMEDIUM)49�lower�any�URGENCY_KEYWORDSr�utcnowrr�replace�utcr)rrZhas_urgency_keyword�nowr�time_until_duer	rr
�classify_prioritys$!50r �
current_title�current_due_datecCs*|dur|n|}|dur|n|}t||�S)a�51    Re-classify priority when task is updated.52 53    Args:54        title: New title (None if not being updated)55        due_date: New due date (None if not being updated, could be explicitly set to None to clear)56        current_title: Current task title57        current_due_date: Current task due date58 59    Returns:60        Priority level: 'VERY_IMPORTANT' | 'HIGH' | 'MEDIUM' | 'LOW'61    N)r )rrr!r"Zeffective_titleZeffective_due_dater	r	r
�reclassify_priority_on_update\s62r#N)	�__doc__rr�typingrr�strr r#r	r	r	r
�<module>s 
F�����