use crate::config::ProviderConfig;
use crate::types::{ChatRequest, ChatResponse, StreamChunk};
use anyhow::Result;
use async_trait::async_trait;
use bytes::Bytes;
#[derive(Debug)]
pub struct ProviderRequest {
pub url: String,
pub method: String,
pub headers: Vec<(String, String)>,
pub body: Bytes,
}
#[async_trait]
pub trait TransformLayer: Send + Sync {
async fn transform_request(
&self,
request: &ChatRequest,
api_key: &str,
provider: &ProviderConfig,
) -> Result<ProviderRequest>;
async fn transform_response(
&self,
status: u16,
body: Bytes,
provider: &ProviderConfig,
) -> Result<ChatResponse>;
async fn transform_stream_chunk(
&self,
chunk: &str,
provider: &ProviderConfig,
) -> Result<Option<StreamChunk>>;
}