llmp.components.generator.simple.Generator

class llmp.components.generator.simple.Generator(job: JobRecord, job_settings: dict = None, **kwargs)[source]

Basic generator that runs a job once.

This generator is used to run a job once and return the parsed output according job’s output_model.

Initialize the generator with a job and job settings.

Parameters
  • job (JobRecord) – the job to be executed

  • job_settings (dict) – the job settings to be used

  • **kwargs – any - passed to load_engine_from_job

Attributes

verification_type

Return the validation type for the generator.

Methods

__init__(job[, job_settings])

Initialize the generator with a job and job settings.

generate(input_data, **kwargs)

Generate an output based on the job and input data.

log_generation(input_object, ...)

Log the generation result.

__init__(job: JobRecord, job_settings: dict = None, **kwargs)

Initialize the generator with a job and job settings.

Parameters
  • job (JobRecord) – the job to be executed

  • job_settings (dict) – the job settings to be used

  • **kwargs – any - passed to load_engine_from_job

generate(input_data: dict, **kwargs) Tuple[dict, dict][source]

Generate an output based on the job and input data.

loads the engine from the job and runs it with the input data.

Parameters
  • input_data (dict) – Input data for the job. With prompt placeholder as keys

  • **kwargs – any - passed to engine.run() method

log_generation(input_object: dict, generated_object: dict, run_metrics: dict, **kwargs) Optional[Event]

Log the generation result.

Parameters
  • input_object (dict) – the input object

  • generated_object (dict) – the generated object

  • run_metrics (dict) – the run metrics

  • **kwargs – any - passed to JobRecord.log_generation