artefactual.preprocessing.BatchRequestOutput#
- class artefactual.preprocessing.BatchRequestOutput(**data)[source]#
Bases:
ResponseModelOne line of an OpenAI Batch output file.
The Batch API returns JSONL – one of these per line – and any OpenAI-compatible server writes the same shape. The completion is always nested under response.body.
custom_id is the only id that identifies the request: id is assigned by the provider, as is response.request_id, and so is the completion’s own id. It is the key every stage joins on.
A failed line carries no usable completion, and completion reports that by returning None. LogProbParser refuses such a line: it emits one row per line, and a dropped row would shift every later response against its label.
Methods
constructcopyReturns a copy of the model.
dictfrom_ormjsonmodel_constructCreates a new instance of the Model class with validated data.
model_copy!!! abstract "Usage Documentation"
model_dump!!! abstract "Usage Documentation"
model_dump_json!!! abstract "Usage Documentation"
model_json_schemaGenerates a JSON schema for a model class.
model_parametrized_nameCompute the class name for parametrizations of generic classes.
model_post_initOverride this method to perform additional initialization after __init__ and model_construct.
model_rebuildTry to rebuild the pydantic-core schema for the model.
model_validateValidate a pydantic model instance.
model_validate_json!!! abstract "Usage Documentation"
model_validate_stringsValidate the given object with string data against the Pydantic model.
parse_fileparse_objparse_rawThe completion this line carries, validated as the format it is.
schemaschema_jsonupdate_forward_refsvalidate- property completion: Any | None#
The completion payload this line carries, or None if it carries none.
None covers every way a line can fail, which failure names: a non-HTTP error, an HTTP status outside 2xx – where the body is an error object rather than a completion – and a missing envelope or body.
- property failure: str | None#
Why this line carries no completion, phrased for an error message.
None when it carries one. The error repr is truncated because it is provider text of no fixed length, and this ends up inside exception messages.
- model_config: ClassVar[ConfigDict] = {'extra': 'ignore', 'from_attributes': True}#
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- payload(kind=<class 'artefactual.preprocessing.response_models.LogprobsMixin'>)[source]#
The completion this line carries, validated as the format it is.
kind narrows the formats accepted: the default is every registered one, a format accepts its own only.
Raises for a line that carries none: dropping a failed line would shift every later response against its label. Filter the failed lines out before parsing, which is where their failure can still be reported against a custom_id.
The body goes through the same formats as a bare completion, so a batch of Responses-API calls parses like any other.
- Raises:
ValueError – If the line failed, naming its custom_id and failure.
TypeError – If the body is neither a chat completion nor a Responses payload.
- Return type:
-
response:
BatchResponseData|None#