def _make_pre_act_value(self) -> str:
    """Returns a representation of the current situation to pre act."""
    agent_name = self.get_entity().name
    current_time = self._clock_now()
    observations = self.get_entity().get_component(
        self._observation_component_key)

    initial_step_thought_chain = ''
    if self._situation_thus_far is None:
      chain_of_thought = interactive_document.InteractiveDocument(self._model)
      chain_of_thought.statement('~~ Creative Writing Assignment ~~')
      if self._declare_entity_as_protagonist:
        chain_of_thought.statement(f'Protagonist: {agent_name}')
      mems = observations.get_pre_act_value()
      chain_of_thought.statement(f'Story fragments and world data:\n{mems}')
      self._add_components_if_any(chain_of_thought)
      chain_of_thought.statement(f'Events continue after {current_time}')
      self._situation_thus_far = chain_of_thought.open_question(
          question=(
              'Narratively summarize the story fragments and world data. Give '
              'special emphasis to atypical features of the setting such as '
              'when and where the story takes place as well as any causal '
              'mechanisms or affordances mentioned in the information '
              'provided. Highlight the goals, personalities, occupations, '
              'skills, and affordances of the named characters and '
              'relationships between them. If any specific numbers were '
              'mentioned then make sure to include them. Use third-person '
              'omniscient perspective.'),
          max_tokens=1000,
          terminators=(),
          question_label='Exercise')
      initial_step_thought_chain = '\n'.join(
          chain_of_thought.view().text().splitlines())

    result = observations.get_pre_act_value() + '\n'
    chain_of_thought = interactive_document.InteractiveDocument(self._model)
    chain_of_thought.statement(f'Context:\n{self._situation_thus_far}')
    self._add_components_if_any(chain_of_thought)
    if self._declare_entity_as_protagonist:
      chain_of_thought.statement(f'Protagonist: {agent_name}')
      chain_of_thought.statement(
          f'Thoughts and memories of {agent_name}:\n{result}'
      )
    else:
      chain_of_thought.statement(f'Notes:\n{result}')
    self._situation_thus_far = chain_of_thought.open_question(
        question=(
            'What situation does the protagonist find themselves in? '
            'Make sure to provide enough detail to give the '
            'reader a comprehensive understanding of the world '
            'inhabited by the protagonist, their affordances in that '
            'world, actions they may be able to take, effects their '
            'actions may produce, and what is currently going on. If any '
            'specific numbers were mentioned then make sure to include them. '
            'Also, make sure to repeat all details of the context that could '
            'ever be relevant, now or in the future.'
        ),
        max_tokens=1000,
        terminators=(),
        question_label='Exercise',
    )
    chain_of_thought.statement(f'The current date and time is {current_time}')

    chain_of_thought_text = '\n'.join(
        chain_of_thought.view().text().splitlines())

    self._logging_channel({
        'Key': self.get_pre_act_label(),
        'Value': self._situation_thus_far,
        'Chain of thought': (initial_step_thought_chain +
                             '\n***\n' +
                             chain_of_thought_text),
    })

    self._previous_time = current_time

    return self._situation_thus_far
Returns a representation of the current situation to pre act.
concordia/contrib/components/agent/situation_representation_via_narrative.py