Skip to content

Commit

Permalink
fmt fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andthattoo committed Oct 3, 2024
1 parent f761927 commit f187380
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/program/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ impl fmt::Display for ExecutionError {
ExecutionError::WorkflowFailed(cmd) => write!(f, "Workflow execution failed: {}", cmd),
ExecutionError::InvalidInput => write!(f, "Invalid input provided"),
ExecutionError::UnexpectedOutput => write!(f, "Unexpected output from command"),
ExecutionError::GenerationFailed(detail) => write!(f, "Text generation failed {}", detail),
ExecutionError::FunctionCallFailed(detail) => write!(f, "Function call failed {}", detail),
ExecutionError::GenerationFailed(detail) => {
write!(f, "Text generation failed {}", detail)
}
ExecutionError::FunctionCallFailed(detail) => {
write!(f, "Function call failed {}", detail)
}
ExecutionError::VectorSearchFailed => write!(f, "Vector search failed"),
ExecutionError::StringCheckFailed => write!(f, "Vector search failed"),
ExecutionError::SamplingError => {
Expand Down
28 changes: 22 additions & 6 deletions src/program/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,16 @@ impl Executor {
} else {
warn!("{} failed, halting beacause of no fallback", &edge.source);
error!("Task execution failed");
return Err(ExecutionError::WorkflowFailed(format!("{:?}", result.unwrap_err())));
return Err(ExecutionError::WorkflowFailed(format!(
"{:?}",
result.unwrap_err()
)));
};
} else {
return Err(ExecutionError::WorkflowFailed(format!("Task with id [{}] not found", &edge.source)));
return Err(ExecutionError::WorkflowFailed(format!(
"Task with id [{}] not found",
&edge.source
)));
}
} else {
break;
Expand All @@ -175,12 +181,16 @@ impl Executor {
// log if elapsed time is bigger the max time
if start.elapsed().as_secs() >= max_time {
warn!("Max time exceeded, halting");
return Err(ExecutionError::WorkflowFailed("Max execution time exceeded".to_string()));
return Err(ExecutionError::WorkflowFailed(
"Max execution time exceeded".to_string(),
));
}
// log if max steps is reached
if num_steps >= max_steps {
warn!("Max steps reached, halting");
return Err(ExecutionError::WorkflowFailed("Max steps reached".to_string()));
return Err(ExecutionError::WorkflowFailed(
"Max steps reached".to_string(),
));
}
let rv = workflow.get_return_value();
let return_value = self.handle_input(&rv.input, memory).await;
Expand Down Expand Up @@ -253,7 +263,10 @@ impl Executor {
let result = self.generate_text(&prompt, config).await;
if result.is_err() {
error!("Error generating text");
return Err(ExecutionError::GenerationFailed(format!("{:?}", result.err().unwrap())));
return Err(ExecutionError::GenerationFailed(format!(
"{:?}",
result.err().unwrap()
)));
}
debug!("Prompt: {}", &prompt);
log_colored(
Expand All @@ -270,7 +283,10 @@ impl Executor {
let result = self.function_call(&prompt, config, raw_mode).await;
if result.is_err() {
error!("Error function calling");
return Err(ExecutionError::FunctionCallFailed(format!("{:?}", result.err().unwrap())));
return Err(ExecutionError::FunctionCallFailed(format!(
"{:?}",
result.err().unwrap()
)));
}
debug!("Prompt: {}", &prompt);
log_colored(
Expand Down

0 comments on commit f187380

Please sign in to comment.