def METHOD_NAME(cls, values):
    format_dict = {}
    input_variables = extract_input_variables_from_prompt(values["template"])
    if values.get("ai_prefix_value", None) is None:
        values["ai_prefix_value"] = values["memory"].ai_prefix
    for key in input_variables:
        new_value = values.get(key, f"{{{key}}}")
        format_dict[key] = new_value
        if key == values.get("ai_prefix_value", None):
            values["memory"].ai_prefix = new_value
    values["template"] = values["template"].format(**format_dict)
    values["template"] = values["template"]
    values["input_variables"] = extract_input_variables_from_prompt(
        values["template"]
    )
    values["prompt"].template = values["template"]
    values["prompt"].input_variables = values["input_variables"]
    return values