Skip to content

Commit

Permalink
add agent role-playing instructions to examples
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 630361661
Change-Id: I7d8ca6fd3a13ac59821b529772d9fa55eb04b263
  • Loading branch information
jzleibo authored and copybara-github committed May 3, 2024
1 parent 7f1ca71 commit 34f1ae3
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 4 deletions.
20 changes: 19 additions & 1 deletion examples/cyberball/cyberball.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,23 @@
" measurements: measurements_lib.Measurements | None = None):\n",
" mem = formative_memory_factory.make_memories(agent_config)\n",
"\n",
" agent_name = agent_config.name\n",
" instructions = generic_components.constant.ConstantComponent(\n",
" state=(\n",
" f'The instructions for how to play the role of {agent_name} are as '\n",
" 'follows. This is a social science experiment studying how well you '\n",
" f'play the role of a character named {agent_name}. The experiment '\n",
" 'is structured as a tabletop roleplaying game (like dungeons and '\n",
" 'dragons). However, in this case it is a serious social science '\n",
" 'experiment and simulation. The goal is to be realistic. It is '\n",
" f'important to play the role of a person like {agent_name} as '\n",
" f'accurately as possible, i.e., by responding in ways that you think '\n",
" f'it is likely a person like {agent_name} would respond, and taking '\n",
" f'into account all information about {agent_name} that you have. '\n",
" 'Always use third-person limited perspective.'\n",
" ),\n",
" name='role playing instructions\\n')\n",
"\n",
" time = generic_components.report_function.ReportFunction(\n",
" name='Current time',\n",
" function=clock.current_time_interval_str,\n",
Expand Down Expand Up @@ -331,7 +348,8 @@
" mem,\n",
" agent_name=agent_config.name,\n",
" clock=clock,\n",
" components=[persona,\n",
" components=[instructions,\n",
" persona,\n",
" plan,\n",
" time,\n",
" current_obs,\n",
Expand Down
20 changes: 19 additions & 1 deletion examples/magic_beans_for_sale.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,23 @@
"\n",
" mem = formative_memory_factory.make_memories(agent_config)\n",
"\n",
" agent_name = agent_config.name\n",
" instructions = generic_components.constant.ConstantComponent(\n",
" state=(\n",
" f'The instructions for how to play the role of {agent_name} are as '\n",
" 'follows. This is a social science experiment studying how well you '\n",
" f'play the role of a character named {agent_name}. The experiment '\n",
" 'is structured as a tabletop roleplaying game (like dungeons and '\n",
" 'dragons). However, in this case it is a serious social science '\n",
" 'experiment and simulation. The goal is to be realistic. It is '\n",
" f'important to play the role of a person like {agent_name} as '\n",
" f'accurately as possible, i.e., by responding in ways that you think '\n",
" f'it is likely a person like {agent_name} would respond, and taking '\n",
" f'into account all information about {agent_name} that you have. '\n",
" 'Always use third-person limited perspective.'\n",
" ),\n",
" name='role playing instructions\\n')\n",
"\n",
" time = generic_components.report_function.ReportFunction(\n",
" name='Current time',\n",
" function=clock.current_time_interval_str,\n",
Expand Down Expand Up @@ -352,7 +369,8 @@
" agent_name=agent_config.name,\n",
" clock=clock,\n",
" verbose=False,\n",
" components=[persona,\n",
" components=[instructions,\n",
" persona,\n",
" summary_obs,\n",
" current_obs,\n",
" time,\n",
Expand Down
20 changes: 19 additions & 1 deletion examples/three_key_questions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,23 @@
"\n",
" mem = formative_memory_factory.make_memories(agent_config)\n",
"\n",
" agent_name = agent_config.name\n",
" instructions = generic_components.constant.ConstantComponent(\n",
" state=(\n",
" f'The instructions for how to play the role of {agent_name} are as '\n",
" 'follows. This is a social science experiment studying how well you '\n",
" f'play the role of a character named {agent_name}. The experiment '\n",
" 'is structured as a tabletop roleplaying game (like dungeons and '\n",
" 'dragons). However, in this case it is a serious social science '\n",
" 'experiment and simulation. The goal is to be realistic. It is '\n",
" f'important to play the role of a person like {agent_name} as '\n",
" f'accurately as possible, i.e., by responding in ways that you think '\n",
" f'it is likely a person like {agent_name} would respond, and taking '\n",
" f'into account all information about {agent_name} that you have. '\n",
" 'Always use third-person limited perspective.'\n",
" ),\n",
" name='role playing instructions\\n')\n",
"\n",
" time = generic_components.report_function.ReportFunction(\n",
" name='Current time',\n",
" function=clock.current_time_interval_str,\n",
Expand Down Expand Up @@ -389,7 +406,8 @@
" agent_name=agent_config.name,\n",
" clock=clock,\n",
" verbose=False,\n",
" components=[persona,\n",
" components=[instructions,\n",
" persona,\n",
" time,\n",
" current_obs,\n",
" goal_metric,\n",
Expand Down
18 changes: 17 additions & 1 deletion examples/village/riverbend_elections.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,22 @@
"\n",
" mem = formative_memory_factory.make_memories(agent_config)\n",
"\n",
" # Build the player.\n",
" agent_name = agent_config.name\n",
" instructions = generic_components.constant.ConstantComponent(\n",
" state=(\n",
" f'The instructions for how to play the role of {agent_name} are as '\n",
" 'follows. This is a social science experiment studying how well you '\n",
" f'play the role of a character named {agent_name}. The experiment '\n",
" 'is structured as a tabletop roleplaying game (like dungeons and '\n",
" 'dragons). However, in this case it is a serious social science '\n",
" 'experiment and simulation. The goal is to be realistic. It is '\n",
" f'important to play the role of a person like {agent_name} as '\n",
" f'accurately as possible, i.e., by responding in ways that you think '\n",
" f'it is likely a person like {agent_name} would respond, and taking '\n",
" f'into account all information about {agent_name} that you have. '\n",
" 'Always use third-person limited perspective.'\n",
" ),\n",
" name='role playing instructions\\n')\n",
"\n",
" time = generic_components.report_function.ReportFunction(\n",
" name='Current time',\n",
Expand Down Expand Up @@ -321,6 +336,7 @@
" clock=clock,\n",
" verbose=True,\n",
" components=[\n",
" instructions,\n",
" identity,\n",
" plan,\n",
" somatic_state,\n",
Expand Down

0 comments on commit 34f1ae3

Please sign in to comment.