From 289b4b98bd9804bfcc9c1ba0e5558b60a044c4e3 Mon Sep 17 00:00:00 2001 From: Igor Novikov Date: Sat, 13 Jan 2024 18:16:34 +0400 Subject: [PATCH] [#24, #38] Fix generate_hourly_schedule --- .../persona/cognitive_modules/plan.py | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/reverie/backend_server/persona/cognitive_modules/plan.py b/reverie/backend_server/persona/cognitive_modules/plan.py index 34d69876e8..e0be6ae970 100644 --- a/reverie/backend_server/persona/cognitive_modules/plan.py +++ b/reverie/backend_server/persona/cognitive_modules/plan.py @@ -95,19 +95,29 @@ def generate_hourly_schedule(persona, wake_up_hour): "10:00 AM", "11:00 AM", "12:00 PM", "01:00 PM", "02:00 PM", "03:00 PM", "04:00 PM", "05:00 PM", "06:00 PM", "07:00 PM", "08:00 PM", "09:00 PM", "10:00 PM", "11:00 PM"] + # Discarded original implementation: we don't have the luxury for multiple passes. + # + # n_m1_activity = [] + # diversity_repeat_count = 3 + # for i in range(diversity_repeat_count): + # n_m1_activity_set = set(n_m1_activity) + # if len(n_m1_activity_set) < 5: + # n_m1_activity = [] + # for count, curr_hour_str in enumerate(hour_str): + # if wake_up_hour > 0: + # n_m1_activity += ["sleeping"] + # wake_up_hour -= 1 + # else: + # n_m1_activity += [run_gpt_prompt_generate_hourly_schedule( + # persona, curr_hour_str, n_m1_activity, hour_str)[0]] n_m1_activity = [] - diversity_repeat_count = 3 - for i in range(diversity_repeat_count): - n_m1_activity_set = set(n_m1_activity) - if len(n_m1_activity_set) < 5: - n_m1_activity = [] - for count, curr_hour_str in enumerate(hour_str): - if wake_up_hour > 0: - n_m1_activity += ["sleeping"] - wake_up_hour -= 1 - else: - n_m1_activity += [run_gpt_prompt_generate_hourly_schedule( - persona, curr_hour_str, n_m1_activity, hour_str)[0]] + for count, curr_hour_str in enumerate(hour_str): + if wake_up_hour > 0: + n_m1_activity += ["sleeping"] + wake_up_hour -= 1 + else: + n_m1_activity += [run_gpt_prompt_generate_hourly_schedule( + persona, curr_hour_str, n_m1_activity, hour_str)[0]] # Step 1. Compressing the hourly schedule to the following format: # The integer indicates the number of hours. They should add up to 24.