use async_trait::async_trait;
use futures::stream::BoxStream;
use crate::audio::{
AudioResponse, SpeechToTextRequest, TextToSpeechRequest, TranscriptionResponse,
};
use crate::embeddings::{EmbeddingsRequest, EmbeddingsResponse};
use crate::error::Error;
use crate::images::{ImagesRequest, ImagesResponse};
use crate::moderation::{ModerationRequest, ModerationResponse};
use crate::rerank::{RerankRequest, RerankResponse};
use crate::stream_event::StreamEvent;
use crate::structured::{StructuredRequest, StructuredResponse, StructuredStreamEvent};
use crate::text::{Step, TextRequest};
#[async_trait]
pub trait Provider: Send + Sync {
fn name(&self) -> &str;
async fn text_step(&self, request: &TextRequest) -> Result<Step, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "text"))
}
async fn stream_text_once(
&self,
request: &TextRequest,
) -> Result<BoxStream<'static, Result<StreamEvent, Error>>, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "stream_text"))
}
async fn structured(&self, request: StructuredRequest) -> Result<StructuredResponse, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "structured"))
}
async fn stream_structured_once(
&self,
request: &StructuredRequest,
) -> Result<BoxStream<'static, Result<StructuredStreamEvent, Error>>, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "stream_structured"))
}
async fn moderation(&self, request: ModerationRequest) -> Result<ModerationResponse, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "moderation"))
}
async fn embeddings(&self, request: EmbeddingsRequest) -> Result<EmbeddingsResponse, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "embeddings"))
}
async fn rerank(&self, request: RerankRequest) -> Result<RerankResponse, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "rerank"))
}
async fn images(&self, request: ImagesRequest) -> Result<ImagesResponse, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "images"))
}
async fn text_to_speech(&self, request: TextToSpeechRequest) -> Result<AudioResponse, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "text_to_speech"))
}
async fn speech_to_text(
&self,
request: SpeechToTextRequest,
) -> Result<TranscriptionResponse, Error> {
let _ = request;
Err(Error::unsupported(self.name(), "speech_to_text"))
}
}