use rig::completion::Message;
#[derive(Debug, Clone)]
pub struct ReActConfig {
pub max_iterations: usize,
pub verbose: bool,
pub return_partial_on_max_depth: bool,
pub enable_summary_reasoning: bool,
}
impl Default for ReActConfig {
fn default() -> Self {
Self {
max_iterations: 15,
verbose: cfg!(debug_assertions),
return_partial_on_max_depth: true,
enable_summary_reasoning: true,
}
}
}
#[derive(Debug, Clone)]
pub struct ReActResponse {
pub content: String,
pub iterations_used: usize,
pub stopped_by_max_depth: bool,
pub tool_calls_history: Vec<String>,
pub chat_history: Option<Vec<Message>>,
}
impl ReActResponse {
pub fn new(
content: String,
iterations_used: usize,
stopped_by_max_depth: bool,
tool_calls_history: Vec<String>,
chat_history: Option<Vec<Message>>,
) -> Self {
Self {
content,
iterations_used,
stopped_by_max_depth,
tool_calls_history,
chat_history,
}
}
pub fn success(content: String, iterations_used: usize) -> Self {
Self::new(content, iterations_used, false, Vec::new(), None)
}
pub fn max_depth_reached_with_history(
content: String,
max_depth: usize,
tool_calls_history: Vec<String>,
chat_history: Vec<Message>,
) -> Self {
Self::new(
content,
max_depth,
true,
tool_calls_history,
Some(chat_history),
)
}
pub fn from_summary_reasoning(
content: String,
max_depth: usize,
tool_calls_history: Vec<String>,
chat_history: Vec<Message>,
) -> Self {
Self::new(
content,
max_depth,
true,
tool_calls_history,
Some(chat_history),
)
}
}