pub trait KeySource: Send + Sync {
// Required method
fn get_api_key<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, ProviderError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
用于获取 LLM Provider API Key 的可插拔 trait。
不同场景下 API Key 来源不同:
- 配置文件(
ConfigKeySource) - 用户自己提供(
UserKeySource)
所有实现均通过本 trait 统一接口接入 ProviderRouter。
Required Methods§
Sourcefn get_api_key<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_api_key<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String, ProviderError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
获取 API Key。
对于 ConfigKeySource:直接从配置中读取。
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".