pub struct FeedbackLoop { /* private fields */ }Expand description
Closed-loop feedback collector that ties together the store and reward model.
Implementations§
Source§impl FeedbackLoop
impl FeedbackLoop
Sourcepub fn new(
ring_capacity: usize,
decay: f64,
max_tokens: u64,
max_latency_ms: u64,
) -> Self
pub fn new( ring_capacity: usize, decay: f64, max_tokens: u64, max_latency_ms: u64, ) -> Self
Create a new FeedbackLoop.
ring_capacity: number of feedbacks retained per variant in the ring buffer.decay: exponential smoothing factor for the reward model (0 < decay < 1).max_tokens: token ceiling used when normalising cost penalties.max_latency_ms: latency ceiling used when normalising latency penalties.
Sourcepub fn record(&self, feedback: Feedback)
pub fn record(&self, feedback: Feedback)
Record a feedback observation.
The variant key is derived from request_id as the model name prefix
(everything before the first ':'). Callers should embed the model
name in request_id as "model:rest-of-id". If no ':' is found the
whole request_id is used as the variant key.
Sourcepub fn best_variant(&self, model_options: &[String]) -> Option<String>
pub fn best_variant(&self, model_options: &[String]) -> Option<String>
Return the variant (from model_options) with the highest average reward.
Returns None if none of the provided options have any recorded rewards.
Sourcepub fn reward_history(&self, variant: &str) -> Vec<f64>
pub fn reward_history(&self, variant: &str) -> Vec<f64>
Return the chronological reward history for a given variant.
Sourcepub fn convergence_score(&self) -> f64
pub fn convergence_score(&self) -> f64
Compute a convergence score as the variance of the most recent rewards across all known variants.
A low value (close to 0) indicates that rewards have stabilised.
Trait Implementations§
Source§impl Clone for FeedbackLoop
impl Clone for FeedbackLoop
Source§fn clone(&self) -> FeedbackLoop
fn clone(&self) -> FeedbackLoop
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for FeedbackLoop
impl RefUnwindSafe for FeedbackLoop
impl Send for FeedbackLoop
impl Sync for FeedbackLoop
impl Unpin for FeedbackLoop
impl UnsafeUnpin for FeedbackLoop
impl UnwindSafe for FeedbackLoop
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request