Skip to main content

RoutingProvider

Struct RoutingProvider 

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

Dispatches on the vendor/ prefix of a pinned model reference.

Implementations§

Source§

impl RoutingProvider

Source

pub fn new() -> RoutingProvider

Source

pub fn with( self, vendor: impl Into<String>, provider: Box<dyn ModelProvider>, ) -> Self

Register the provider for a vendor prefix.

Source

pub fn or_else( self, vendor: impl Into<String>, provider: Box<dyn ModelProvider>, ) -> Self

The provider for a call that names no vendor.

vendor is the operator’s label for it, which is not the same as the provider’s own name: a service called local may well speak the OpenAI protocol, and an artifact that pins local/… means the label.

Source

pub fn vendors(&self) -> Vec<&str>

Vendors this router can reach, in name order.

Includes the fallback’s own vendor: a run with one provider can serve anthropic/claude-… even though nothing was registered under a prefix, because the fallback knows what it is.

Source

pub fn is_empty(&self) -> bool

Source

pub fn describe(&self) -> String

One line for the run log, so which service answered is never a guess.

Trait Implementations§

Source§

impl Default for RoutingProvider

Source§

fn default() -> Self

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

impl ModelProvider for RoutingProvider

Source§

fn streams(&self) -> bool

Only when every route streams.

The interpreter asks this before a request exists, so the answer has to hold for whichever route ends up answering. One provider that cannot stream therefore keeps the smaller output ceiling for all of them — conservative on purpose, because the alternative is an artifact that asks for more tokens than a service accepts and fails on a route the operator did not think they were using.

Source§

fn name(&self) -> &str

Short name used in events and diagnostics, e.g. anthropic or replay.
Source§

fn complete( &mut self, request: &CompletionRequest, ) -> Result<CompletionResponse, ProviderError>

Source§

fn complete_streaming( &mut self, request: &CompletionRequest, on_delta: DeltaSink<'_>, ) -> Result<CompletionResponse, ProviderError>

Complete a request, handing text to on_delta as it arrives. 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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.