Skip to main content

LLMClient

Trait LLMClient 

Source
pub trait LLMClient: Send + Sync {
    // Required methods
    fn generate<'life0, 'life1, 'async_trait>(
        &'life0 self,
        prompt: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = PluginResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn generate_stream<'life0, 'life1, 'async_trait>(
        &'life0 self,
        prompt: &'life1 str,
        callback: Box<dyn Fn(String) + Send + Sync>,
    ) -> Pin<Box<dyn Future<Output = PluginResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn chat<'life0, 'async_trait>(
        &'life0 self,
        messages: Vec<ChatMessage>,
    ) -> Pin<Box<dyn Future<Output = PluginResult<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn embedding<'life0, 'life1, 'async_trait>(
        &'life0 self,
        text: &'life1 str,
    ) -> Pin<Box<dyn Future<Output = PluginResult<Vec<f32>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

LLM 客户端 trait

Required Methods§

Source

fn generate<'life0, 'life1, 'async_trait>( &'life0 self, prompt: &'life1 str, ) -> Pin<Box<dyn Future<Output = PluginResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

生成文本

Source

fn generate_stream<'life0, 'life1, 'async_trait>( &'life0 self, prompt: &'life1 str, callback: Box<dyn Fn(String) + Send + Sync>, ) -> Pin<Box<dyn Future<Output = PluginResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

流式生成

Source

fn chat<'life0, 'async_trait>( &'life0 self, messages: Vec<ChatMessage>, ) -> Pin<Box<dyn Future<Output = PluginResult<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

聊天完成

Source

fn embedding<'life0, 'life1, 'async_trait>( &'life0 self, text: &'life1 str, ) -> Pin<Box<dyn Future<Output = PluginResult<Vec<f32>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

获取嵌入向量

Implementors§