reagent-rs 0.2.9

A Rust library for building AI agents with MCP, custom tools and skills
Documentation
use crate::services::llm::InferenceClientError;

#[derive(Debug)]
pub enum InvocationError {
    ModelNotDefined,
    InferenceError(InferenceClientError),
    /// Provided JSON schema for response format could not be parsed.
    InvalidJsonSchema(String),
}

impl From<InferenceClientError> for InvocationError {
    fn from(err: InferenceClientError) -> Self {
        InvocationError::InferenceError(err)
    }
}

impl std::error::Error for InvocationError {}

impl std::fmt::Display for InvocationError {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            InvocationError::ModelNotDefined => write!(f, "Inference model not defined"),
            InvocationError::InferenceError(inference_client_error) => {
                write!(f, "Client error during inference: {inference_client_error}")
            }
            InvocationError::InvalidJsonSchema(e) => write!(f, "Invalid JSON schema provided: {e}"),
        }
    }
}