Trait LowLevelClient

Source
pub trait LowLevelClient:
    Send
    + Sync
    + Debug {
    // Required methods
    fn ask_raw<'life0, 'async_trait>(
        &'life0 self,
        prompt: String,
    ) -> Pin<Box<dyn Future<Output = Result<String, AIError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn clone_box(&self) -> Box<dyn LowLevelClient>;

    // Provided method
    fn ask_json<'life0, 'async_trait>(
        &'life0 self,
        prompt: String,
    ) -> Pin<Box<dyn Future<Output = Result<String, AIError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Low-level client trait that only requires implementing ask_raw. This trait can be used as dyn LowLevelClient for dynamic dispatch. JSON processing is handled by utility functions with a convenience method.

Required Methods§

Source

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

The only method that implementations must provide

Source

fn clone_box(&self) -> Box<dyn LowLevelClient>

Clone this client into a boxed trait object

Provided Methods§

Source

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

Simple JSON extraction from a prompt response (default implementation)

Trait Implementations§

Source§

impl Clone for Box<dyn LowLevelClient>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl LowLevelClient for Box<dyn LowLevelClient>

Source§

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

The only method that implementations must provide
Source§

fn clone_box(&self) -> Box<dyn LowLevelClient>

Clone this client into a boxed trait object
Source§

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

Simple JSON extraction from a prompt response (default implementation)

Implementations on Foreign Types§

Source§

impl LowLevelClient for Box<dyn LowLevelClient>

Source§

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

Source§

fn clone_box(&self) -> Box<dyn LowLevelClient>

Implementors§