use async_trait::async_trait;
use serde_json::Value;
use thiserror::Error;
#[derive(Debug, Error)]
pub enum LlmError {
#[error("no recorded response for request id {0}\nhint: either re-record the baseline or run with --backend live")]
MissingResponse(String),
#[error(
"io error talking to LLM: {0}\nhint: check network connectivity and provider credentials"
)]
Io(String),
#[error("invalid request payload: {0}\nhint: check that the payload matches SPEC §4.1")]
BadRequest(String),
#[error(
"backend misconfigured: {0}\nhint: see the backend's documentation for required fields"
)]
Config(String),
}
#[async_trait]
pub trait LlmBackend: Send + Sync {
async fn complete(&self, request: &Value) -> Result<Value, LlmError>;
fn id(&self) -> &str;
}