rune-chain-core 0.1.0

Core traits and types for the rune-chain LLM orchestration framework
Documentation
use thiserror::Error;

/// Errors produced by a [`Chain`](crate::Chain) during execution.
#[derive(Debug, Error)]
pub enum ChainError {
    /// The underlying LLM returned an error.
    #[error("LLM error: {0}")]
    LlmError(String),
    /// A required prompt variable was missing from the input map.
    #[error("missing prompt variable: {0}")]
    MissingVariable(String),
    /// The chain's memory layer failed.
    #[error("memory error: {0}")]
    MemoryError(String),
    /// Any error not covered by the variants above.
    #[error("{0}")]
    Other(String),
}

/// Errors produced by an [`Llm`](crate::Llm) during generation.
#[derive(Debug, Error)]
pub enum LlmError {
    /// HTTP or network-level failure contacting the provider.
    #[error("request failed: {0}")]
    RequestFailed(String),
    /// The provider rejected the request (auth, quota, rate limit, …).
    #[error("provider error: {0}")]
    ProviderError(String),
    /// The model returned a response that could not be decoded.
    #[error("invalid response: {0}")]
    InvalidResponse(String),
    /// Any error not covered by the variants above.
    #[error("{0}")]
    Other(String),
}

impl From<LlmError> for ChainError {
    fn from(err: LlmError) -> Self {
        ChainError::LlmError(err.to_string())
    }
}