ModelOutput#
- class rapidtools.models.ModelOutput(text: str | None = None, masks: Any | None = None, bounding_boxes: list | None = None, raw_response: Any | None = None, error: str | None = None, retryable: bool = True)[source]#
Bases:
objectA universal container for multimodal AI model outputs.
- Variables:
text (str | None) – Generated text (vision-language models).
masks (Any | None) – Segmentation masks, e.g. a list of NumPy arrays for SAM 3.
bounding_boxes (list | None) – Detected boxes as
[x0, y0, x1, y1]lists.raw_response (Any | None) – The provider’s raw JSON or the raw tensors/metadata of a local model, kept for debugging.
error (str | None) – Why the request produced no output (
Noneon success). Transient failures (rate limits, timeouts) are still reported as a plainNonereturn fromrun_inference; this field marks responses the provider actively rejected.retryable (bool) – Whether the same request could succeed later. Provider rejections (refusals, safety blocks, 4xx errors) set it to
Falseso callers do not pause and retry them.
Example
>>> from rapidtools.models.base import ModelOutput >>> out = ModelOutput(text=' ', bounding_boxes=[[0, 0, 4, 4]]) >>> out.has_text False >>> out.has_bounding_boxes True >>> ModelOutput.failure('refused').retryable False
Methods
Build an output that records why the request failed.
- retryable: bool = True#
Whether sending the same request again could succeed.
Falsefor provider rejections (refusals, safety blocks, 4xx errors).