def get_shared_memories_and_context(
    model: language_model.LanguageModel,
    rng: random.Random,
) -> tuple[Sequence[str], str]:
  """Return the shared memories and context for all agents and game master."""
  shared_memories = get_world_elements(NUM_BACKGROUND_WORLD_ELEMENTS, rng)
  selected_laudanum_advertisements = get_laudanum_advertisements(
      NUM_LAUDANUM_ADVERTISEMENTS, rng
  )

  today = "Today's newspaper contains the following advertisement: "
  laudanum_today = [
      f'{today}{advert}' for advert in selected_laudanum_advertisements
  ]
  shared_memories += laudanum_today

  # The shared context will be used for the NPC context. It reflects general
  # knowledge and is possessed by all characters.
  shared_context = model.sample_text(
      'Summarize the following passage in a concise and insightful fashion. It '
      'is OK to omit details that seem less important:\n'
      + 'The year is 1870. The place is London.\n'
      + '\nContext:\n'
      + '\n'.join(shared_memories)
      + '\n'
      + 'Summary:'
  )
  return shared_memories, shared_context
Return the shared memories and context for all agents and game master.
examples/deprecated/modular/environment/london_esoteric_market_1870.py