use std::pin::Pin;
use async_trait::async_trait;
use futures_util::Stream;
use crate::error::BaochuanError;
use crate::types::{ChatRequest, ChatResponse, ModelInfo, StreamChunk, TtsRequest};
pub type ChunkStream = Pin<Box<dyn Stream<Item = Result<StreamChunk, BaochuanError>> + Send>>;
#[async_trait]
pub trait Provider: Send + Sync {
async fn chat(&self, request: &ChatRequest) -> Result<ChatResponse, BaochuanError>;
async fn stream_chat(&self, request: &ChatRequest) -> Result<ChunkStream, BaochuanError>;
async fn models(&self) -> Result<Vec<ModelInfo>, BaochuanError> {
Ok(vec![])
}
async fn tts(&self, _request: &TtsRequest) -> Result<Vec<u8>, BaochuanError> {
Err(BaochuanError::InvalidRequest(format!(
"{} does not support text-to-speech",
self.name()
)))
}
fn name(&self) -> &str;
}