Skip to main content

LlmConfig

Struct LlmConfig 

Source
pub struct LlmConfig {
Show 19 fields pub providers: Vec<ProviderEntry>, pub routing: LlmRoutingStrategy, pub routes: HashMap<String, Vec<String>>, pub embedding_model: String, pub candle: Option<CandleConfig>, pub stt: Option<SttConfig>, pub response_cache_enabled: bool, pub response_cache_ttl_secs: u64, pub semantic_cache_enabled: bool, pub semantic_cache_threshold: f32, pub semantic_cache_max_candidates: u32, pub router_ema_enabled: bool, pub router_ema_alpha: f64, pub router_reorder_interval: u64, pub router: Option<RouterConfig>, pub instruction_file: Option<PathBuf>, pub summary_model: Option<String>, pub summary_provider: Option<ProviderEntry>, pub complexity_routing: Option<ComplexityRoutingConfig>,
}
Expand description

LLM configuration, nested under [llm] in TOML.

Declares the provider pool and controls routing, embedding, caching, and STT. All providers are declared in [[llm.providers]]; subsystems reference them by the name field using a *_provider config key.

§Example (TOML)

[[llm.providers]]
name = "fast"
type = "openai"
model = "gpt-4o-mini"

[[llm.providers]]
name = "quality"
type = "claude"
model = "claude-opus-4-5"

[llm]
routing = "none"
embedding_model = "qwen3-embedding"

Fields§

§providers: Vec<ProviderEntry>

Provider pool. First entry is default unless one is marked default = true.

§routing: LlmRoutingStrategy

Routing strategy for multi-provider configs.

§routes: HashMap<String, Vec<String>>

Task-based routes (only used when routing = "task").

§embedding_model: String§candle: Option<CandleConfig>§stt: Option<SttConfig>§response_cache_enabled: bool§response_cache_ttl_secs: u64§semantic_cache_enabled: bool

Enable semantic similarity-based response caching. Requires embedding support.

§semantic_cache_threshold: f32

Cosine similarity threshold for semantic cache hits (0.0–1.0).

Only the highest-scoring candidate above this threshold is returned. Lower values produce more cache hits but risk returning less relevant responses. Recommended range: 0.92–0.98; default: 0.95.

§semantic_cache_max_candidates: u32

Maximum cached entries to examine per semantic lookup (SQL LIMIT clause in ResponseCache::get_semantic()). Controls the recall-vs-performance tradeoff:

  • Higher values (e.g. 50): scan more entries, better chance of finding a semantically similar cached response, but slower queries.
  • Lower values (e.g. 5): faster queries, but may miss relevant cached entries when the cache is large.
  • Default (10): balanced middle ground for typical workloads.

Tuning guidance: set to 50+ when recall matters more than latency (e.g. long-running sessions with many cached responses); reduce to 5 for low-latency interactive use. Env override: ZEPH_LLM_SEMANTIC_CACHE_MAX_CANDIDATES.

§router_ema_enabled: bool§router_ema_alpha: f64§router_reorder_interval: u64§router: Option<RouterConfig>

Routing configuration for Thompson/Cascade strategies.

§instruction_file: Option<PathBuf>

Provider-specific instruction file to inject into the system prompt. Merged with agent.instruction_files at startup.

§summary_model: Option<String>

Shorthand model spec for tool-pair summarization and context compaction. Format: ollama/<model>, claude[/<model>], openai[/<model>], compatible/<name>, candle. Ignored when [llm.summary_provider] is set.

§summary_provider: Option<ProviderEntry>

Structured provider config for summarization. Takes precedence over summary_model.

§complexity_routing: Option<ComplexityRoutingConfig>

Complexity triage routing configuration. Required when routing = "triage".

Implementations§

Source§

impl LlmConfig

Source

pub fn effective_provider(&self) -> ProviderKind

Effective provider kind for the primary (first/default) provider in the pool.

Source

pub fn effective_base_url(&self) -> &str

Effective base URL for the primary provider.

Source

pub fn effective_model(&self) -> &str

Effective model for the primary provider.

Source

pub fn stt_provider_entry(&self) -> Option<&ProviderEntry>

Find the provider entry designated for STT.

Resolution priority:

  1. [llm.stt].provider matches [[llm.providers]].name and the entry has stt_model
  2. [llm.stt].provider is empty — fall through to auto-detect
  3. First provider with stt_model set (auto-detect fallback)
  4. None — STT disabled
Source

pub fn check_legacy_format(&self) -> Result<(), ConfigError>

Validate that the config uses the new [[llm.providers]] format.

§Errors

Returns ConfigError::Validation when no providers are configured.

Source

pub fn validate_stt(&self) -> Result<(), ConfigError>

Validate STT config cross-references.

§Errors

Returns ConfigError::Validation when the referenced STT provider does not exist.

Trait Implementations§

Source§

impl Debug for LlmConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for LlmConfig

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<LlmConfig, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for LlmConfig

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,