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>
impl<'model> LoomSession<'model>
Sourcepub fn replace_text(
&mut self,
text: &str,
tokenization: Tokenization,
) -> Result<AdmissionOutput>
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.
Sourcepub fn append_text(
&mut self,
text: &str,
tokenization: Tokenization,
) -> Result<AdmissionOutput>
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.
Sourcepub fn replace_text_observed(
&mut self,
text: &str,
tokenization: Tokenization,
monitor: &mut PrefillMonitor,
) -> Result<AdmissionOutput>
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.
Sourcepub fn append_text_observed(
&mut self,
text: &str,
tokenization: Tokenization,
monitor: &mut PrefillMonitor,
) -> Result<AdmissionOutput>
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.
Sourcepub fn generate(
&mut self,
request: GenerationRequest<'_>,
) -> Result<GenerationOutput>
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.
Sourcepub fn clear(&mut self) -> Result<()>
pub fn clear(&mut self) -> Result<()>
Clears current causal state and exact local lineage.
§Errors
Returns the retained reason when native state is poisoned.
Sourcepub fn capture_state(&mut self) -> Result<StateSnapshot>
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.
Sourcepub fn restore_state(&mut self, snapshot: &StateSnapshot) -> Result<()>
pub fn restore_state(&mut self, snapshot: &StateSnapshot) -> Result<()>
Restores a compatible checkpoint.
§Errors
Returns an identity, compatibility, or native restore error.
Sourcepub const fn options(&self) -> SessionOptions
pub const fn options(&self) -> SessionOptions
Returns the exact allocation contract for this session.
Sourcepub fn token_history(&self) -> &[TokenId]
pub fn token_history(&self) -> &[TokenId]
Returns exact admitted token history.
Sourcepub const fn is_healthy(&self) -> bool
pub const fn is_healthy(&self) -> bool
Returns whether native state is not poisoned.
Sourcepub fn poison_reason(&self) -> Option<&str>
pub fn poison_reason(&self) -> Option<&str>
Returns the retained poison reason, when present.
Source§impl<'model> LoomSession<'model>
impl<'model> LoomSession<'model>
Sourcepub fn lora<'scope>(
&'scope mut self,
adapter: &'scope mut LoraAdapter,
scale: f32,
) -> Result<LoraSession<'scope, 'model>>
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.
Sourcepub fn control_vector<'scope>(
&'scope mut self,
vector: &'scope ControlVector,
) -> Result<ControlVectorSession<'scope, 'model>>
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.