Skip to content

Signature

gepa.proposer.reflective_mutation.base.Signature() dataclass

Attributes

prompt_template: str class-attribute

input_keys: list[str] class-attribute

output_keys: list[str] class-attribute

Functions

prompt_renderer(input_dict: Mapping[str, Any]) -> str | list[dict[str, Any]] classmethod

Source code in gepa/proposer/reflective_mutation/base.py
@classmethod
def prompt_renderer(cls, input_dict: Mapping[str, Any]) -> str | list[dict[str, Any]]:
    raise NotImplementedError

output_extractor(lm_out: str) -> dict[str, str] classmethod

Source code in gepa/proposer/reflective_mutation/base.py
@classmethod
def output_extractor(cls, lm_out: str) -> dict[str, str]:
    raise NotImplementedError

run(lm: LanguageModel, input_dict: Mapping[str, Any]) -> dict[str, str] classmethod

Source code in gepa/proposer/reflective_mutation/base.py
@classmethod
def run(cls, lm: LanguageModel, input_dict: Mapping[str, Any]) -> dict[str, str]:
    full_prompt = cls.prompt_renderer(input_dict)
    lm_res = lm(full_prompt)
    lm_out = lm_res.strip()
    return cls.output_extractor(lm_out)

run_with_metadata(lm: LanguageModel, input_dict: Mapping[str, Any]) -> tuple[dict[str, str], str | list[dict[str, Any]], str] classmethod

Like run(), but also returns the rendered prompt and raw LM output.

Returns:

Type Description
tuple[dict[str, str], str | list[dict[str, Any]], str]

A tuple of (extracted_output, rendered_prompt, raw_lm_output).

Source code in gepa/proposer/reflective_mutation/base.py
@classmethod
def run_with_metadata(
    cls, lm: LanguageModel, input_dict: Mapping[str, Any]
) -> tuple[dict[str, str], str | list[dict[str, Any]], str]:
    """Like ``run()``, but also returns the rendered prompt and raw LM output.

    Returns:
        A tuple of (extracted_output, rendered_prompt, raw_lm_output).
    """
    full_prompt = cls.prompt_renderer(input_dict)
    lm_res = lm(full_prompt)
    lm_out = lm_res.strip()
    return cls.output_extractor(lm_out), full_prompt, lm_out