Skip to main content

PredictError

Enum PredictError 

Source
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

§fields: Vec<String>

The names of the missing fields.

§expected: Vec<String>

All output field names, in declaration order. Pairs with fields to surface “missing 2 of 3” context.

§raw_excerpt: String

Head + 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).

§raw_bytes_total: usize

Total byte length of the raw completion. Reading the excerpt with (0 of 50000) context vs (0 of 200) context changes the operator’s diagnosis (truncation vs malformed output).

§

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.

Fields

§field: String

The lookup key that was not in the prediction.

§

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

§stop_reason: String

The normalized stop reason that triggered the early stop. Stringified at the boundary so this error type doesn’t take a public dependency on modelplease::StopReason.

§output_tokens: Option<u64>

Output tokens generated before truncation, when the provider reported usage. None for providers that omit usage on a truncated response.

§

FieldTypeMismatch

A field value could not be coerced to the declared FieldType.

Fields

§field: String

The field name.

§expected: String

The expected type label.

§actual: String

The raw value that failed coercion.

§

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

§expected_markers: Vec<String>

Markers the parser hoped to find (one per output field).

§raw_excerpt: String

Head + tail excerpt of the raw model completion.

§raw_bytes_total: usize

Total byte length of the raw completion.

§

InvalidSignature

Signature construction failed due to invalid configuration.

Fields

§reason: String

Why the signature is invalid.

§

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).

Fields

§message: String

Description of the optimizer error.

§

Evaluation

The evaluation runner exceeded its error budget.

Fields

§message: String

Description of the evaluation error.

§

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

§field: String

The field path being parsed.

§discriminator: String

The discriminator property name declared by the OneOf type.

§

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

§field: String

The field path being parsed.

§tag: String

The offending discriminator value.

§valid_tags: Vec<String>

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

§field: String

The field path being parsed.

§arm_errors: Vec<(usize, Box<Self>)>

Per-arm rejection reasons, parallel to the arms vector. The usize is the arm index.

§

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

§field: String

The field path being parsed.

§matching_arms: Vec<usize>

Indices of every arm that successfully parsed the value.

§

AnyOfNoArmMatched

An AnyOf input matched zero arms. AnyOf is first-match-wins; “no arm matched” means every arm rejected the value.

Fields

§field: String

The field path being parsed.

§arm_errors: Vec<(usize, Box<Self>)>

Per-arm rejection reasons, parallel to the arms vector.

Implementations§

Source§

impl PredictError

Source

pub fn missing_fields_from_parse<F, E>( missing: F, expected: E, raw_completion: &str, ) -> Self
where F: IntoIterator<Item = String>, E: IntoIterator<Item = String>,

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.

Source

pub fn no_field_markers_from_parse<E>( expected_markers: E, raw_completion: &str, ) -> Self
where E: IntoIterator<Item = String>,

Create a NoFieldMarkers error from the chat-adapter parse path.

Source

pub fn invalid_signature(reason: impl Into<String>) -> Self

Create an InvalidSignature error.

Source

pub fn optimizer(message: impl Into<String>) -> Self

Create an Optimizer error.

Source

pub fn evaluation(message: impl Into<String>) -> Self

Create an Evaluation error.

Source

pub fn truncated(stop_reason: &StopReason, output_tokens: Option<u64>) -> Self

Create a Truncated error from a language-model StopReason and optional output token count.

Trait Implementations§

Source§

impl Debug for PredictError

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for PredictError

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for PredictError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for PredictError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for PredictError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.
Source§

impl From<LanguageModelError> for PredictError

Source§

fn from(source: LanguageModelError) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more