use crate::error::LlmResult;
use crate::types::{ChatRequest, ChatResponse, EmbeddingRequest, EmbeddingResponse};
use async_trait::async_trait;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct ProviderCapabilities {
pub chat: bool,
pub embeddings: bool,
}
#[async_trait]
pub trait LlmProvider: Send + Sync {
fn name(&self) -> &str;
fn default_model(&self) -> &str;
fn capabilities(&self) -> ProviderCapabilities;
async fn chat(&self, request: &ChatRequest) -> LlmResult<ChatResponse>;
async fn embed(&self, request: &EmbeddingRequest) -> LlmResult<EmbeddingResponse>;
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_provider_capabilities() {
let caps = ProviderCapabilities {
chat: true,
embeddings: false,
};
assert!(caps.chat);
assert!(!caps.embeddings);
}
}