From 3dfde879c41be548aa1bf0d2aa54862387a6639f Mon Sep 17 00:00:00 2001 From: Igor Novikov Date: Thu, 18 Jan 2024 22:06:11 +0400 Subject: [PATCH] [#24] Restore a bunch of prompts to the working order --- .gitignore | 1 + .../persona/cognitive_modules/plan.py | 57 +--- reverie/backend_server/persona/common.py | 8 + .../persona/prompt_template/run_gpt_prompt.py | 292 +++++++----------- .../action_location_object_v1/skprompt.txt | 20 +- .../action_location_sector_v2/skprompt.txt | 4 +- .../v4_sk/task_decomp_v3/config.json | 4 +- .../v4_sk/task_decomp_v3/skprompt.txt | 25 +- reverie/backend_server/reverie.py | 5 +- 9 files changed, 159 insertions(+), 257 deletions(-) create mode 100644 reverie/backend_server/persona/common.py diff --git a/.gitignore b/.gitignore index e536f37194..ea01d7262b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ storage/* static_dirs/* /environment/frontend_server/storage /environment/frontend_server/temp_storage +/reverie/backend_server/debug_cache.json !storage/base_the_ville_isabella_maria_klaus/* !storage/base_the_ville_n25/* diff --git a/reverie/backend_server/persona/cognitive_modules/plan.py b/reverie/backend_server/persona/cognitive_modules/plan.py index 9057b954cf..38bcf07601 100644 --- a/reverie/backend_server/persona/cognitive_modules/plan.py +++ b/reverie/backend_server/persona/cognitive_modules/plan.py @@ -18,16 +18,7 @@ from persona.cognitive_modules.retrieve import * from persona.cognitive_modules.converse import * from persona.prompt_template.embedding import get_embedding - -class HourlyScheduleItem: - def __init__(self, task: str, start_time: int, duration: int = None): - self.task = task - self.start_time = start_time - self.duration = duration - - def __repr__(self): - return f"HourlyScheduleItem(task={self.task}, start_time={self.start_time}, duration={self.duration})" - +from persona.common import HourlyScheduleItem ############################################################################## # CHAPTER 2: Generate ############################################################################## @@ -148,32 +139,6 @@ def generate_hourly_schedule(persona, wake_up_hour): # Return the mapped daily requirements return daily_req_mapped -def generate_task_decomp(persona, task, duration): - """ - A few shot decomposition of a task given the task description - - Persona state: identity stable set, curr_date_str, first_name - - INPUT: - persona: The Persona class instance - task: the description of the task at hand in str form - (e.g., "waking up and starting her morning routine") - duration: an integer that indicates the number of minutes this task is - meant to last (e.g., 60) - OUTPUT: - a list of list where the inner list contains the decomposed task - description and the number of minutes the task is supposed to last. - EXAMPLE OUTPUT: - [['going to the bathroom', 5], ['getting dressed', 5], - ['eating breakfast', 15], ['checking her email', 5], - ['getting her supplies ready for the day', 15], - ['starting to work on her painting', 15]] - - """ - if debug: print ("GNS FUNCTION: ") - return run_gpt_prompt_task_decomp(persona, task, duration)[0] - - def generate_action_sector(act_desp, persona, maze): """TODO Given the persona and the task description, choose the action_sector. @@ -537,21 +502,21 @@ def is_sleeping(action: HourlyScheduleItem) -> bool: OUTPUT: a boolean. True if the action is not a sleeping action and needs to be decomposed, False otherwise. """ - task = action.task + task = action.task.lower() # If the task doesn't mention "sleep" or "bed" at all, # then we assume it's not a sleeping action and should be decomposed. if "sleep" not in task and "bed" not in task: - return True + return False # If the task is explicit about the NPC sleeping (e.g., "sleeping", "asleep", "in bed"), # then we don't decompose it as it's a single, continuous action. elif "sleeping" in task or "asleep" in task or "in bed" in task: - return False + return True # If "sleep" or "bed" is mentioned, but it's not explicit that the NPC is sleeping, # we use the duration to determine if it's a sleep or sleep-related action. # If the duration is more than 60 minutes, we assume it's a sleep action and don't decompose it. elif action.duration > 60: - return False - return True + return True + return False def _determine_action(persona, maze): """ @@ -585,13 +550,13 @@ def _determine_action(persona, maze): # criteria described in determine_decomp. if not is_sleeping(item): persona.scratch.f_daily_schedule[curr_index:curr_index+1] = ( - generate_task_decomp(persona, item.task, item.duration)) + run_gpt_prompt_task_decomp(persona, item)) if curr_index_60 + 1 < len(persona.scratch.f_daily_schedule): item = persona.scratch.f_daily_schedule[curr_index_60+1] if item.duration >= 60: if not is_sleeping(item): persona.scratch.f_daily_schedule[curr_index_60+1:curr_index_60+2] = ( - generate_task_decomp(persona, item.task, item.duration)) + run_gpt_prompt_task_decomp(persona, item)) if curr_index_60 < len(persona.scratch.f_daily_schedule): # If it is not the first hour of the day, this is always invoked (it is @@ -602,9 +567,9 @@ def _determine_action(persona, maze): # And we don't want to decompose after 11 pm. item = persona.scratch.f_daily_schedule[curr_index_60] if item.duration >= 60: - if not is_sleeping(item.task, item.duration): + if not is_sleeping(item): persona.scratch.f_daily_schedule[curr_index_60:curr_index_60+1] = ( - generate_task_decomp(persona, item.task, item.duration)) + run_gpt_prompt_task_decomp(persona, item)) # * End of Decompose * # Generate an instance from the action description and duration. By @@ -619,7 +584,7 @@ def _determine_action(persona, maze): # 1440 x_emergency = 0 - for i in persona.scratch.f_daily_schedule: + for i in persona.scratch.f_daily_schedule_hourly_org: x_emergency += i.duration # print ("x_emergency", x_emergency) diff --git a/reverie/backend_server/persona/common.py b/reverie/backend_server/persona/common.py new file mode 100644 index 0000000000..4745775622 --- /dev/null +++ b/reverie/backend_server/persona/common.py @@ -0,0 +1,8 @@ +class HourlyScheduleItem: + def __init__(self, task: str, start_time: int, duration: int = None): + self.task = task + self.start_time = start_time + self.duration = duration + + def __repr__(self): + return f"HourlyScheduleItem(task={self.task}, start_time={self.start_time}, duration={self.duration})" diff --git a/reverie/backend_server/persona/prompt_template/run_gpt_prompt.py b/reverie/backend_server/persona/prompt_template/run_gpt_prompt.py index d04b223a36..da43c1c3a8 100644 --- a/reverie/backend_server/persona/prompt_template/run_gpt_prompt.py +++ b/reverie/backend_server/persona/prompt_template/run_gpt_prompt.py @@ -16,6 +16,7 @@ from global_methods import * from persona.prompt_template.gpt_structure import * from persona.prompt_template.print_prompt import * +from persona.common import HourlyScheduleItem kernel.set_default_chat_service("strong") skill = kernel.import_semantic_skill_from_directory("persona/prompt_template", "v4_sk") @@ -39,7 +40,7 @@ def get_random_alphanumeric(i=6, j=6): # CHAPTER 1: Run GPT Prompt ############################################################################## -@instantiated +@functor class run_gpt_prompt_wake_up_hour(InferenceStrategy): semantic_function = skill["wake_up_hour_v1"] @@ -71,7 +72,7 @@ def fallback(self, persona): OUTPUT: a list of daily actions in broad strokes. """ -@instantiated +@functor class run_gpt_prompt_daily_plan(InferenceStrategy): semantic_function = skill["daily_planning_v6"] @@ -101,87 +102,70 @@ def fallback(self, persona, wake_up_hour): 'go to bed at 11:00 pm', ] -def surrounding_schedule(persona, task, duration): - hourly_schedule = persona.scratch.f_daily_schedule_hourly_org - -run_gpt_prompt_task_decomp = create_prompt_runner( - skill['task_decomp_v3'], - context_prep=lambda persona, task, duration: { - "commonset": persona.scratch.get_str_iss(), - "firstname": persona.scratch.get_str_firstname(), - "surrounding_schedule": persona.scratch.get_f_daily_schedule_hourly_org_index() - }, -) - -def run_gpt_prompt_task_decomp_old(persona, - task, - duration, - test_input=None, - verbose=False): - def create_prompt_input(persona, task, duration, test_input=None): - - """ - Today is Saturday June 25. From 00:00 ~ 06:00am, Maeve is - planning on sleeping, 06:00 ~ 07:00am, Maeve is - planning on waking up and doing her morning routine, - and from 07:00am ~08:00am, Maeve is planning on having breakfast. - """ - - curr_f_org_index = persona.scratch.get_f_daily_schedule_hourly_org_index() - all_indices = [] - # if curr_f_org_index > 0: - # all_indices += [curr_f_org_index-1] - all_indices += [curr_f_org_index] - if curr_f_org_index+1 <= len(persona.scratch.f_daily_schedule_hourly_org): - all_indices += [curr_f_org_index+1] - if curr_f_org_index+2 <= len(persona.scratch.f_daily_schedule_hourly_org): - all_indices += [curr_f_org_index+2] - - curr_time_range = "" - - print ("DEBUG") - print (persona.scratch.f_daily_schedule_hourly_org) - print (all_indices) - +# A few shot decomposition of a task given the task description +# +# Persona state: identity stable set, curr_date_str, first_name +# +# INPUT: +# persona: The Persona class instance +# task: the description of the task at hand in str form +# (e.g., "waking up and starting her morning routine") +# duration: an integer that indicates the number of minutes this task is +# meant to last (e.g., 60) +# OUTPUT: +# a list of list where the inner list contains the decomposed task +# description and the number of minutes the task is supposed to last. +# EXAMPLE OUTPUT: +# [['going to the bathroom', 5], ['getting dressed', 5], +# ['eating breakfast', 15], ['checking her email', 5], +# ['getting her supplies ready for the day', 15], +# ['starting to work on her painting', 15]] +@functor +class run_gpt_prompt_task_decomp(InferenceStrategy): + semantic_function = skill["task_decomp_v3"] + + def prepare_context(self, persona, schedule_item: HourlyScheduleItem): + # The complex part is producing the surrounding schedule. + # Here's an example: + # + # Today is Saturday June 25. From 00:00 ~ 06:00am, Maeve is + # planning on sleeping, 06:00 ~ 07:00am, Maeve is + # planning on waking up and doing her morning routine, + # and from 07:00am ~08:00am, Maeve is planning on having + # breakfast. + + self.schedule_item = schedule_item + firstname = persona.scratch.get_str_firstname() + schedule = persona.scratch.f_daily_schedule_hourly_org + schedule_item_index = schedule.index(schedule_item) + start_index = max(schedule_item_index - 1, 0) + end_index = min(schedule_item_index + 2, len(schedule) - 1) + surrounding_schedule_items = schedule[start_index:end_index] + + primary_time_range = None summ_str = f'Today is {persona.scratch.curr_time.strftime("%B %d, %Y")}. ' summ_str += f'From ' - for index in all_indices: - print ("index", index) - if index < len(persona.scratch.f_daily_schedule_hourly_org): - start_min = 0 - for i in range(index): - start_min += persona.scratch.f_daily_schedule_hourly_org[i][1] - end_min = start_min + persona.scratch.f_daily_schedule_hourly_org[index][1] - start_time = (datetime.datetime.strptime("00:00:00", "%H:%M:%S") - + datetime.timedelta(minutes=start_min)) - end_time = (datetime.datetime.strptime("00:00:00", "%H:%M:%S") - + datetime.timedelta(minutes=end_min)) - start_time_str = start_time.strftime("%H:%M%p") - end_time_str = end_time.strftime("%H:%M%p") - summ_str += f"{start_time_str} ~ {end_time_str}, {persona.name} is planning on {persona.scratch.f_daily_schedule_hourly_org[index][0]}, " - if curr_f_org_index+1 == index: - curr_time_range = f'{start_time_str} ~ {end_time_str}' + for cur_item in surrounding_schedule_items: + start_time_str = self.minutes_to_time_string(cur_item.start_time) + end_time_str = self.minutes_to_time_string(cur_item.start_time + cur_item.duration) + cur_time_range = f'{start_time_str} ~ {end_time_str}' + summ_str += f'{cur_time_range}, {firstname} is planning on "{cur_item.task}", ' + if cur_item is schedule_item: + primary_time_range = f'{start_time_str} ~ {end_time_str}' summ_str = summ_str[:-2] + "." - prompt_input = [] - prompt_input += [persona.scratch.get_str_iss()] - prompt_input += [summ_str] - # prompt_input += [persona.scratch.get_str_curr_date_str()] - prompt_input += [persona.scratch.get_str_firstname()] - prompt_input += [persona.scratch.get_str_firstname()] - prompt_input += [task] - prompt_input += [curr_time_range] - prompt_input += [duration] - prompt_input += [persona.scratch.get_str_firstname()] - return prompt_input - - def __func_clean_up(gpt_response, prompt=""): - print ("TOODOOOOOO") - print (gpt_response) - print ("-==- -==- -==- ") + return { + "commonset": persona.scratch.get_str_iss(), + "surrounding_schedule": summ_str, + "firstname": firstname, + "task": schedule_item.task, + "time_range": primary_time_range, + "duration": schedule_item.duration + } + def extractor(self, output): # TODO SOMETHING HERE sometimes fails... See screenshot - temp = [i.strip() for i in gpt_response.split("\n")] + temp = [i.strip() for i in output.split("\n")] _cr = [] cr = [] for count, i in enumerate(temp): @@ -192,13 +176,11 @@ def __func_clean_up(gpt_response, prompt=""): for count, i in enumerate(_cr): k = [j.strip() for j in i.split("(duration in minutes:")] task = k[0] - if task[-1] == ".": - task = task[:-1] - duration = int(k[1].split(",")[0].strip()) + task = re.sub(r'[^\w\d]*$', '', task) + duration = int(re.findall(r'\d+', k[1])[0]) cr += [[task, duration]] - total_expected_min = int(prompt.split("(total duration in minutes")[-1] - .split("):")[0].strip()) + total_expected_min = self.schedule_item.duration # TODO -- now, you need to make sure that this is the same as the sum of # the current action sequence. @@ -232,82 +214,13 @@ def __func_clean_up(gpt_response, prompt=""): return cr - def __func_validate(gpt_response, prompt=""): - # TODO -- this sometimes generates error - try: - __func_clean_up(gpt_response) - except: - pass - # return False - return gpt_response - - def get_fail_safe(): - fs = ["asleep"] - return fs - - gpt_param = {"engine": "text-davinci-003", "max_tokens": 1000, - "temperature": 0, "top_p": 1, "stream": False, - "frequency_penalty": 0, "presence_penalty": 0, "stop": None} - prompt_template = "persona/prompt_template/v2/task_decomp_v3.txt" - prompt_input = create_prompt_input(persona, task, duration) - prompt = generate_prompt(prompt_input, prompt_template) - fail_safe = get_fail_safe() - - print ("?????") - print (prompt) - output = safe_generate_response(prompt, gpt_param, 5, get_fail_safe(), - __func_validate, __func_clean_up, override_deprecated=True) - - # TODO THERE WAS A BUG HERE... - # This is for preventing overflows... - """ - File "/Users/joonsungpark/Desktop/Stanford/Projects/ - generative-personas/src_exploration/reverie_simulation/ - brain/get_next_action_v3.py", line 364, in run_gpt_prompt_task_decomp - fin_output[-1][1] += (duration - ftime_sum) - IndexError: list index out of range - """ - - print ("IMPORTANT VVV DEBUG") - - # print (prompt_input) - # print (prompt) - print (output) - - fin_output = [] - time_sum = 0 - for i_task, i_duration in output: - time_sum += i_duration - # HM????????? - # if time_sum < duration: - if time_sum <= duration: - fin_output += [[i_task, i_duration]] - else: - break - ftime_sum = 0 - for fi_task, fi_duration in fin_output: - ftime_sum += fi_duration - - # print ("for debugging... line 365", fin_output) - fin_output[-1][1] += (duration - ftime_sum) - output = fin_output - - - - task_decomp = output - ret = [] - for decomp_task, duration in task_decomp: - ret += [[f"{task} ({decomp_task})", duration]] - output = ret - - - if debug or verbose: - print_run_prompts(prompt_template, persona, gpt_param, - prompt_input, prompt, output) - - return output, [output, prompt, gpt_param, prompt_input, fail_safe] - + def fallback(self, persona, schedule_item): + return [[schedule_item.task, schedule_item.duration]] + def minutes_to_time_string(self, minutes): + time = (datetime.datetime.strptime("00:00:00", "%H:%M:%S") + + datetime.timedelta(minutes=minutes)) + return time.strftime("%H:%M %p").lower() def run_gpt_prompt_action_sector(action_description, persona, @@ -586,8 +499,9 @@ def get_fail_safe(): fail_safe = get_fail_safe() output = safe_generate_response(prompt, gpt_param, 5, fail_safe, - __func_validate, __func_clean_up) + __func_validate, __func_clean_up, override_deprecated=True) + output = re.search('^[^\n]*', output).group() x = [i.strip() for i in persona.s_mem.get_str_accessible_arena_game_objects(temp_address).split(",")] if output not in x: output = random.choice(x) @@ -608,19 +522,19 @@ def create_prompt_input(action_description): prompt_input = [action_description] return prompt_input - def __func_clean_up(gpt_response, prompt=""): - cr = gpt_response.strip() - if len(cr) > 3: - cr = cr[:3] - return cr + # def __func_clean_up(gpt_response, prompt=""): + # cr = gpt_response.strip() + # if len(cr) > 3: + # cr = cr[:3] + # return cr - def __func_validate(gpt_response, prompt=""): - try: - __func_clean_up(gpt_response, prompt="") - if len(gpt_response) == 0: - return False - except: return False - return True + # def __func_validate(gpt_response, prompt=""): + # try: + # __func_clean_up(gpt_response, prompt="") + # if len(gpt_response) == 0: + # return False + # except: return False + # return True def get_fail_safe(): fs = "😋" @@ -636,27 +550,31 @@ def __chat_func_clean_up(gpt_response, prompt=""): ############ def __chat_func_validate(gpt_response, prompt=""): ############ try: - __func_clean_up(gpt_response, prompt="") + __chat_func_clean_up(gpt_response, prompt="") if len(gpt_response) == 0: return False except: return False return True - return True - print ("asdhfapsh8p9hfaiafdsi;ldfj as DEBUG 4") ######## - gpt_param = {"engine": "text-davinci-002", "max_tokens": 15, - "temperature": 0, "top_p": 1, "stream": False, - "frequency_penalty": 0, "presence_penalty": 0, "stop": None} - prompt_template = "persona/prompt_template/v3_ChatGPT/generate_pronunciatio_v1.txt" ######## + # print ("asdhfapsh8p9hfaiafdsi;ldfj as DEBUG 4") ######## + # gpt_param = {"engine": "text-davinci-002", "max_tokens": 15, + # "temperature": 0, "top_p": 1, "stream": False, + # "frequency_penalty": 0, "presence_penalty": 0, "stop": None} + # prompt_template = "persona/prompt_template/v3_ChatGPT/generate_pronunciatio_v1.txt" ######## prompt_input = create_prompt_input(action_description) ######## - prompt = generate_prompt(prompt_input, prompt_template) - example_output = "🛁🧖‍♀️" ######## - special_instruction = "The value for the output must ONLY contain the emojis." ######## - fail_safe = get_fail_safe() - output = ChatGPT_safe_generate_response(prompt, example_output, special_instruction, 3, fail_safe, - __chat_func_validate, __chat_func_clean_up, True) - if output != False: - return output, [output, prompt, gpt_param, prompt_input, fail_safe] + # prompt = generate_prompt(prompt_input, prompt_template) + # example_output = "🛁🧖‍♀️" ######## + # special_instruction = "The value for the output must ONLY contain the emojis." ######## + # fail_safe = get_fail_safe() + output = skill["generate_pronunciatio"](prompt_input) + if __chat_func_validate(output): + return output + else: + return get_fail_safe() + # output = ChatGPT_safe_generate_response(prompt, example_output, special_instruction, 3, fail_safe, + # __chat_func_validate, __chat_func_clean_up, True) + # if output != False: + # return output, [output, prompt, gpt_param, prompt_input, fail_safe] # ChatGPT Plugin =========================================================== @@ -760,7 +678,7 @@ def get_fail_safe(persona): prompt = generate_prompt(prompt_input, prompt_template) fail_safe = get_fail_safe(persona) ######## output = safe_generate_response(prompt, gpt_param, 5, fail_safe, - __func_validate, __func_clean_up) + __func_validate, __func_clean_up, override_deprecated=True) output = (persona.name, output[0], output[1]) if debug or verbose: @@ -830,7 +748,7 @@ def __chat_func_validate(gpt_response, prompt=""): ############ special_instruction = "The output should ONLY contain the phrase that should go in ." ######## fail_safe = get_fail_safe(act_game_object) ######## output = ChatGPT_safe_generate_response(prompt, example_output, special_instruction, 3, fail_safe, - __chat_func_validate, __chat_func_clean_up, True) + __chat_func_validate, __chat_func_clean_up, True, override_deprecated=True) if output != False: return output, [output, prompt, gpt_param, prompt_input, fail_safe] # ChatGPT Plugin =========================================================== diff --git a/reverie/backend_server/persona/prompt_template/v4_sk/action_location_object_v1/skprompt.txt b/reverie/backend_server/persona/prompt_template/v4_sk/action_location_object_v1/skprompt.txt index bf75c1897a..e6c6d21b37 100644 --- a/reverie/backend_server/persona/prompt_template/v4_sk/action_location_object_v1/skprompt.txt +++ b/reverie/backend_server/persona/prompt_template/v4_sk/action_location_object_v1/skprompt.txt @@ -10,7 +10,21 @@ Variables: !! -- Persona's current sector ### -!! is in {!!} in !!. -!! is going to !! that has ONLY the following areas: {!!} +Jane Anderson is in kitchen in Jane Anderson's house. +Jane Anderson is going to Jane Anderson's house that has the following areas: {kitchen, bedroom, bathroom} Stay in the current area if the activity can be done there. Never go into other people's rooms unless necessary. -!! is !!. For !!, !! should go to the following area in !!: { \ No newline at end of file +For cooking, Jane Anderson should go to the following area in Jane Anderson's house: +Answer: {kitchen} +--- +Tom Watson is in common room in Tom Watson's apartment. +Tom Watson is going to Hobbs Cafe that has the following areas: {cafe} +Stay in the current area if the activity can be done there. Never go into other people's rooms unless necessary. +For getting coffee, Tom Watson should go to the following area in Hobbs Cafe: +Answer: {cafe} +--- + +!! is going to !! that has the following areas: {!!} +* Stay in the current area if the activity can be done there. +* NEVER go into other people's rooms unless necessary. +!! is !!. For !!, !! should go to the following area in !! (MUST pick one of {!!}): +Answer: \ No newline at end of file diff --git a/reverie/backend_server/persona/prompt_template/v4_sk/action_location_sector_v2/skprompt.txt b/reverie/backend_server/persona/prompt_template/v4_sk/action_location_sector_v2/skprompt.txt index 586381f5b2..6b992e2743 100644 --- a/reverie/backend_server/persona/prompt_template/v4_sk/action_location_sector_v2/skprompt.txt +++ b/reverie/backend_server/persona/prompt_template/v4_sk/action_location_sector_v2/skprompt.txt @@ -19,4 +19,6 @@ Stay in the current area if the activity can be done there. Only go out if the a Area Options Available (Class label): {!!} -Classification Task: !! is !! as a part of !!. Pick one of the choices given in the Area options that !! should go to. \ No newline at end of file +Classification Task: !! is !! as a part of !!. Pick one of the choices given in the Area options that !! should go to. + +Answer without any prelude, only include the area name in the curly brackets, e.g., {kitchen}, and end your answer immediately. \ No newline at end of file diff --git a/reverie/backend_server/persona/prompt_template/v4_sk/task_decomp_v3/config.json b/reverie/backend_server/persona/prompt_template/v4_sk/task_decomp_v3/config.json index 170e5a84da..15433ad78f 100644 --- a/reverie/backend_server/persona/prompt_template/v4_sk/task_decomp_v3/config.json +++ b/reverie/backend_server/persona/prompt_template/v4_sk/task_decomp_v3/config.json @@ -1,10 +1,10 @@ { "schema": 1, "type": "completion", - "description": "Generate 1-2 emoji representing the given action", + "description": "Generates a detailed breakdown of subtasks for a given task, performed by a specific persona within a specified time range.", "completion": { "max_tokens": 1000, - "temperature": 0, + "temperature": 0.5, "top_p": 1, "frequency_penalty": 0, "presence_penalty": 0 diff --git a/reverie/backend_server/persona/prompt_template/v4_sk/task_decomp_v3/skprompt.txt b/reverie/backend_server/persona/prompt_template/v4_sk/task_decomp_v3/skprompt.txt index b1902697bc..02cb5e56f7 100644 --- a/reverie/backend_server/persona/prompt_template/v4_sk/task_decomp_v3/skprompt.txt +++ b/reverie/backend_server/persona/prompt_template/v4_sk/task_decomp_v3/skprompt.txt @@ -1,18 +1,5 @@ -task_decomp_v2.txt +Let's perform task decomposition. Here's an example of how it can be done: -Variables: -!! -- Commonset -!! -- Surrounding schedule description -!! -- Persona first name -!! -- Persona first name -!! -- Current action -!! -- curr time range -!! -- Current action duration in min -!! -- Persona first names - -### -Describe subtasks in 5 min increments. ---- Name: Kelly Bronson Age: 35 Backstory: Kelly always wanted to be a teacher, and now she teaches kindergarten. During the week, she dedicates herself to her students, but on the weekends, she likes to try out new restaurants and hang out with friends. She is very warm and friendly, and loves caring for others. @@ -21,7 +8,7 @@ Location: Kelly is in an older condo that has the following areas: {kitchen, bed Currently: Kelly is a teacher during the school year. She teaches at the school but works on lesson plans at home. She is currently living alone in a single bedroom condo. Daily plan requirement: Kelly is planning to teach during the morning and work from home in the afternoon.s -Today is Saturday May 10. From 08:00am ~09:00am, Kelly is planning on having breakfast, from 09:00am ~ 12:00pm, Kelly is planning on working on the next day's kindergarten lesson plan, and from 12:00 ~ 13pm, Kelly is planning on taking a break. +Today is Saturday May 10. From 08:00am ~ 09:00am, Kelly is planning on having breakfast, from 09:00am ~ 12:00pm, Kelly is planning on working on the next day's kindergarten lesson plan, and from 12:00 ~ 13pm, Kelly is planning on taking a break. In 5 min increments, list the subtasks Kelly does when Kelly is working on the next day's kindergarten lesson plan from 09:00am ~ 12:00pm (total duration in minutes: 180): 1) Kelly is reviewing the kindergarten curriculum standards. (duration in minutes: 15, minutes left: 165) 2) Kelly is brainstorming ideas for the lesson. (duration in minutes: 30, minutes left: 135) @@ -32,7 +19,11 @@ In 5 min increments, list the subtasks Kelly does when Kelly is working on the n 7) Kelly is making final changes to the lesson plan. (duration in minutes: 15, minutes left: 15) 8) Kelly is printing the lesson plan. (duration in minutes: 10, minutes left: 5) 9) Kelly is putting the lesson plan in her bag. (duration in minutes: 5, minutes left: 0) ---- +/END + +Now, let's consider {{$firstname}}, who is about to perform the task "{{$task}}". + {{$commonset}} {{$surrounding_schedule}} -In 5 min increments, list the subtasks {{$firstname}} does when {{$firstname}} is {{$action}} from {{$time_range}} (total duration in minutes {{$duration}}). \ No newline at end of file + +In 5 min increments, list the subtasks {{$firstname}} does when {{$firstname}} is performing a task "{{$task}}" from {{$time_range}} (total duration in minutes {{$duration}}). \ No newline at end of file diff --git a/reverie/backend_server/reverie.py b/reverie/backend_server/reverie.py index 36ff8d06fc..f9af76f2a1 100644 --- a/reverie/backend_server/reverie.py +++ b/reverie/backend_server/reverie.py @@ -611,7 +611,10 @@ def open_server_in_event_loop(self): self.loop = asyncio.new_event_loop() self.loop.reverie_server = self asyncio.set_event_loop(self.loop) - self.loop.run_until_complete(self.open_server()) + try: + self.loop.run_until_complete(self.open_server()) + finally: + self.loop.close() if __name__ == '__main__': # rs = ReverieServer("base_the_ville_isabella_maria_klaus",