pub struct LatencyRouter { /* private fields */ }Expand description
Router that selects providers based on observed latency.
Implementations§
Source§impl LatencyRouter
impl LatencyRouter
Sourcepub fn new(providers: Vec<Arc<dyn Provider>>) -> Result<Self>
pub fn new(providers: Vec<Arc<dyn Provider>>) -> Result<Self>
Create a latency router with default configuration.
§Errors
Returns a routing error if no providers are supplied.
Sourcepub fn with_config(
providers: Vec<Arc<dyn Provider>>,
config: LatencyRouterConfig,
) -> Result<Self>
pub fn with_config( providers: Vec<Arc<dyn Provider>>, config: LatencyRouterConfig, ) -> Result<Self>
Create a latency router with explicit configuration.
§Errors
Returns a routing error if no providers are supplied.
Sourcepub fn provider_count(&self) -> usize
pub fn provider_count(&self) -> usize
Return the number of configured providers.
Sourcepub async fn complete(
&self,
request: &CompletionRequest,
) -> Result<CompletionResponse>
pub async fn complete( &self, request: &CompletionRequest, ) -> Result<CompletionResponse>
Execute a completion request using latency-based selection.
Sourcepub async fn stream(
&self,
request: &CompletionRequest,
) -> Result<Box<dyn Stream<Item = Result<CompletionChunk>> + Send + Unpin>>
pub async fn stream( &self, request: &CompletionRequest, ) -> Result<Box<dyn Stream<Item = Result<CompletionChunk>> + Send + Unpin>>
Execute a streaming request using latency-based selection.
Auto Trait Implementations§
impl !Freeze for LatencyRouter
impl !RefUnwindSafe for LatencyRouter
impl Send for LatencyRouter
impl Sync for LatencyRouter
impl Unpin for LatencyRouter
impl !UnwindSafe for LatencyRouter
Blanket Implementations§
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
Mutably borrows from an owned value. Read more