def action_spec_parser(next_action_spec_string: str) -> entity_lib.ActionSpec:
  """Parse the next action spec string into an action spec."""
  if 'type: free' in next_action_spec_string:
    splits = next_action_spec_string.split(';;')
    if len(splits) != 2:
      call_to_action = entity_lib.DEFAULT_CALL_TO_ACTION
    else:
      call_to_action = splits[0].split('prompt: ')[1]
    return entity_lib.ActionSpec(
        call_to_action=call_to_action,
        output_type=entity_lib.OutputType.FREE,
    )
  elif (
      'type: choice' in next_action_spec_string
      and 'options: ' in next_action_spec_string
  ):
    splits = next_action_spec_string.split(';;')
    if 'prompt: ' not in next_action_spec_string:
      call_to_action = entity_lib.DEFAULT_CALL_TO_ACTION
    else:
      call_to_action = splits[0].split('prompt: ')[1]
    return entity_lib.ActionSpec(
        call_to_action=call_to_action,
        output_type=entity_lib.OutputType.CHOICE,
        options=tuple(next_action_spec_string.split('options: ')[1].split(',')),
    )
  elif _TYPE_SKIP_THIS_STEP in next_action_spec_string:
    return entity_lib.skip_this_step_action_spec()
  else:
    raise RuntimeError(
        'Invalid next action spec string: \"{}\"'.format(
            next_action_spec_string))
Parse the next action spec string into an action spec.
concordia/environment/engine.py