rune-chain-core 0.1.2

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(#[from] LlmError),
    /// 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),
    /// A tool invoked by an agent returned an error.
    #[error("tool error: {0}")]
    ToolError(#[from] ToolError),
    /// Output could not be parsed into the expected type.
    #[error("parse error: {0}")]
    ParseError(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, Clone)]
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),
    /// Function/tool calling is not supported by this provider.
    #[error("tool use not supported: {0}")]
    ToolUseNotSupported(String),
    /// Any error not covered by the variants above.
    #[error("{0}")]
    Other(String),
}

/// Errors produced by a [`Tool`](crate::Tool) during execution.
#[derive(Debug, Error, Clone)]
pub enum ToolError {
    /// The input provided to the tool was invalid or could not be parsed.
    #[error("invalid input: {0}")]
    InvalidInput(String),
    /// The tool's operation failed at runtime.
    #[error("execution failed: {0}")]
    ExecutionFailed(String),
    /// Any error not covered by the variants above.
    #[error("{0}")]
    Other(String),
}