pub enum PredictError {
Show 16 variants
MissingFields {
fields: Vec<String>,
expected: Vec<String>,
raw_excerpt: String,
raw_bytes_total: usize,
},
FieldNotInPrediction {
field: String,
},
Truncated {
stop_reason: String,
output_tokens: Option<u64>,
},
FieldTypeMismatch {
field: String,
expected: String,
actual: String,
},
NoFieldMarkers {
expected_markers: Vec<String>,
raw_excerpt: String,
raw_bytes_total: usize,
},
InvalidSignature {
reason: String,
},
Serialization(Error),
LanguageModel(LanguageModelError),
Optimizer {
message: String,
},
Evaluation {
message: String,
},
Io(Error),
OneOfTagMissing {
field: String,
discriminator: String,
},
OneOfTagInvalid {
field: String,
tag: String,
valid_tags: Vec<String>,
},
OneOfNoArmMatched {
field: String,
arm_errors: Vec<(usize, Box<Self>)>,
},
OneOfAmbiguous {
field: String,
matching_arms: Vec<usize>,
},
AnyOfNoArmMatched {
field: String,
arm_errors: Vec<(usize, Box<Self>)>,
},
}Expand description
Errors that can occur in predict operations.
Variants§
MissingFields
One or more required output fields are absent from the completion.
Surfaced from an adapter’s parse implementation when the
parser found at least one field marker but not every required
output field. The raw excerpt + total-bytes context lets an
operator diagnose from the error alone instead of running the
model again with extra logging.
Fields
expected: Vec<String>All output field names, in declaration order. Pairs with
fields to surface “missing 2 of 3” context.
raw_excerpt: StringHead + tail excerpt of the raw model completion at parse
time. Empty when the error is constructed outside the
adapter parse path (e.g. a Prediction::get lookup miss
— though that uses FieldNotInPrediction).
FieldNotInPrediction
Caller asked for a field via Prediction::get
that is not present in the prediction. Distinct from
MissingFields — which is a parser-level
“model failed to emit” — because this one is a “caller asked
for the wrong key” and the raw-completion context is irrelevant.
Truncated
The language model stopped generating before producing a complete
response — most often because the configured max_tokens budget
was exhausted mid-output. The completion is therefore truncated
and cannot be parsed for output fields. Surfaced ahead of
MissingFields so operators see the real
root cause instead of a generic parse failure.
Fields
FieldTypeMismatch
A field value could not be coerced to the declared FieldType.
Fields
NoFieldMarkers
The completion contained no [[ ## field ## ]] markers at all.
The raw excerpt names what the model emitted instead — usually
either a code-fenced JSON object the prompt didn’t ask for, a
natural-language refusal, or a near-miss marker ([[answer]]
without the surrounding ## decorations).
Fields
InvalidSignature
Signature construction failed due to invalid configuration.
Serialization(Error)
JSON serialization or deserialization failure.
LanguageModel(LanguageModelError)
A language model call failed.
Optimizer
An optimizer encountered a runtime error (e.g. exceeded max errors).
Evaluation
The evaluation runner exceeded its error budget.
Io(Error)
File I/O error during state save or load.
OneOfTagMissing
A tagged OneOf input is missing its
discriminator property. Either the property is absent from the JSON
object, or the value being parsed isn’t a JSON object at all.
Fields
OneOfTagInvalid
A tagged OneOf input carried a discriminator
value that doesn’t match any declared arm tag. Lists the valid tags so
the operator can compare against the offending value (case, whitespace,
near-miss spellings).
Fields
The full set of valid arm tags declared by the OneOf type.
OneOfNoArmMatched
An untagged OneOf input matched zero arms.
Each per-arm parse failure is preserved so the operator can see why
every arm rejected the value rather than guessing.
Fields
OneOfAmbiguous
An untagged OneOf input matched more than
one arm. JSON Schema’s oneOf semantics require exactly one match;
ambiguity is a schema-design bug surfaced to the operator.
Fields
AnyOfNoArmMatched
An AnyOf input matched zero arms. AnyOf is
first-match-wins; “no arm matched” means every arm rejected the value.
Implementations§
Source§impl PredictError
impl PredictError
Sourcepub fn missing_fields_from_parse<F, E>(
missing: F,
expected: E,
raw_completion: &str,
) -> Self
pub fn missing_fields_from_parse<F, E>( missing: F, expected: E, raw_completion: &str, ) -> Self
Create a MissingFields error
from the chat-adapter parse path. The raw completion is in scope
at the construction site; passing it through populates the
excerpt + total-bytes context the operator needs to debug from
the error alone.
Sourcepub fn no_field_markers_from_parse<E>(
expected_markers: E,
raw_completion: &str,
) -> Selfwhere
E: IntoIterator<Item = String>,
pub fn no_field_markers_from_parse<E>(
expected_markers: E,
raw_completion: &str,
) -> Selfwhere
E: IntoIterator<Item = String>,
Create a NoFieldMarkers error
from the chat-adapter parse path.
Sourcepub fn invalid_signature(reason: impl Into<String>) -> Self
pub fn invalid_signature(reason: impl Into<String>) -> Self
Create an InvalidSignature error.
Sourcepub fn evaluation(message: impl Into<String>) -> Self
pub fn evaluation(message: impl Into<String>) -> Self
Create an Evaluation error.
Trait Implementations§
Source§impl Debug for PredictError
impl Debug for PredictError
Source§impl Display for PredictError
impl Display for PredictError
Source§impl Error for PredictError
impl Error for PredictError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()