llm_samplers/configure/
mod.rs

1//! This module implements configurable samplers
2//! based on keys and values and also parsing strings
3//! to configure a sampler.
4//!
5//! Unless you're writing your own implementation, you
6//! basically only need to worry about
7//! [ConfigurableSampler::configure](crate::configure::ConfigurableSampler::configure).
8//! The built in samplers all implement this trait.
9//!
10//! Currently the default implementations aren't as flexible
11//! as we might like and it should be noted that values are
12//! converted from string to [u64] or [f64] before being
13//! converted to the actual option type.
14
15mod building;
16mod configurable;
17mod metadata;
18mod value;
19
20use thiserror::Error;
21
22#[doc(inline)]
23pub use self::{building::*, configurable::*, metadata::*, value::*};
24
25/// Sampler option handling errors.
26#[derive(Debug, Error, Clone, PartialEq)]
27pub enum ConfigureSamplerError {
28    #[error("unknown option key {0} or bad type")]
29    /// Unknown option key or incorrect type specified.
30    UnknownOrBadType(String),
31
32    /// The supplied key can match multiple options.
33    #[error("option key {0} is ambiguous")]
34    AmbiguousKey(String),
35
36    /// An error occurred converting the option value.
37    #[error("option value conversion for key {0} failed")]
38    ConversionFailure(String),
39
40    /// The option value cannot be accessed as requested.
41    #[error("option value for key {0} cannot be accessed as requested")]
42    CannotAccessOptionValue(String),
43}