llmp.components.generator.concurrent.AsyncGenerator

class llmp.components.generator.concurrent.AsyncGenerator(job: JobRecord, job_settings: dict = None, num_runs: int = 5, **kwargs)[source]

Generates a job multiple times asynchronous.

generate()[source]

generate an output based on the job + job_setting and input data.

run_engines(async)[source]

run the engines in parallel with identical job setup. This is an async method so it can be used with asyncio.gather()

Initialize the generator with a job and job settings.

Parameters
  • job – JobRecord

  • job_settings – dict

  • num_runs – int

Attributes

verification_type

Return the validation type for the generator.

Methods

__init__(job[, job_settings, num_runs])

Initialize the generator with a job and job settings.

generate(input_data, **kwargs)

Generate an output based on the job + job_setting and input data.

log_generation(input_object, ...)

Log the generation result.

run_engines(input_data, **kwargs)

Run the engines in parallel with identical job setup.

__init__(job: JobRecord, job_settings: dict = None, num_runs: int = 5, **kwargs)[source]

Initialize the generator with a job and job settings.

Parameters
  • job – JobRecord

  • job_settings – dict

  • num_runs – int

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

Generate an output based on the job + job_setting and input data.

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

async run_engines(input_data: Union[dict, list[dict]], **kwargs) list[Tuple[dict, dict]][source]

Run the engines in parallel with identical job setup.

Return a list of Tuple[output, run_metrics] for each run.