def build(
      self,
      model: language_model.LanguageModel,
      memory_bank: basic_associative_memory.AssociativeMemoryBank,
  ) -> entity_agent_with_logging.EntityAgentWithLogging:
    """Build an agent.

    Args:
      model: The language model to use.
      memory_bank: The agent's memory_bank object.

    Returns:
      An agent.
    """

    agent_name = self.params.get('name', 'Alice')

    custom_instructions = self.params.get('custom_instructions', None)
    if custom_instructions is not None:
      instructions = agent_components.constant.Constant(
          state=DEFAULT_INSTRUCTIONS,
          pre_act_label=DEFAULT_INSTRUCTIONS_PRE_ACT_LABEL,
      )
    else:
      instructions = agent_components.instructions.Instructions(
          agent_name=agent_name,
          pre_act_label=DEFAULT_INSTRUCTIONS_PRE_ACT_LABEL,
      )

    observation_to_memory = agent_components.observation.ObservationToMemory()

    observation_label = '\nObservation'
    observation = agent_components.observation.LastNObservations(
        history_length=100, pre_act_label=observation_label
    )

    simulation_perception = agent_components.question_of_recent_memories.QuestionOfRecentMemories(
        model=model,
        pre_act_label=(
            '\nQuestion: What kind of simulation does the user want? Give'
            ' location, time, style and scope.\nAnswer'
        ),
        question=(
            '\nQuestion: What kind of simulation does the user want?\nAnswer'
        ),
        answer_prefix='\nSimulation:',
        add_to_memory=False,
    )

    actors_perception = agent_components.question_of_recent_memories.QuestionOfRecentMemories(
        model=model,
        pre_act_label=(
            '\nQuestion: What actors are required for the simulation? List'
            ' their names, backgrounds and goals.\nAnswer'
        ),
        question=(
            '\nQuestion: What actors are required for the simulation?\nAnswer'
        ),
        answer_prefix='\nActors:',
        add_to_memory=False,
    )

    components_of_agent = {
        DEFAULT_INSTRUCTIONS_COMPONENT_KEY: instructions,
        'observation_to_memory': observation_to_memory,
        'simulation_perception': simulation_perception,
        'actors_perception': actors_perception,
        agent_components.observation.DEFAULT_OBSERVATION_COMPONENT_KEY: (
            observation
        ),
        agent_components.memory.DEFAULT_MEMORY_COMPONENT_KEY: (
            agent_components.memory.AssociativeMemory(memory_bank=memory_bank)
        ),
    }

    extra_components = self.params.get('extra_components', {})
    # check if extra_components is a mapping
    if not isinstance(extra_components, Mapping):
      raise ValueError('extra_components must be a mapping')

    if extra_components:
      for component_name, component in extra_components.items():
        components_of_agent[component_name] = component

    component_order = list(components_of_agent.keys())

    if self.params.get('goal', ''):
      goal_key = DEFAULT_GOAL_COMPONENT_KEY
      goal = agent_components.constant.Constant(
          state=self.params.get('goal', ''),
          pre_act_label='Overarching goal',
      )
      components_of_agent[goal_key] = goal
      # Place goal after the instructions.
      component_order.insert(1, goal_key)
    act_component = agent_components.concat_act_component.ConcatActComponent(
        model=model,
        component_order=component_order,
        prefix_entity_name=False,
    )

    agent = entity_agent_with_logging.EntityAgentWithLogging(
        agent_name=agent_name,
        act_component=act_component,
        context_components=components_of_agent,
    )

    return agent
Build an agent.

    Args:
      model: The language model to use.
      memory_bank: The agent's memory_bank object.

    Returns:
      An agent.
    
concordia/prefabs/configurator/basic.py