Spaces:
Runtime error
Runtime error
Update core/ai_engine.py
Browse files- core/ai_engine.py +4 -8
core/ai_engine.py
CHANGED
|
@@ -90,9 +90,7 @@ Classify the task across these dimensions:
|
|
| 90 |
|
| 91 |
6. time_estimate (integer): Realistic minutes to complete.
|
| 92 |
|
| 93 |
-
7. deadline_date (string or null):
|
| 94 |
-
Today is {today}. Examples: "by Friday" → next Friday's date, "due March 1" → "2026-03-01".
|
| 95 |
-
Return null if no deadline is mentioned.
|
| 96 |
|
| 97 |
8. clarifications_needed (array of strings):
|
| 98 |
If NOT confident about a dimension, add a short specific question.
|
|
@@ -101,8 +99,7 @@ Classify the task across these dimensions:
|
|
| 101 |
STRICT RULES:
|
| 102 |
- Return ONLY valid JSON. No markdown, no explanation.
|
| 103 |
- Never guess if uncertain — ask a clarification question instead.
|
| 104 |
-
- Always return all 8 fields.
|
| 105 |
-
- ALWAYS extract deadline_date if user says "by X", "due X", "before X", "deadline X".
|
| 106 |
|
| 107 |
Example: {"title": "Finish project proposal", "life_area": "Work", "urgency": "Urgent", "importance": "Move the Needle", "state_of_mind": "Flow", "time_estimate": 90, "deadline_date": null, "clarifications_needed": []}"""
|
| 108 |
|
|
@@ -120,12 +117,11 @@ def parse_task_with_groq(raw_text: str, user_context: dict = None,
|
|
| 120 |
if life_areas:
|
| 121 |
context_hint += f"\nUser's life areas: {', '.join(life_areas)}"
|
| 122 |
|
| 123 |
-
|
| 124 |
-
system_prompt = TASK_CAPTURE_PROMPT.replace("{today}", today_str) + context_hint
|
| 125 |
response = _groq().chat.completions.create(
|
| 126 |
model=GROQ_MODEL,
|
| 127 |
messages=[
|
| 128 |
-
{"role": "system", "content":
|
| 129 |
{"role": "user", "content": f"Parse this task: {raw_text}"}
|
| 130 |
],
|
| 131 |
max_tokens=512,
|
|
|
|
| 90 |
|
| 91 |
6. time_estimate (integer): Realistic minutes to complete.
|
| 92 |
|
| 93 |
+
7. deadline_date (string or null): If user says "by Friday", "due March 1", "before end of month", "deadline X" — extract as YYYY-MM-DD. Today is {TODAY}. Return null if no deadline mentioned.
|
|
|
|
|
|
|
| 94 |
|
| 95 |
8. clarifications_needed (array of strings):
|
| 96 |
If NOT confident about a dimension, add a short specific question.
|
|
|
|
| 99 |
STRICT RULES:
|
| 100 |
- Return ONLY valid JSON. No markdown, no explanation.
|
| 101 |
- Never guess if uncertain — ask a clarification question instead.
|
| 102 |
+
- Always return all 8 fields including deadline_date (null if none).
|
|
|
|
| 103 |
|
| 104 |
Example: {"title": "Finish project proposal", "life_area": "Work", "urgency": "Urgent", "importance": "Move the Needle", "state_of_mind": "Flow", "time_estimate": 90, "deadline_date": null, "clarifications_needed": []}"""
|
| 105 |
|
|
|
|
| 117 |
if life_areas:
|
| 118 |
context_hint += f"\nUser's life areas: {', '.join(life_areas)}"
|
| 119 |
|
| 120 |
+
_prompt = TASK_CAPTURE_PROMPT.replace("{TODAY}", str(date.today())) + context_hint
|
|
|
|
| 121 |
response = _groq().chat.completions.create(
|
| 122 |
model=GROQ_MODEL,
|
| 123 |
messages=[
|
| 124 |
+
{"role": "system", "content": _prompt},
|
| 125 |
{"role": "user", "content": f"Parse this task: {raw_text}"}
|
| 126 |
],
|
| 127 |
max_tokens=512,
|