Provider

Trait Provider 

Source
pub trait Provider: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn chat<'life0, 'life1, 'async_trait>(
        &'life0 self,
        request: &'life1 ChatRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmConnectorError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn models<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, LlmConnectorError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn as_any(&self) -> &dyn Any;
}
Expand description

服务提供商trait - 定义统一的服务接口

这个trait代表一个具体的LLM服务提供商,提供完整的服务功能。 它是用户直接交互的接口。

Required Methods§

Source

fn name(&self) -> &str

提供商名称 (如 “openai”, “aliyun”, “ollama”)

Source

fn chat<'life0, 'life1, 'async_trait>( &'life0 self, request: &'life1 ChatRequest, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse, LlmConnectorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

聊天完成

Source

fn models<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<Vec<String>, LlmConnectorError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

获取可用模型列表

Source

fn as_any(&self) -> &dyn Any

类型转换支持 (用于特殊功能访问)

Implementors§