Skip to main content

LlmClientFactory

Trait LlmClientFactory 

Source
pub trait LlmClientFactory: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn display_name(&self) -> &str;
    fn create(
        &self,
        config: &HashMap<String, String>,
    ) -> Result<Arc<dyn LlmClient>, LlmError>;
    fn validate_config(&self, config: &HashMap<String, String>) -> Vec<String>;
    fn required_config_keys(&self) -> Vec<&str>;
}
Expand description

Factory that creates LLM client instances from configuration.

Third-party LLM providers (Anthropic, Bedrock, vLLM, etc.) implement this trait to integrate with Razeri’s AI profiler.

Required Methods§

Source

fn name(&self) -> &str

Machine-readable provider name (e.g., “ollama”, “openai”, “anthropic”).

Source

fn display_name(&self) -> &str

Human-readable display name.

Source

fn create( &self, config: &HashMap<String, String>, ) -> Result<Arc<dyn LlmClient>, LlmError>

Create an LLM client from configuration (base_url, api_key, etc.).

§Errors

Returns an error if the operation fails.

Source

fn validate_config(&self, config: &HashMap<String, String>) -> Vec<String>

Validate configuration before creating a client.

Source

fn required_config_keys(&self) -> Vec<&str>

List required configuration keys (e.g., “base_url”, “api_key”).

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§