Skip to main content

LLMCapability

Trait LLMCapability 

Source
pub trait LLMCapability: Send + Sync {
    // Required method
    fn llm_provider(&self) -> Option<&Arc<dyn LLMProvider>>;

    // Provided methods
    fn llm_ask<'life0, 'life1, 'async_trait>(
        &'life0 self,
        question: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = Result<String, LLMError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn llm_ask_with_system<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        system: &'life1 str,
        question: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<String, LLMError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait { ... }
    fn llm_chat<'life0, 'async_trait>(
        &'life0 self,
        request: ChatCompletionRequest,
    ) -> Pin<Box<dyn Future<Output = Result<ChatCompletionResponse, LLMError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

LLM 能力 trait

为 Agent 提供 LLM 交互能力

Required Methods§

Source

fn llm_provider(&self) -> Option<&Arc<dyn LLMProvider>>

获取 LLM 提供商

Provided Methods§

Source

fn llm_ask<'life0, 'life1, 'async_trait>( &'life0 self, question: &'life1 str, ) -> Pin<Box<dyn Future<Output = Result<String, LLMError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

简单问答

Source

fn llm_ask_with_system<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, system: &'life1 str, question: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<String, LLMError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

带系统提示的问答

Source

fn llm_chat<'life0, 'async_trait>( &'life0 self, request: ChatCompletionRequest, ) -> Pin<Box<dyn Future<Output = Result<ChatCompletionResponse, LLMError>> + Send + 'async_trait>>
where 'life0: 'async_trait, Self: 'async_trait,

发送完整的 Chat 请求

Implementors§