Skip to content

Commit

Permalink
Further improve alternative baseline agents
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 699960741
Change-Id: I11ce4f4d38f3d5fd63c1755eb543aae00caab01f
  • Loading branch information
jzleibo authored and copybara-github committed Nov 25, 2024
1 parent 12b7946 commit 7c23be2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 20 deletions.
15 changes: 8 additions & 7 deletions concordia/factory/agent/alternative_basic_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from concordia.associative_memory import formative_memories
from concordia.clocks import game_clock
from concordia.components import agent as agent_components
from concordia.contrib.components.agent import observations_since_last_update
from concordia.contrib.components.agent import situation_representation_via_narrative
from concordia.language_model import language_model
from concordia.memory_bank import legacy_associative_memory
Expand Down Expand Up @@ -83,11 +84,12 @@ def build_agent(
)

observation_label = '\nObservation'
observation = agent_components.observation.Observation(
observation = observations_since_last_update.ObservationsSinceLastUpdate(
model=model,
clock_now=clock.now,
timeframe=clock.get_step_size(),
pre_act_key=observation_label,
logging_channel=measurements.get_channel('Observation').on_next,
logging_channel=measurements.get_channel(
'ObservationsSinceLastUpdate').on_next,
)

situation_representation_label = (
Expand Down Expand Up @@ -131,8 +133,7 @@ def build_agent(
model=model,
components={
_get_class_name(
situation_representation): situation_representation_label,
_get_class_name(time_display): 'The current date/time is'},
situation_representation): situation_representation_label},
num_memories_to_retrieve=10,
pre_act_key=relevant_memories_label,
logging_channel=measurements.get_channel('AllSimilarMemories').on_next,
Expand All @@ -150,11 +151,11 @@ def build_agent(
entity_components = (
# Components that provide pre_act context.
time_display,
observation,
relevant_memories,
self_perception,
situation_representation,
observation,
person_by_situation,
relevant_memories,
)
components_of_agent = {_get_class_name(component): component
for component in entity_components}
Expand Down
10 changes: 6 additions & 4 deletions concordia/factory/agent/alternative_rational_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from concordia.associative_memory import formative_memories
from concordia.clocks import game_clock
from concordia.components import agent as agent_components
from concordia.contrib.components.agent import observations_since_last_update
from concordia.contrib.components.agent import situation_representation_via_narrative
from concordia.language_model import language_model
from concordia.memory_bank import legacy_associative_memory
Expand Down Expand Up @@ -125,11 +126,12 @@ def build_agent(
)

observation_label = '\nObservation'
observation = agent_components.observation.Observation(
observation = observations_since_last_update.ObservationsSinceLastUpdate(
model=model,
clock_now=clock.now,
timeframe=clock.get_step_size(),
pre_act_key=observation_label,
logging_channel=measurements.get_channel('Observation').on_next,
logging_channel=measurements.get_channel(
'ObservationsSinceLastUpdate').on_next,
)

situation_representation_label = (
Expand Down Expand Up @@ -205,8 +207,8 @@ def build_agent(
entity_components = (
# Components that provide pre_act context.
time_display,
observation,
situation_representation,
observation,
options_perception,
best_option_perception,
)
Expand Down
13 changes: 4 additions & 9 deletions concordia/factory/agent/observe_and_summarize_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,12 @@ def build_agent(
)

observation_label = '\nObservation'
observation = agent_components.observation.Observation(
clock_now=clock.now,
timeframe=clock.get_step_size(),
pre_act_key=observation_label,
logging_channel=measurements.get_channel('Observation').on_next,
)
observations_since_last_update.ObservationsSinceLastUpdate(
observation = observations_since_last_update.ObservationsSinceLastUpdate(
model=model,
clock_now=clock.now,
pre_act_key=observation_label,
logging_channel=measurements.get_channel('Observation').on_next,
logging_channel=measurements.get_channel(
'ObservationsSinceLastUpdate').on_next,
)

situation_representation_label = (
Expand Down Expand Up @@ -118,8 +113,8 @@ def build_agent(
# Components that provide pre_act context.
instructions,
time_display,
observation,
situation_representation,
observation,
)
components_of_agent = {_get_class_name(component): component
for component in entity_components}
Expand Down

0 comments on commit 7c23be2

Please sign in to comment.