pub struct ProviderChain { /* private fields */ }Expand description
An ordered chain of providers with sticky demotion.
Built once per process from Config::providers() and shared across the
analyzer, so the demotion one file discovers is visible to every other.
Implementations§
Source§impl ProviderChain
impl ProviderChain
Sourcepub fn new(cfgs: &[&LlmConfig]) -> Result<Self, LlmError>
pub fn new(cfgs: &[&LlmConfig]) -> Result<Self, LlmError>
Build a chain from the enabled providers, in order.
A misconfigured entry is fatal rather than skipped. Skipping it would
be the same masking that the 401 rule forbids: an endpoint-less
[[llm]] block is a broken install, and a gate that quietly routes
around it is a gate reporting on a configuration the user did not
write. The index is carried into the message because with several
providers “LLM model is not set” does not say which one.
Sourcepub async fn complete_json(
&self,
system_prompt: &str,
user_content: &str,
cache: &Cache,
) -> Result<Served, ChainError>
pub async fn complete_json( &self, system_prompt: &str, user_content: &str, cache: &Cache, ) -> Result<Served, ChainError>
Send one prompt down the chain, consulting the cache per provider.
Returns the first answer anyone gives, or every provider’s reason for not giving one.
Sourcepub fn cached_json(
&self,
system_prompt: &str,
user_content: &str,
cache: &Cache,
) -> Option<Served>
pub fn cached_json( &self, system_prompt: &str, user_content: &str, cache: &Cache, ) -> Option<Served>
Return the first cached answer in provider order without contacting any backend. A miss is not a provider failure: nothing was attempted and no provider should be demoted merely because this machine has not reviewed the payload yet.