pub struct ModelContext {
pub provider: String,
pub model: String,
pub base_url: String,
pub api_key: Option<String>,
}Expand description
Pre-resolved model configuration created at gateway startup.
The gateway reads the configured provider + model from Config, fetches
the API key from the secrets vault, and holds everything in this struct
so per-connection handlers can call the provider without the client
needing to send credentials.
Fields§
§provider: String§model: String§base_url: String§api_key: Option<String>Implementations§
Source§impl ModelContext
impl ModelContext
Sourcepub fn resolve(config: &Config, secrets: &mut SecretsManager) -> Result<Self>
pub fn resolve(config: &Config, secrets: &mut SecretsManager) -> Result<Self>
Resolve the model context from the app configuration and secrets vault.
Returns an error if no [model] section is present in the config.
A missing API key is treated as a warning (the provider may not need
one — e.g. Ollama), not a hard error.
Sourcepub fn from_config(config: &Config, api_key: Option<String>) -> Result<Self>
pub fn from_config(config: &Config, api_key: Option<String>) -> Result<Self>
Build a model context from configuration and a pre-resolved API key.
Use this when the caller has already extracted the key (e.g. the CLI passes just the provider key to the daemon via an environment variable, so the gateway never needs vault access).
Trait Implementations§
Source§impl Clone for ModelContext
impl Clone for ModelContext
Source§fn clone(&self) -> ModelContext
fn clone(&self) -> ModelContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ModelContext
impl RefUnwindSafe for ModelContext
impl Send for ModelContext
impl Sync for ModelContext
impl Unpin for ModelContext
impl UnwindSafe for ModelContext
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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