Skip to content

Handling prompts with different placeholder names #242

@gordon-lim

Description

@gordon-lim
# main/examples/llm_prompt_optimization/evaluate_prompts.py

        try:
            formatted_prompt = prompt_template.format(instruction=instruction)
        except KeyError:
            # Handle prompts with different placeholder names
            formatted_prompt = prompt_template.replace("{instruction}", instruction)

The fallback doesn't seem to handle the KeyError. If there's a key error wouldn't it mean that the prompt_template does not contain "{instruction}".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions