llmp.data_model.job_record.JobRecord

class llmp.data_model.job_record.JobRecord[source]

Bases: BaseModel

A representation of a job in the LLMP system.

The JobRecord class captures the core attributes of a job, its associated examples, and its history.

idx

A unique identifier for the job.

Type

UUID4

job_name

The name of the job, if provided.

Type

Optional[str]

version

The current version of the job, indicating updates or modifications.

Type

int

state

The current state of the job, indicating if it is active or inactive.

Type

int

is_explicit

A flag indicating if the job is explicitly defined.

Type

bool

input_model

The input schema model.

Type

InputModel

output_model

The output schema model.

Type

OutputModel

example_records

A list of example records associated with the job.

Type

List[ExampleRecord]

instruction

An optional instruction or description for the job.

Type

Optional[str]

metrics

Metrics associated with the job, if available.

Type

Optional[Dict[str, float]]

version_history

A dictionary capturing the history of versions for the job.

Type

Dict[int, Any]

event_log

A log of actions performed on the job.

Type

list[str]

generation_log

A history of generations associated with the job.

Type

list[dict]

convert_keys_to_int(cls, item) Dict[int, Any][source]

Convert string keys to integers for version history dictionary.

parse_examples() List[Example]

Retrieve the parsed examples from the job’s example records.

add_version(instruction

str, examples: List[ExampleRecord], metrics: Dict[str, float]): Update the job to a new version with new instruction, examples, and metrics.

add_action(action

str, version: int = None): Log an action in the job’s action history.

add_generation_log(generation_log

dict): Log a generation in the job’s generation history.

rollback(version

int): Rollback the job to a specific previous version.

to_template() str

Convert the job into a template for LLM generation.

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

param config: dict [Optional]
param event_log: list[llmp.data_model.events.Event] [Optional]
param example_records: List[llmp.data_model.example_record.ExampleRecord] [Optional]
param generation_log: list[dict] [Optional]
param idx: str [Optional]
param input_model: structgenie.components.input_output.input_model.InputModel [Required]
param instruction: Optional[str] = None
param is_explicit: bool = False
param job_name: Optional[str] = None
param output_model: structgenie.components.input_output.output_model.OutputModel [Required]
param version: int = 0
param version_history: Dict[int, dict] [Optional]
add_example(example_record: ExampleRecord, **kwargs) None[source]

Add an example to the job.

add_version(instruction: str, examples: List[ExampleRecord], metrics: Dict[str, float] = None) None[source]

Add a new version to the job.

classmethod construct(_fields_set: Optional[SetStr] = None, **values: Any) Model

Creates a new model setting __dict__ and __fields_set__ from trusted or pre-validated data. Default values are respected, but no other validation is performed. Behaves as if Config.extra = ‘allow’ was set since it adds all passed values

classmethod convert_keys_to_int(item)[source]
copy(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, update: Optional[DictStrAny] = None, deep: bool = False) Model

Duplicate a model, optionally choose which fields to include, exclude and change.

Parameters
  • include – fields to include in new model

  • exclude – fields to exclude from new model, as with values this takes precedence over include

  • update – values to change/add in the new model. Note: the data is not validated before creating the new model: you should trust this data

  • deep – set to True to make a deep copy of the model

Returns

new model instance

dict(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False) DictStrAny

Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.

classmethod from_orm(obj: Any) Model
get_examples(example_ids: list = None)[source]

Parse the examples to the correct version.

json(*, include: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, exclude: Optional[Union[AbstractSetIntStr, MappingIntStrAny]] = None, by_alias: bool = False, skip_defaults: Optional[bool] = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, encoder: Optional[Callable[[Any], Any]] = None, models_as_dict: bool = True, **dumps_kwargs: Any) unicode

Generate a JSON representation of the model, include and exclude arguments as per dict().

encoder is an optional function to supply as default to json.dumps(), other arguments as per json.dumps().

log_event(event: Event)[source]

Add an event to the job.

log_generation(input_object: dict, output_object: dict, event_metric: dict, job_settings: dict = None) Event[source]

Add a generation to the job.

classmethod parse_file(path: Union[str, Path], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model
classmethod parse_obj(obj: Any) Model
classmethod parse_raw(b: Union[str, bytes], *, content_type: unicode = None, encoding: unicode = 'utf8', proto: Protocol = None, allow_pickle: bool = False) Model
rollback(version: int) None[source]

Rollback the job to a previous version.

classmethod schema(by_alias: bool = True, ref_template: unicode = '#/definitions/{model}') DictStrAny
classmethod schema_json(*, by_alias: bool = True, ref_template: unicode = '#/definitions/{model}', **dumps_kwargs: Any) unicode
classmethod update_forward_refs(**localns: Any) None

Try to update ForwardRefs on fields based on this Model, globalns and localns.

classmethod validate(value: Any) Model