evoproc_procedures.ollama

Ollama-backed query helpers for structured procedure generation and repair.

These functions implement the QueryFn/RepairFn style expected by the GA core:
  • query(…): general-purpose text → JSON call, optionally constrained by a JSON Schema.

  • hard_query(…): strict/low-temperature variant useful for repair passes.

  • query_repair_structured(…): loop that validates a procedure JSON and issues

minimal repair prompts until it passes (or exhausts retries). - create_and_validate_procedure_structured(…): one-shot convenience that creates a procedure JSON for a task and validates/repairs it before returning.

All functions are pure client wrappers around ollama.generate. They return strings (for raw model responses) or dicts (for JSON payloads).

Functions

create_and_validate_procedure_ollama(idx, ...)

Convenience creator that uses Ollama under the hood.

hard_query(prompt, model[, fmt, seed])

Call Ollama with strict decoding settings.

query(prompt, model[, fmt, seed])

General-purpose Ollama call.

repair_fn_ollama(proc, model)

Adapter for GA's repair_fn(proc, model) using Ollama backend.

run_full_procedure_ollama(idx, question, *)

Ollama-backed 'create → repair → execute' helper for one question.

evoproc_procedures.ollama.query(prompt, model, fmt=None, seed=1234)[source]

General-purpose Ollama call.

This is your default structured call. When fmt is supplied, Ollama will attempt to return an object matching that schema.

Parameters:
  • prompt (str) – Full prompt text.

  • model (str) – Ollama model name.

  • fmt (Optional[Dict[str, Any]]) – Optional JSON Schema dict used as a response format.

  • seed (Optional[int]) – Optional random seed for reproducibility.

Return type:

str

Returns:

Raw string response (often JSON text when fmt is provided).

evoproc_procedures.ollama.hard_query(prompt, model, fmt=None, seed=1234)[source]

Call Ollama with strict decoding settings.

Use this when you need the model to adhere tightly to fmt (a JSON Schema), e.g., repair steps. Temperature is set to 0.

Parameters:
  • prompt (str) – Full prompt text.

  • model (str) – Ollama model name (e.g., "gemma3:latest").

  • fmt (Optional[Dict[str, Any]]) – Optional JSON Schema dict for structured output.

  • seed (Optional[int]) – Optional random seed for reproducibility.

Return type:

str

Returns:

The raw string response (usually JSON text when fmt is provided).

evoproc_procedures.ollama.repair_fn_ollama(proc, model)[source]

Adapter for GA’s repair_fn(proc, model) using Ollama backend.

Return type:

Dict[str, Any]

Parameters:
evoproc_procedures.ollama.create_and_validate_procedure_ollama(idx, task, *, model, seed=1234, print_diagnostics=False)[source]

Convenience creator that uses Ollama under the hood.

Return type:

Dict[str, Any]

Parameters:
evoproc_procedures.ollama.run_full_procedure_ollama(idx, question, *, model='gemma3:latest', answer_schema_name='gsm', run_steps_fn=None, seed=1234, print_diagnostics=False)[source]

Ollama-backed ‘create → repair → execute’ helper for one question.

Args mirror the backend-agnostic version; this just wires in the Ollama query and fetches the answer schema by name.

Return type:

Tuple[Dict[str, Any], Dict[str, Any]]

Parameters:
  • idx (int)

  • question (str)

  • model (str)

  • answer_schema_name (str)

  • seed (int | None)

  • print_diagnostics (bool)