pub struct AlloyedModelProvider { /* private fields */ }Expand description
A StreamingModelProvider that cycles through multiple providers in round-robin order.
Each call to stream_response advances to the next provider in the list. This allows alternating between models with different strengths on successive turns.
§Behavior
stream_response– Uses the current provider, then advances the index.display_name– Returns the current provider’s name (does not advance).context_window– Returns the minimum context window across all providers. ReturnsNoneif any provider’s window is unknown.model– Returns the current provider’s model identity.
§Example
use llm::alloyed::AlloyedModelProvider;
use llm::StreamingModelProvider;
fn create_alloyed(providers: Vec<Box<dyn StreamingModelProvider>>) -> AlloyedModelProvider {
AlloyedModelProvider::new(providers)
// First stream_response() uses providers[0],
// second uses providers[1], etc.
}Created automatically by ModelProviderParser::parse
when given a comma-separated model string like "anthropic:claude-sonnet-4-5-20250929,openai:gpt-4o".
Implementations§
Source§impl AlloyedModelProvider
impl AlloyedModelProvider
pub fn new(providers: Vec<Box<dyn StreamingModelProvider>>) -> Self
Trait Implementations§
Source§impl StreamingModelProvider for AlloyedModelProvider
impl StreamingModelProvider for AlloyedModelProvider
fn stream_response(&self, context: &Context) -> LlmResponseStream
Source§fn model(&self) -> Option<LlmModel>
fn model(&self) -> Option<LlmModel>
The
LlmModel this provider is currently configured to use.
Returns None for providers where the model is unknown at compile time
(e.g. test fakes).fn display_name(&self) -> String
Source§fn context_window(&self) -> Option<u32>
fn context_window(&self) -> Option<u32>
Context window size in tokens for the current model.
Returns
None for unknown models (e.g. Ollama, LlamaCpp).Auto Trait Implementations§
impl !Freeze for AlloyedModelProvider
impl !RefUnwindSafe for AlloyedModelProvider
impl Send for AlloyedModelProvider
impl Sync for AlloyedModelProvider
impl Unpin for AlloyedModelProvider
impl UnsafeUnpin for AlloyedModelProvider
impl !UnwindSafe for AlloyedModelProvider
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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 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>
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 moreCreates a shared type from an unshared type.