Skip to main content

TransformLayer

Trait TransformLayer 

Source
pub trait TransformLayer: Send + Sync {
    // Required methods
    fn transform_request<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 self,
        request: &'life1 ChatRequest,
        api_key: &'life2 str,
        provider: &'life3 ProviderConfig,
    ) -> Pin<Box<dyn Future<Output = Result<ProviderRequest>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
    fn transform_response<'life0, 'life1, 'async_trait>(
        &'life0 self,
        status: u16,
        body: Bytes,
        provider: &'life1 ProviderConfig,
    ) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn transform_stream_chunk<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        chunk: &'life1 str,
        provider: &'life2 ProviderConfig,
    ) -> Pin<Box<dyn Future<Output = Result<Option<StreamChunk>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
}

Required Methods§

Source

fn transform_request<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 self, request: &'life1 ChatRequest, api_key: &'life2 str, provider: &'life3 ProviderConfig, ) -> Pin<Box<dyn Future<Output = Result<ProviderRequest>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Convert a ChatRequest into the provider’s HTTP format.

Source

fn transform_response<'life0, 'life1, 'async_trait>( &'life0 self, status: u16, body: Bytes, provider: &'life1 ProviderConfig, ) -> Pin<Box<dyn Future<Output = Result<ChatResponse>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Parse a provider’s HTTP response into ChatResponse.

Source

fn transform_stream_chunk<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, chunk: &'life1 str, provider: &'life2 ProviderConfig, ) -> Pin<Box<dyn Future<Output = Result<Option<StreamChunk>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Parse one SSE chunk from the provider into our StreamChunk. Returns None if the chunk is a keep-alive or should be skipped.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§