diff --git a/examples/fix_missing_episodes_with_tag.py b/examples/fix_missing_episodes_with_tag.py index f1aa415aa..18de69d68 100644 --- a/examples/fix_missing_episodes_with_tag.py +++ b/examples/fix_missing_episodes_with_tag.py @@ -145,6 +145,7 @@ def get_combo_model_map( bad_gpt4_rewards_count = 0 bad_combo_count = 0 bad_lite_mode_count = 0 + bad_background_count = 0 episodes_to_delete = [] # iterate through episodes @@ -181,6 +182,15 @@ def get_combo_model_map( # bad_lite_mode_count += 1 # continue + # check if the background is present + # if not "lite" in curr_ep.tag: + # concat_text = "\n".join(rendered_ep[:-2]) + # if "'s background" not in concat_text: + # print("Background not found in: ", curr_ep.pk) + # episodes_to_delete.append(curr_ep.pk) + # bad_background_count += 1 + # continue + if len(interaction_list) <= 5: # bad_rewards_count += 1 episodes_to_delete.append(curr_ep.pk) @@ -211,7 +221,8 @@ def get_combo_model_map( # episodes_to_delete.append(curr_ep.pk) bad_combo_count += 1 - print("Bad lite mode count: ", bad_lite_mode_count) + # print("Bad lite mode count: ", bad_lite_mode_count) + # print("Bad background count: ", bad_background_count) # exit(0) print("-" * 20 + "Deleting Bad Combos" + "-" * 20) for ep_pk in episodes_to_delete: diff --git a/sotopia/messages/message_classes.py b/sotopia/messages/message_classes.py index bddcf4e97..c72f28eed 100644 --- a/sotopia/messages/message_classes.py +++ b/sotopia/messages/message_classes.py @@ -56,13 +56,19 @@ class ScriptBackground(Message): def to_natural_language(self) -> str: if self.p1_background or self.p2_background: + p1_background = ( + self.p1_background if self.p1_background else "Unknown" + ) + p2_background = ( + self.p2_background if self.p2_background else "Unknown" + ) # Not using AND, since in stranger relation the background is not visible return format_docstring( f"""Here is the context of this interaction: Scenario: {self.scenario} Participants: {self.p1_name} and {self.p2_name} - {self.p1_name}'s background: {self.p1_background} - {self.p2_name}'s background: {self.p2_background} + {self.p1_name}'s background: {p1_background} + {self.p2_name}'s background: {p2_background} {self.p1_name}'s goal: {self.p1_goal} {self.p2_name}'s goal: {self.p2_goal} """ diff --git a/tests/renderers/test_xml_renderer.py b/tests/renderers/test_xml_renderer.py index 9152e4ad7..586b35e46 100644 --- a/tests/renderers/test_xml_renderer.py +++ b/tests/renderers/test_xml_renderer.py @@ -92,6 +92,8 @@ def test_renderer_in_env() -> None: obs["John"].last_turn == "Here is the context of this interaction:\n" "Scenario: test\n" "Participants: John and Jane\n" + "John's background: John Doe is a 0-year-old . pronouns. Personality and values description: John's secrets: \n" + "Jane's background: Unknown\n" "John's goal: agent_1's goal\n" "Jane's goal: Unknown" )