def format_prompt(orig_input, exemplar_inputs,
                  exemplar_outputs,
                  config):
  """Constructs a retrieval-augmented input string.

  Args:
    orig_input: Input of the original example.
    exemplar_inputs: Inputs of the exemplars.
    exemplar_outputs: Outputs of the exemplars.
    config: a FormatterConfig object.

  Returns:
    The retrieval-augmented input string.
  """
  input_parts = []
  if not config.orig_input_at_end:
    input_parts.append(config.orig_input_prefix + orig_input)
  for i, (ex_in, ex_out) in enumerate(zip(exemplar_inputs, exemplar_outputs)):
    input_prefix = config.exemplar_input_prefix.replace("{i}", str(i + 1))
    output_prefix = config.exemplar_output_prefix.replace("{i}", str(i + 1))
    input_parts.append(input_prefix + ex_in + output_prefix + ex_out)
  if config.orig_input_at_end:
    input_parts.append(config.orig_input_prefix + orig_input)
  return config.exemplar_separator.join(input_parts)