def create_model_invocation_pipeline()

in src/fmeval/eval_algorithms/util.py [0:0]


def create_model_invocation_pipeline(model: ModelRunner, prompt_template: str) -> TransformPipeline:
    """Create a transform pipeline for performing the standard action of invoking a model on a prompt.

    :param model: The model to be invoked.
    :param prompt_template: The template used for constructing prompts (out of raw inputs)
        that will be fed to the model.
    :returns: A TransformPipeline instance containing a GeneratePrompt transform that uses `prompt_template`
        and a GetModelOutputs transform for invoking the model on the generated prompts.
    """
    gen_prompt = GeneratePrompt(
        input_keys=[DatasetColumns.MODEL_INPUT.value.name],
        output_keys=[DatasetColumns.PROMPT.value.name],
        prompt_template=prompt_template,
    )
    get_model_outputs = GetModelOutputs(
        input_to_output_keys={DatasetColumns.PROMPT.value.name: [DatasetColumns.MODEL_OUTPUT.value.name]},
        model_runner=model,
    )
    return TransformPipeline([gen_prompt, get_model_outputs])