pub struct LlmProviderFactory;Expand description
Factory for creating LLM provider adapters by name.
Each provider is only available when the corresponding feature flag is
enabled (openai, anthropic, or deepseek).
§Example
use paladin_llm::provider_factory::LlmProviderFactory;
let factory = LlmProviderFactory::new();
let provider = factory.create("openai").expect("OPENAI_API_KEY must be set");Implementations§
Source§impl LlmProviderFactory
impl LlmProviderFactory
Sourcepub fn new() -> LlmProviderFactory
pub fn new() -> LlmProviderFactory
Create a new provider factory.
Sourcepub fn create(
&self,
provider_name: &str,
) -> Result<Arc<dyn LlmPort>, ProviderFactoryError>
pub fn create( &self, provider_name: &str, ) -> Result<Arc<dyn LlmPort>, ProviderFactoryError>
Create an LlmPort adapter by provider name.
Configuration is loaded from environment variables (see each adapter’s
*Config::from_env() for the expected variable names).
§Errors
Returns ProviderFactoryError if the provider name is unknown, a
required environment variable is absent, or the adapter fails to
initialise.
Sourcepub fn get_default_provider() -> Option<String>
pub fn get_default_provider() -> Option<String>
Return the name of the first available provider based on environment
variables, or None if no API keys are set.
Priority: OpenAI → DeepSeek → Anthropic.
Sourcepub fn list_available_providers() -> Vec<String>
pub fn list_available_providers() -> Vec<String>
Return the names of all providers that have API keys configured.
Trait Implementations§
Source§impl Default for LlmProviderFactory
impl Default for LlmProviderFactory
Source§fn default() -> LlmProviderFactory
fn default() -> LlmProviderFactory
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LlmProviderFactory
impl RefUnwindSafe for LlmProviderFactory
impl Send for LlmProviderFactory
impl Sync for LlmProviderFactory
impl Unpin for LlmProviderFactory
impl UnsafeUnpin for LlmProviderFactory
impl UnwindSafe for LlmProviderFactory
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 more