rag_toolchain/chains/
types.rs

1use thiserror::Error;
2
3/// # [`RagChainError`]
4///
5/// This enum represents the possible errors that can occur when using the BasicRAGChain.
6/// It is parametrized over the error types of the chat client and the retriever. this way
7/// concrete error types are preserved and can be handled accordingly.
8///
9/// * `T` - The error type of the chat client
10/// * `U` - The error type of the retriever
11#[derive(Error, Debug, PartialEq)]
12pub enum RagChainError<T, U>
13where
14    T: std::error::Error + std::fmt::Display,
15    U: std::error::Error + std::fmt::Display,
16{
17    #[error("Chat Client Error: {0}")]
18    ChatClientError(T),
19    #[error("Retriever Error: {0}")]
20    RetrieverError(U),
21}
22
23/// # [`ChainError`]
24///
25/// This enum represents the possible errors that can occur when using the ChatHistoryChain.
26/// It is parametrized over the error type of the chat client. this way concrete error types are
27/// preserved and can be handled accordingly.
28#[derive(Error, Debug, PartialEq)]
29pub enum ChainError<T>
30where
31    T: std::error::Error + std::fmt::Display,
32{
33    #[error("Chat Client Error: {0}")]
34    ChatClientError(T),
35}