Skip to main content

Capped

Struct Capped 

Source
pub struct Capped<P> {
    pub inner: P,
    pub context_hard_cap: usize,
}
Expand description

A ceiling on request size, on top of whatever else a policy decides.

The second implementation, and the one the missing capability calls for: a deployment that has to guarantee it never sends a request past some size — a provider hard limit, a cost ceiling, a compliance rule — wraps its policy in this. A turn whose context is still above the cap after compaction ends rather than sending the request anyway.

Fields§

§inner: P§context_hard_cap: usize

Trait Implementations§

Source§

impl<P: BudgetPolicy> BudgetPolicy for Capped<P>

Source§

fn on_usage(&self, spend: &Spend) -> Spending

After a model call, against the root turn’s reading (SpendNode::whole_turn) then. A turn the engine’s ceilings already ended does not ask.
Source§

fn remaining(&self, spend: &Spend) -> Option<Remaining>

Before a model call, against the root turn’s reading. The call is not sent when less than MIN_CALL_TOKENS remain under this or any of the engine’s ceilings, and otherwise asks for no more output than the tightest leaves. None: no ceiling of the policy’s own.
Source§

fn on_output_target(&self, progress: &OutputProgress) -> OutputTarget

When the model has stopped and a volume of output was asked for. Read more
Source§

fn context_budget(&self, scene: &TokenBudget) -> ContextBudget

What the scene asked for, and what the deployment will actually allow.

Auto Trait Implementations§

§

impl<P> Forget for Capped<P>

§

impl<P> Freeze for Capped<P>
where P: Freeze,

§

impl<P> Move for Capped<P>

§

impl<P> RefUnwindSafe for Capped<P>
where P: RefUnwindSafe,

§

impl<P> Send for Capped<P>
where P: Send,

§

impl<P> Sync for Capped<P>
where P: Sync,

§

impl<P> Unpin for Capped<P>
where P: Unpin,

§

impl<P> UnsafeUnpin for Capped<P>
where P: UnsafeUnpin,

§

impl<P> UnwindSafe for Capped<P>
where P: UnwindSafe,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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