pub struct RoutingProvider { /* private fields */ }Expand description
Dispatches on the vendor/ prefix of a pinned model reference.
Implementations§
Source§impl RoutingProvider
impl RoutingProvider
pub fn new() -> RoutingProvider
Sourcepub fn with(
self,
vendor: impl Into<String>,
provider: Box<dyn ModelProvider>,
) -> Self
pub fn with( self, vendor: impl Into<String>, provider: Box<dyn ModelProvider>, ) -> Self
Register the provider for a vendor prefix.
Sourcepub fn or_else(
self,
vendor: impl Into<String>,
provider: Box<dyn ModelProvider>,
) -> Self
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.
Sourcepub fn vendors(&self) -> Vec<&str>
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.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Default for RoutingProvider
impl Default for RoutingProvider
Source§impl ModelProvider for RoutingProvider
impl ModelProvider for RoutingProvider
Source§fn streams(&self) -> bool
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.
fn complete( &mut self, request: &CompletionRequest, ) -> Result<CompletionResponse, ProviderError>
Source§fn complete_streaming(
&mut self,
request: &CompletionRequest,
on_delta: DeltaSink<'_>,
) -> Result<CompletionResponse, ProviderError>
fn complete_streaming( &mut self, request: &CompletionRequest, on_delta: DeltaSink<'_>, ) -> Result<CompletionResponse, ProviderError>
on_delta as it arrives. Read more