Spaces:
Sleeping
Sleeping
matthew.farant commited on
Commit ·
6d731d9
1
Parent(s): dfb45d5
Add score logic for micro action completions and deep reflection
Browse files- app/assistants.py +2 -0
- app/user.py +10 -0
app/assistants.py
CHANGED
|
@@ -496,8 +496,10 @@ class Assistant:
|
|
| 496 |
elif tool.function.name == "end_conversation":
|
| 497 |
day_n = json.loads(tool.function.arguments)['day_n']
|
| 498 |
completed_micro_action = json.loads(tool.function.arguments)['completed_micro_action']
|
|
|
|
| 499 |
|
| 500 |
self.cm.user.update_micro_action_status(completed_micro_action)
|
|
|
|
| 501 |
|
| 502 |
# NOTE: we will record whether the user has completed the theme for the day
|
| 503 |
# NOTE: if no, we will include a short followup message to encourage the user the next day
|
|
|
|
| 496 |
elif tool.function.name == "end_conversation":
|
| 497 |
day_n = json.loads(tool.function.arguments)['day_n']
|
| 498 |
completed_micro_action = json.loads(tool.function.arguments)['completed_micro_action']
|
| 499 |
+
area_of_deep_reflection = json.loads(tool.function.arguments)['area_of_deep_reflection']
|
| 500 |
|
| 501 |
self.cm.user.update_micro_action_status(completed_micro_action)
|
| 502 |
+
self.cm.user.trigger_deep_reflection_point(area_of_deep_reflection)
|
| 503 |
|
| 504 |
# NOTE: we will record whether the user has completed the theme for the day
|
| 505 |
# NOTE: if no, we will include a short followup message to encourage the user the next day
|
app/user.py
CHANGED
|
@@ -377,7 +377,17 @@ class User:
|
|
| 377 |
if completed_micro_action:
|
| 378 |
self.micro_actions[-1]["status"] = "COMPLETE"
|
| 379 |
self.micro_actions[-1]["updated_at"] = pd.Timestamp.now().strftime("%d-%m-%Y %a %H:%M:%S")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 380 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
def update_goal_status(self):
|
| 382 |
self.goal[-1]["status"] = "COMPLETE"
|
| 383 |
self.goal[-1]["updated_at"] = pd.Timestamp.now().strftime("%d-%m-%Y %a %H:%M:%S")
|
|
|
|
| 377 |
if completed_micro_action:
|
| 378 |
self.micro_actions[-1]["status"] = "COMPLETE"
|
| 379 |
self.micro_actions[-1]["updated_at"] = pd.Timestamp.now().strftime("%d-%m-%Y %a %H:%M:%S")
|
| 380 |
+
|
| 381 |
+
num_of_micro_actions_completed = sum(1 for item in self.micro_actions if item['status'] == 'COMPLETE')
|
| 382 |
+
|
| 383 |
+
if (num_of_micro_actions_completed in (1,3,5)) or (num_of_micro_actions_completed % 10 == 0 and num_of_micro_actions_completed != 0):
|
| 384 |
+
self.add_life_score_point(variable = self.get_current_goal()['area'], points_added = 10, notes = f"Completing the {num_of_micro_actions_completed}-th micro-action")
|
| 385 |
|
| 386 |
+
def trigger_deep_reflection_point(self, area_of_deep_reflection):
|
| 387 |
+
if len(area_of_deep_reflection)>0:
|
| 388 |
+
for area in area_of_deep_reflection:
|
| 389 |
+
self.add_life_score_point(variable = area, points_added = 5, notes = f"Doing a deep reflection about {area}")
|
| 390 |
+
|
| 391 |
def update_goal_status(self):
|
| 392 |
self.goal[-1]["status"] = "COMPLETE"
|
| 393 |
self.goal[-1]["updated_at"] = pd.Timestamp.now().strftime("%d-%m-%Y %a %H:%M:%S")
|