Skip to main content

LoomSession

Struct LoomSession 

Source
pub struct LoomSession<'model> { /* private fields */ }
Expand description

Higher-level borrowing façade over one single-owner causal session.

Implementations§

Source§

impl<'model> LoomSession<'model>

Source

pub fn replace_text( &mut self, text: &str, tokenization: Tokenization, ) -> Result<AdmissionOutput>

Tokenizes exact text and replaces prior causal state before admission.

§Errors

Returns a tokenization, capacity, validation, or native prefill error.

Source

pub fn append_text( &mut self, text: &str, tokenization: Tokenization, ) -> Result<AdmissionOutput>

Tokenizes exact text and appends it to existing causal state.

§Errors

Returns a tokenization, capacity, validation, or native prefill error.

Source

pub fn replace_text_observed( &mut self, text: &str, tokenization: Tokenization, monitor: &mut PrefillMonitor, ) -> Result<AdmissionOutput>

Replaces prior causal state while observing complete prefill chunks.

A cooperative stop returns successful partial admission. Inspect the prefill receipt before deciding whether to generate.

§Errors

Returns a tokenization, capacity, observer, or native prefill error.

Source

pub fn append_text_observed( &mut self, text: &str, tokenization: Tokenization, monitor: &mut PrefillMonitor, ) -> Result<AdmissionOutput>

Appends exact text while observing complete prefill chunks.

A cooperative stop returns successful partial admission. Inspect the prefill receipt before deciding whether to generate.

§Errors

Returns a tokenization, capacity, observer, or native prefill error.

Source

pub fn generate( &mut self, request: GenerationRequest<'_>, ) -> Result<GenerationOutput>

Executes one bounded generation request against current causal state.

§Errors

Returns a plan, pipeline, observer, sampling, capacity, or native error.

Source

pub fn clear(&mut self) -> Result<()>

Clears current causal state and exact local lineage.

§Errors

Returns the retained reason when native state is poisoned.

Source

pub fn capture_state(&mut self) -> Result<StateSnapshot>

Captures opaque native state and exact causal lineage.

§Errors

Returns an identity, allocation, or native state error.

Source

pub fn restore_state(&mut self, snapshot: &StateSnapshot) -> Result<()>

Restores a compatible checkpoint.

§Errors

Returns an identity, compatibility, or native restore error.

Source

pub const fn position(&self) -> u64

Returns the current causal position.

Source

pub const fn options(&self) -> SessionOptions

Returns the exact allocation contract for this session.

Source

pub fn token_history(&self) -> &[TokenId]

Returns exact admitted token history.

Source

pub const fn is_healthy(&self) -> bool

Returns whether native state is not poisoned.

Source

pub fn poison_reason(&self) -> Option<&str>

Returns the retained poison reason, when present.

Source

pub const fn raw(&self) -> &Session<'model>

Returns the underlying low-level session.

Source

pub fn raw_mut(&mut self) -> &mut Session<'model>

Returns the underlying mutable low-level session.

Source§

impl<'model> LoomSession<'model>

Source

pub fn lora<'scope>( &'scope mut self, adapter: &'scope mut LoraAdapter, scale: f32, ) -> Result<LoraSession<'scope, 'model>>

Applies a LoRA and borrows this session until explicit or drop cleanup.

§Errors

Returns a contract or native application error.

Source

pub fn control_vector<'scope>( &'scope mut self, vector: &'scope ControlVector, ) -> Result<ControlVectorSession<'scope, 'model>>

Applies a control vector and borrows this session until cleanup.

§Errors

Returns a contract, model-compatibility, or native application error.

Trait Implementations§

Source§

impl Debug for LoomSession<'_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'model> !RefUnwindSafe for LoomSession<'model>

§

impl<'model> !Send for LoomSession<'model>

§

impl<'model> !Sync for LoomSession<'model>

§

impl<'model> !UnwindSafe for LoomSession<'model>

§

impl<'model> Freeze for LoomSession<'model>

§

impl<'model> Unpin for LoomSession<'model>

§

impl<'model> UnsafeUnpin for LoomSession<'model>

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> Same for T

Source§

type Output = T

Should always be Self
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