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

create_direct_prompt(item)

Build a direct Q→A prompt (baseline / ARC-style).

create_execution_prompt(visible_inputs, ...)

Build a prompt to execute a single step with strict JSON output.

create_procedure_prompt(item[, example_prompt])

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).

Parameters:

item (str) – The task text (e.g., question stem or problem statement).

Return type:

str

Returns:

A concise prompt string suitable for a direct answer call.

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:
  • item (str) – Natural-language task to decompose.

  • example_prompt (Optional[str]) – Optional extra hint or in-context example description (kept as a single string you can preformat upstream).

Return type:

str

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_text only, later steps may read any earlier variables (global state), and the final step emits final_answer as 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) – If True, annotate that these outputs constitute the final answer.

Return type:

str

Returns:

A prompt string that instructs the model to return only a JSON object matching schema and containing exactly expected_outputs.