InstructionProposalSignature¶
gepa.strategies.instruction_proposal.InstructionProposalSignature()
dataclass
¶
Bases: Signature
Attributes¶
default_prompt_template = "I provided an assistant with the following instructions to perform a task for me:\n```\n<curr_param>\n```\n\nThe following are examples of different task inputs provided to the assistant along with the assistant's response for each of them, and some feedback on how the assistant's response could be better:\n```\n<side_info>\n```\n\nYour task is to write a new instruction for the assistant.\n\nRead the inputs carefully and identify the input format and infer detailed task description about the task I wish to solve with the assistant.\n\nRead all the assistant responses and the corresponding feedback. Identify all niche and domain specific factual information about the task and include it in the instruction, as a lot of it may not be available to the assistant in the future. The assistant may have utilized a generalizable strategy to solve the task, if so, include that in the instruction as well.\n\nProvide the new instructions within ``` blocks."
class-attribute
instance-attribute
¶
input_keys: list[str] = ['current_instruction_doc', 'dataset_with_feedback', 'prompt_template']
class-attribute
¶
output_keys: list[str] = ['new_instruction']
class-attribute
¶
adapter: SignatureAdapter | None = _INSTRUCTION_PROPOSAL_ADAPTER
class-attribute
¶
reasoning_tags: tuple[str, ...] = ('think',)
class-attribute
¶
prompt_template: str
class-attribute
¶
Methods:¶
validate_prompt_template(prompt_template: str | None) -> None
classmethod
¶
Source code in gepa/strategies/instruction_proposal.py
prompt_renderer(input_dict: Mapping[str, Any]) -> str | list[dict[str, Any]]
classmethod
¶
Source code in gepa/strategies/instruction_proposal.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
output_extractor(lm_out: str) -> dict[str, str]
classmethod
¶
Compatibility boundary for callers that require a proposal or error.
run(lm: LanguageModel, input_dict: Mapping[str, Any]) -> dict[str, str]
classmethod
¶
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). |