Skip to main content

LlmClient

Trait LlmClient 

Source
pub trait LlmClient: Send + Sync {
    // Required methods
    fn structured_call<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        messages: &'life1 [Message],
        schema: &'life2 Value,
    ) -> Pin<Box<dyn Future<Output = Result<(Option<Value>, Vec<ToolCall>, String), SgrError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn tools_call<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        messages: &'life1 [Message],
        tools: &'life2 [ToolDef],
    ) -> Pin<Box<dyn Future<Output = Result<Vec<ToolCall>, SgrError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn complete<'life0, 'life1, 'async_trait>(
        &'life0 self,
        messages: &'life1 [Message],
    ) -> Pin<Box<dyn Future<Output = Result<String, SgrError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn tools_call_stateful<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        messages: &'life1 [Message],
        tools: &'life2 [ToolDef],
        _previous_response_id: Option<&'life3 str>,
    ) -> Pin<Box<dyn Future<Output = Result<(Vec<ToolCall>, Option<String>), SgrError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait { ... }
}
Expand description

Abstract LLM client for agent framework.

Required Methods§

Source

fn structured_call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, messages: &'life1 [Message], schema: &'life2 Value, ) -> Pin<Box<dyn Future<Output = Result<(Option<Value>, Vec<ToolCall>, String), SgrError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Structured call: send messages with schema injected into system prompt. Returns (parsed_output, native_tool_calls, raw_text).

Source

fn tools_call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, messages: &'life1 [Message], tools: &'life2 [ToolDef], ) -> Pin<Box<dyn Future<Output = Result<Vec<ToolCall>, SgrError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Native function calling: send messages + tool defs, get tool calls. This is STATELESS — no side effects on shared state.

Source

fn complete<'life0, 'life1, 'async_trait>( &'life0 self, messages: &'life1 [Message], ) -> Pin<Box<dyn Future<Output = Result<String, SgrError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Plain text completion (no schema, no tools).

Provided Methods§

Source

fn tools_call_stateful<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, messages: &'life1 [Message], tools: &'life2 [ToolDef], _previous_response_id: Option<&'life3 str>, ) -> Pin<Box<dyn Future<Output = Result<(Vec<ToolCall>, Option<String>), SgrError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Stateful function calling with explicit response_id for chaining. Returns (tool_calls, new_response_id). When previous_response_id is Some, only delta messages are needed.

Implementors§