pub struct LocalLlmAgent {
pub agent_did: String,
pub backend: AgentBackend,
pub memory_used_bytes: AtomicU64,
/* private fields */
}Expand description
The concrete local inference agent. Uses a mock inference path for now;
swap infer_local_model for an actual llama.cpp FFI call.
Fields§
§agent_did: String§backend: AgentBackend§memory_used_bytes: AtomicU64Implementations§
Source§impl LocalLlmAgent
impl LocalLlmAgent
Sourcepub fn infer_local_model_streaming<F: FnMut(String) + Send + 'static>(
&self,
prompt: &str,
graph_context: &str,
on_token: Option<F>,
) -> (String, Vec<u64>, u32, Option<NQuin>)
pub fn infer_local_model_streaming<F: FnMut(String) + Send + 'static>( &self, prompt: &str, graph_context: &str, on_token: Option<F>, ) -> (String, Vec<u64>, u32, Option<NQuin>)
Phase 8: Bifurcated Compute — SPSC Wait-Free Intercept.
On native targets: loads the GGUF model, tokenises the prompt, and runs an
autoregressive decode loop via QTensorEngine::dispatch_fused_transformer_block.
Logit summaries flow from the LLM engine thread to the Webizen Sentinel (this
thread) over a wait-free SPSC ring. The Sentinel may inject DenyRollback
for real governance signals; the old IEEE-754 0x99 mantissa check was
removed (it fired randomly ~1/256 tokens and corrupted the stream).
On WASM / non-local backends: falls through to the original mock path.
Run local inference, optionally streaming decoded text deltas to on_token.
Source§impl LocalLlmAgent
impl LocalLlmAgent
pub fn new(agent_did: impl Into<String>, model_path: impl Into<String>) -> Self
Sourcepub fn with_local_backend(
agent_did: impl Into<String>,
backend: AgentBackend,
) -> Self
pub fn with_local_backend( agent_did: impl Into<String>, backend: AgentBackend, ) -> Self
Construct an agent with a fully specified backend (e.g. catalog multimodal profile).
Sourcepub fn attach_lora_adapters(&self, adapter_dir: impl Into<PathBuf>)
pub fn attach_lora_adapters(&self, adapter_dir: impl Into<PathBuf>)
Attach a LoRA adapter directory to this agent.
Adapters are loaded lazily on the first prompt that triggers a domain
switch. The directory must contain *.lora files named after
ContextType::adapter_filename() (e.g. medical_v1.lora).
Sourcepub fn attach_lora_adapters_with_dims(
&self,
adapter_dir: impl Into<PathBuf>,
n_in: usize,
n_out: usize,
)
pub fn attach_lora_adapters_with_dims( &self, adapter_dir: impl Into<PathBuf>, n_in: usize, n_out: usize, )
Attach a LoRA manager pre-configured with expected embedding dimensions.
n_in should match the model’s embedding dimension (e.g. 4096 for 7B models).
Sourcepub fn detach_lora_adapters(&self)
pub fn detach_lora_adapters(&self)
Remove the LoRA manager and revert to base-model-only inference.
Sourcepub fn warm_lora_for_prompt(&self, prompt: &str)
pub fn warm_lora_for_prompt(&self, prompt: &str)
Detect context from prompt and pre-warm the LoRA adapter cache.
Call this before a batch of related prompts to avoid cold-load latency on the first inference.
Sourcepub fn active_lora_context(&self) -> Option<ContextType>
pub fn active_lora_context(&self) -> Option<ContextType>
Return the currently active LoRA context type, if any.
Sourcepub fn configure_sieve_lex(&self, path: impl Into<String>)
pub fn configure_sieve_lex(&self, path: impl Into<String>)
Wire the .q42.lex sidecar used to populate FSM sieve masks at inference time.
pub fn agent_did_hash(&self) -> u64
Source§impl LocalLlmAgent
impl LocalLlmAgent
Sourcepub fn validate_intent_frame(&self, frame: &AgentIntentFrame) -> WebizenVerdict
pub fn validate_intent_frame(&self, frame: &AgentIntentFrame) -> WebizenVerdict
Zero-allocation pre-flight path for Core 1 (no active_profile heap lookup).
Trait Implementations§
Source§impl AgentRuntime for LocalLlmAgent
impl AgentRuntime for LocalLlmAgent
Source§fn backend(&self) -> &AgentBackend
fn backend(&self) -> &AgentBackend
Source§fn validate_intent(&self, intent: &AgentIntent) -> WebizenVerdict
fn validate_intent(&self, intent: &AgentIntent) -> WebizenVerdict
infer. Callers must not proceed if
the verdict is Deny.Source§fn infer(
&self,
prompt: &str,
graph_context: &str,
) -> Result<AgentOutput, AgentError>
fn infer( &self, prompt: &str, graph_context: &str, ) -> Result<AgentOutput, AgentError>
graph_context is a serialised sub-graph slice provided by the Webizen.Source§fn validate_output(&self, output: &AgentOutput) -> WebizenVerdict
fn validate_output(&self, output: &AgentOutput) -> WebizenVerdict
Source§fn memory_budget_remaining(&self) -> u64
fn memory_budget_remaining(&self) -> u64
Auto Trait Implementations§
impl !Freeze for LocalLlmAgent
impl RefUnwindSafe for LocalLlmAgent
impl Send for LocalLlmAgent
impl Sync for LocalLlmAgent
impl Unpin for LocalLlmAgent
impl UnsafeUnpin for LocalLlmAgent
impl UnwindSafe for LocalLlmAgent
Blanket Implementations§
§impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
impl<S, A> Aggregate<Result<S, Error>> for Awhere
A: Aggregate<S>,
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
§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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more