pub struct Config {
pub models: HashMap<String, ModelConfig>,
pub embedding: Option<EmbeddingConfig>,
/* private fields */
}Expand description
全局配置,持有所有已加载的模型配置表
Fields§
§models: HashMap<String, ModelConfig>§embedding: Option<EmbeddingConfig>Implementations§
Source§impl Config
impl Config
Sourcepub fn load() -> Result<Config, ReactError>
pub fn load() -> Result<Config, ReactError>
加载配置(只读取 YAML 配置文件)
每次调用都重新读取文件,不使用缓存。
如需缓存请使用 load_cached。
Sourcepub fn load_cached() -> Result<&'static Config, ReactError>
pub fn load_cached() -> Result<&'static Config, ReactError>
惰性加载并缓存配置(进程级单例)
首次调用时执行 load,后续调用返回缓存结果。
加载失败时缓存错误信息,不 panic。
Sourcepub fn get_model(model: &str) -> Result<ModelConfig, ReactError>
pub fn get_model(model: &str) -> Result<ModelConfig, ReactError>
获取指定模型的配置
Sourcepub fn list_models() -> Vec<String>
pub fn list_models() -> Vec<String>
列出所有可用的模型名称
配置加载失败时返回空列表(不 panic)。
Sourcepub fn get_embedding() -> Result<EmbeddingConfig, ReactError>
pub fn get_embedding() -> Result<EmbeddingConfig, ReactError>
获取 embedding 配置
Sourcepub fn has_embedding() -> bool
pub fn has_embedding() -> bool
检查 embedding 配置是否存在
Sourcepub fn from_env() -> Result<Config, ReactError>
pub fn from_env() -> Result<Config, ReactError>
向后兼容:from_env 是 load 的别名
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Config
impl<'de> Deserialize<'de> for Config
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Config, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Config, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Config
impl Serialize for Config
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
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§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnsafeUnpin for Config
impl UnwindSafe for Config
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request