evoproc_procedures.pipelines¶
Functions
|
Create → repair → execute a structured procedure for one task. |
- evoproc_procedures.pipelines.run_full_procedure_structured(idx, question, *, model, query_fn, run_steps_fn, answer_schema, seed=1234, print_diagnostics=False)[source]¶
Create → repair → execute a structured procedure for one task.
Steps¶
Build a creation prompt (global-state constraints) for question.
Ask the LLM (via query_fn) to emit a Procedure JSON that validates Procedure.model_json_schema().
Iteratively repair with repair_procedure_structured(…) until it validates.
Execute the procedure with run_steps_fn to obtain the final answer/state.
- type idx:
- param idx:
An index for logging (e.g., dataset row).
- type question:
- param question:
Natural-language task text (fed as problem_text).
- type model:
- param model:
Backend model name (passed through to query_fn).
- type query_fn:
Callable[[str,str,Optional[Dict[str,Any]],Optional[int]],str]- param query_fn:
Callable (prompt, model, fmt, seed) -> str. Provide your backend.
- type run_steps_fn:
- param run_steps_fn:
- Your executor. Two common signatures:
run_steps_fn(proc, question, answer_schema, model, print_bool=False) -> state
run_steps_fn(proc, *, inputs: dict, answer_schema: dict, model: str) -> state
This wrapper will try (a) first, then (b).
- type answer_schema:
- param answer_schema:
JSON Schema for the final answer object (e.g., GSM/ARC).
- type seed:
- param seed:
Optional seed for determinism (if backend supports it).
- type print_diagnostics:
- param print_diagnostics:
If True, prints repair diagnostics each iteration.
- returns:
Validated procedure JSON and the execution state (should include the final answer).
- rtype:
(procedure_json, state_dict)
- raises ValueError:
If the model response cannot be parsed as JSON.
- raises RuntimeError:
If the procedure cannot be repaired to pass validation.