pub struct Score<L> { /* private fields */ }Expand description
A score question with a statically known ordered rubric.
Implementations§
Source§impl<L: Ord> Score<L>
impl<L: Ord> Score<L>
Sourcepub fn new<const N: usize, D: Serialize>(
instructions: impl Serialize,
levels: [(L, D); N],
) -> Result<Self, ProviderError>
pub fn new<const N: usize, D: Serialize>( instructions: impl Serialize, levels: [(L, D); N], ) -> Result<Self, ProviderError>
Define an ordered, typed rubric. Array order determines zero-based wire positions; the enum’s discriminants and ordering do not.
ⓘ
use rig_typesafeai::Score;
let _ = Score::new("Rate risk", [(0u8, "Only one level")]);Sourcepub fn try_from_iter<I, D>(
instructions: impl Serialize,
levels: I,
) -> Result<Self, ProviderError>
pub fn try_from_iter<I, D>( instructions: impl Serialize, levels: I, ) -> Result<Self, ProviderError>
Define a typed rubric from a runtime collection, validating its size and rejecting repeated variants before evaluation.
Trait Implementations§
Source§impl<L: Ord + Clone + WasmCompatSend + WasmCompatSync> Query for Score<L>
impl<L: Ord + Clone + WasmCompatSend + WasmCompatSync> Query for Score<L>
Source§type Output = ScoreAnswer<L>
type Output = ScoreAnswer<L>
The validated application answer shape.
Source§fn decode(&self, response: Answer) -> Result<Self::Output, ProviderError>
fn decode(&self, response: Answer) -> Result<Self::Output, ProviderError>
Validate and convert a deserialized response. Composite queries delegate
to their fields, keeping validation inside the evaluation error boundary.
Source§fn named(self, id: impl Into<String>) -> Result<NamedQuery<Self>, ProviderError>where
Self: Sized,
fn named(self, id: impl Into<String>) -> Result<NamedQuery<Self>, ProviderError>where
Self: Sized,
Give a standalone question a runtime ID. Named struct fields do not need this.
Source§fn join<Q: Query>(self, other: Q) -> JoinedQuery<Self, Q>where
Self: Sized,
fn join<Q: Query>(self, other: Q) -> JoinedQuery<Self, Q>where
Self: Sized,
Flatten two object-shaped queries into one evaluation request.
Duplicate IDs are rejected before sending the request. Child queries must
serialize with stable field names: decoding uses those names to partition
the response before delegating to each child.
Source§fn map<A, F>(self, map: F) -> MappedQuery<Self, F>
fn map<A, F>(self, map: F) -> MappedQuery<Self, F>
Project validated answers into an application value.
Auto Trait Implementations§
impl<L> Freeze for Score<L>
impl<L> RefUnwindSafe for Score<L>where
Vec<L>: RefUnwindSafe,
impl<L> Send for Score<L>
impl<L> Sync for Score<L>
impl<L> Unpin for Score<L>
impl<L> UnsafeUnpin for Score<L>where
Vec<L>: UnsafeUnpin,
impl<L> UnwindSafe for Score<L>where
Vec<L>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
impl<T> IntoToolOutput for Twhere
T: Serialize + 'static,
Source§fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
fn into_tool_output(self) -> Result<ToolOutput, ToolExecutionError>
Convert this value without routing structured data through a string.