diff --git a/src/lib.rs b/src/lib.rs index 0076d43..6c7290f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,7 +77,7 @@ use types::{LoomError, SummaryModelTokens, WeaveError}; use crate::types::{PromptModelTokens, WrapperRole}; -pub type Result = std::result::Result>; +pub type Result = std::result::Result; /// Represents a unique identifier for any arbitrary entity. /// diff --git a/src/loom.rs b/src/loom.rs index 8ef1aec..a4f9719 100644 --- a/src/loom.rs +++ b/src/loom.rs @@ -52,10 +52,7 @@ impl Loom { tapestry_id: TID, instructions: String, mut msgs: Vec>, - ) -> Result< - (<::PromptModel as Llm>::Response, u64, bool), - Box, - > { + ) -> Result<(<::PromptModel as Llm>::Response, u64, bool), LoomError> { let instructions_ctx_msg = Self::build_context_message(SYSTEM_ROLE.into(), instructions, None); let instructions_req_msg: PromptModelRequest = instructions_ctx_msg.clone().into(); @@ -211,7 +208,7 @@ impl Loom { summary_model_config: &LlmConfig, tapestry_fragment: &TapestryFragment, summary_max_tokens: SummaryModelTokens, - ) -> Result> { + ) -> Result { trace!( "Generating summary with max tokens: {:?}, for tapestry fragment: {:?}", summary_max_tokens, diff --git a/src/types.rs b/src/types.rs index f78cec1..d7d3e43 100644 --- a/src/types.rs +++ b/src/types.rs @@ -65,16 +65,7 @@ pub enum LoomError { #[error("Storage error: {0}")] Storage(#[from] StorageError), #[error("Error: {0}")] - Error(String), -} - -impl From> for LoomError { - fn from(error: Box) -> Self { - match error.downcast::() { - Ok(loom_error) => *loom_error, - Err(error) => LoomError::Error(error.to_string()), - } - } + UnknownError(String), } #[derive(Debug, thiserror::Error)] @@ -83,6 +74,10 @@ pub enum WeaveError { MaxCompletionTokensIsZero, #[error("Bad configuration: {0}")] BadConfig(String), + #[error("Not enough credits to cover cost")] + NotEnoughCredits, + #[error("Unknown error: {0}")] + Unknown(String), } #[derive(Debug, thiserror::Error)]