evoproc_procedures.prompts¶
Prompt builders for procedure creation and step execution.
These helpers produce LLM prompts used by the GA scaffold and your runners:
create_direct_prompt()— a simple “ask the question directly” prompt (handy for baselines and ARC-style multiple choice).create_procedure_prompt()— asks the model to emit a global-state procedure JSON that validates your Pydantic schema.create_execution_prompt()— runs a single step by showing inputs, the step action, and the required outputs, while reminding the model to return strict JSON conforming to a supplied schema.
All functions are pure string builders and have no network side-effects. They are safe to use in tests and with any LLM backend.
Example
>>> from evoproc_procedures.prompts import create_procedure_prompt
>>> p = create_procedure_prompt("Natalia sold clips to 48 friends in April...")
>>> isinstance(p, str)
True
Functions
|
Build a direct Q→A prompt (baseline / ARC-style). |
|
Build a prompt to execute a single step with strict JSON output. |
|
Ask the LLM to synthesize a global-state procedure JSON. |
- evoproc_procedures.prompts.create_direct_prompt(item)[source]¶
Build a direct Q→A prompt (baseline / ARC-style).
- evoproc_procedures.prompts.create_procedure_prompt(item, example_prompt=None)[source]¶
Ask the LLM to synthesize a global-state procedure JSON.
The model is instructed to return exactly one JSON object that validates the Pydantic schema produced by
uhj_procedures.models.Procedure.- Parameters:
- Return type:
- Returns:
A prompt string suitable for a structured generation call.
Notes
The schema is injected verbatim via
Procedure.model_json_schema().Constraints match your GA scaffold: step 1 uses
problem_textonly, later steps may read any earlier variables (global state), and the final step emitsfinal_answeras a description only.
- evoproc_procedures.prompts.create_execution_prompt(visible_inputs, action, schema, expected_outputs, output_descriptions=None, *, is_final=False)[source]¶
Build a prompt to execute a single step with strict JSON output.
- Parameters:
visible_inputs (
Dict[str,Any]) – The subset of global state the step may read (already extracted variables).action (
str) – The step’s imperative instruction (e.g., “extract the two numbers a and b”).schema (
Dict[str,Any]) – JSON Schema that the output object must validate against (for regular steps use your step-output schema; for the last step you can pass your answer schema, e.g. GSM/ARC).expected_outputs (
Iterable[str]) – Names of keys the model must return in the JSON object.output_descriptions (
Optional[Dict[str,str]]) – Optional mapping of key → human description (shown to the model).is_final (
bool) – IfTrue, annotate that these outputs constitute the final answer.
- Return type:
- Returns:
A prompt string that instructs the model to return only a JSON object matching
schemaand containing exactlyexpected_outputs.