Skip to main content

Runtime

Struct Runtime 

Source
pub struct Runtime { /* private fields */ }
Expand description

Coordinates catalog resolution, routing, model lifecycle, and inference.

A runtime is explicit application state; it does not create global state or background services. Use Runtime::builder to obtain built-in CPU and ONNX execution.

Implementations§

Source§

impl Runtime

Source

pub fn generation_providers(&self) -> Vec<ProviderCapability>

Descriptors of registered generation providers. These are separate from typed-inference providers and never take part in their routing.

Source

pub async fn list_generation_models( &self, provider: &str, cancellation: Option<CancellationToken>, ) -> RuntimeResult<Vec<GenerationModelInfo>>

Lists models from the named provider, where the upstream supports it.

Source

pub async fn chat( &self, provider: &str, request: ChatRequest, cancellation: Option<CancellationToken>, ) -> RuntimeResult<ChatResponse>

Single-response generation through the explicitly named provider.

When a JSON response format is requested the returned ChatResponse::structured states whether the text parsed and validated; invalid output is reported, never repaired.

Source

pub async fn chat_stream( &self, provider: &str, request: ChatRequest, cancellation: Option<CancellationToken>, ) -> RuntimeResult<BoxStream<RuntimeResult<ChatStreamEvent>>>

Streaming generation. Yields Started, zero or more Delta, then exactly one Completed on success. Any failure or cancellation ends the stream with an error and never with Completed; a stream that ends without either is reported as a protocol error. Dropping the stream releases the upstream connection and the concurrency permit.

Source§

impl Runtime

Source

pub fn new() -> Self

Source

pub fn builder() -> RuntimeBuilder

Source

pub fn config(&self) -> &RuntimeConfig

Source

pub fn load_decision_model( &self, artifact: impl AsRef<Path>, ) -> RuntimeResult<Box<dyn DecisionModel>>

Loads an immutable local typed-decision artifact through the single matching backend. There is no fallback: missing, ambiguous, or invalid artifacts fail closed.

Source

pub fn decision_capabilities( &self, model: &dyn DecisionModel, ) -> DecisionModelCapabilities

Returns model/backend execution facts without requiring applications to inspect artifact layouts or backend names.

Source

pub fn explain_decision( &self, model: &dyn DecisionModel, request: &DecisionGraphRequest, ) -> RuntimeResult<DecisionExecutionPlan>

Builds the deterministic execution plan for a loaded model and graph.

Source

pub async fn execute_decision_graph( &self, model: Arc<dyn DecisionModel>, request: DecisionGraphRequest, cancellation: Option<CancellationToken>, ) -> RuntimeResult<PlannedDecisionResult>

Executes a graph asynchronously. Synchronous native model calls are moved off the caller’s async executor thread.

Source

pub async fn decide_async( &self, model: Arc<dyn DecisionModel>, request: DecisionRequest, policy: DecisionExecutionPolicy, cancellation: Option<CancellationToken>, ) -> RuntimeResult<PlannedDecisionResult>

Compatibility-friendly async execution for an ordinary independent DecisionRequest.

Source

pub fn installed_models(&self) -> RuntimeResult<Vec<InstalledModelRecord>>

Source

pub async fn install_registered_model( &self, name: &str, source_override: Option<&str>, replace: bool, ) -> RuntimeResult<ModelLifecycleResult>

Source

pub fn doctor_registered_model( &self, name: &str, ) -> RuntimeResult<ModelDoctorReport>

Source

pub fn remove_registered_model( &self, name: &str, ) -> RuntimeResult<InstalledModelRecord>

Source

pub fn load_model(&self, name: &str) -> RuntimeResult<Box<dyn DecisionModel>>

Loads a validated installed model by its registry name. Source, artifact layout, tokenizer, and backend selection remain runtime concerns.

Source

pub fn set_catalog<C>(&mut self, catalog: C)
where C: ModelCatalog + 'static,

Source

pub async fn catalog_models(&self) -> RuntimeResult<Vec<ModelDescriptor>>

Source

pub async fn resolve_model( &self, reference: &ModelReference, ) -> RuntimeResult<ModelDescriptor>

Source

pub async fn refresh_catalog(&self) -> RuntimeResult<()>

Source

pub fn models(&self) -> ModelRegistry

Source

pub fn providers(&self) -> ProviderRegistry

Source

pub fn backends(&self) -> BackendRegistry

Source

pub fn capabilities(&self) -> RuntimeCapabilities

Source

pub fn capability(&self, id: &str) -> Option<Capability>

Source

pub fn capability_registry(&self) -> &CapabilityRegistry

Source

pub fn load_capability_packages( &mut self, root: impl AsRef<Path>, ) -> RuntimeResult<Vec<String>>

Explicitly discovers and registers local capability package metadata.

Discovery never loads or executes a provider binary.

Source

pub fn environment(&self) -> RuntimeEnvironment

Source

pub fn resolve_capability( &self, request: &ExecutionRequest, ) -> RuntimeResult<CapabilityResolution>

Source

pub fn resolve_capability_with_constraints( &self, request: &ExecutionRequest, constraints: &ResolutionConstraints, ) -> RuntimeResult<CapabilityResolution>

Source

pub async fn execute_capability( &self, request: ExecutionRequest, authorizer: Option<&dyn CapabilityAuthorizer>, ) -> RuntimeResult<ExecutionResult>

Source

pub fn status(&self) -> RuntimeStatus

Source

pub fn metrics(&self) -> RuntimeMetricsSnapshot

Source

pub fn executions(&self) -> Vec<ExecutionRecord>

Source

pub fn resources(&self) -> Vec<ModelResource>

Source

pub fn snapshot(&self) -> RuntimeSnapshot

Source

pub fn selection_for( &self, model: &ModelSpec, ) -> RuntimeResult<RuntimeSelection>

Source

pub async fn load(&self, model: ModelSpec) -> RuntimeResult<RuntimeModelHandle>

Explicitly loads a model for repeated execution with Self::infer_loaded. Normal one-off requests should use Self::infer, which loads lazily.

Source

pub async fn load_reference( &self, reference: ModelReference, ) -> RuntimeResult<RuntimeModelHandle>

Source

pub async fn infer( &self, request: InferenceRequest, ) -> RuntimeResult<InferenceResult>

Resolves, loads, routes, and executes one request.

Source

pub async fn infer_loaded( &self, model: &RuntimeModelHandle, input: Input, options: InferenceOptions, ) -> RuntimeResult<InferenceResult>

Executes against a previously loaded handle without exposing cache internals.

Source

pub async fn infer_loaded_stream( &self, model: &RuntimeModelHandle, input: Input, options: InferenceOptions, ) -> RuntimeResult<InferenceStream>

Source

pub async fn infer_batch( &self, requests: Vec<InferenceRequest>, ) -> RuntimeResult<Vec<InferenceResult>>

Executes requests in stable input order.

The call fails as a whole on a request error. Backends without native batching are invoked individually behind the same API.

Source

pub async fn infer_with_cancellation( &self, request: InferenceRequest, cancellation: CancellationToken, ) -> RuntimeResult<InferenceResult>

Executes one request while propagating cancellation through scheduling, provider transport, and backend execution.

Source

pub async fn infer_stream( &self, request: InferenceRequest, ) -> RuntimeResult<InferenceStream>

Starts normalized Started → Output* → Completed streaming.

Source

pub async fn infer_stream_with_cancellation( &self, request: InferenceRequest, cancellation: CancellationToken, ) -> RuntimeResult<InferenceStream>

Starts a bounded stream with caller-controlled cancellation.

Trait Implementations§

Source§

impl Default for Runtime

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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