Skip to content

Commit

Permalink
Update to_natural_text for empty background and update test cases for…
Browse files Browse the repository at this point in the history
… stranger relations
  • Loading branch information
bugsz committed Feb 5, 2024
1 parent 3beca20 commit fd6700a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
13 changes: 12 additions & 1 deletion examples/fix_missing_episodes_with_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 8 additions & 2 deletions sotopia/messages/message_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
"""
Expand Down
2 changes: 2 additions & 0 deletions tests/renderers/test_xml_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

0 comments on commit fd6700a

Please sign in to comment.