Skip to content

Commit

Permalink
Add failed tooloutput that can be handled
Browse files Browse the repository at this point in the history
  • Loading branch information
timonv committed Nov 28, 2024
1 parent 97cc602 commit 1039306
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions swiftide-core/src/chat_completion/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ use derive_builder::Builder;
pub enum ToolOutput {
/// Adds the result of the toolcall to messages
Text(String),
Ok,

/// Indicates that the toolcall failed, but can be handled by the llm
Fail(String),
/// Stops an agent
///
Stop,
}

Expand All @@ -31,7 +32,7 @@ impl std::fmt::Display for ToolOutput {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
ToolOutput::Text(value) => write!(f, "{value}"),
ToolOutput::Ok => write!(f, "Ok"),
ToolOutput::Fail(value) => write!(f, "Tool call failed: {value}"),
ToolOutput::Stop => write!(f, "Stop"),
}
}
Expand Down
4 changes: 2 additions & 2 deletions swiftide-core/src/chat_completion/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl From<CommandOutput> for ToolOutput {
fn from(value: CommandOutput) -> Self {
match value {
CommandOutput::Text(value) => ToolOutput::Text(value),
CommandOutput::Ok => ToolOutput::Ok,
CommandOutput::Ok => ToolOutput::Text("Tool successfuly completed".to_string()),

Check warning on line 69 in swiftide-core/src/chat_completion/traits.rs

View workflow job for this annotation

GitHub Actions / Lint

"successfuly" should be "successfully".

Check failure on line 69 in swiftide-core/src/chat_completion/traits.rs

View workflow job for this annotation

GitHub Actions / Lint

`successfuly` should be `successfully`
CommandOutput::Shell {
stdout,
stderr,
Expand All @@ -76,7 +76,7 @@ impl From<CommandOutput> for ToolOutput {
if success {
ToolOutput::Text(stdout)
} else {
ToolOutput::Text(stderr)
ToolOutput::Fail(stderr)
}
}
}
Expand Down

0 comments on commit 1039306

Please sign in to comment.