Skip to content

Commit 381d2d2

Browse files
committed
new: improved shell namespace output
1 parent d40e018 commit 381d2d2

File tree

3 files changed

+14
-13
lines changed

3 files changed

+14
-13
lines changed

examples/shell/task.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@ using:
55
- 'goal'
66

77
system_prompt: >
8-
You are an useful assistant that executes any task the user provides.
9-
10-
8+
You are an useful assistant that executes any task the user provides.

src/agent/generator/ollama.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl Client for OllamaClient {
166166
}
167167
}
168168

169-
log::debug!("ollama.tools={:?}", &tools);
169+
log::trace!("ollama.tools={:?}", &tools);
170170
}
171171

172172
let mut request = ChatMessageRequest::new(self.model.to_string(), chat_history)
@@ -185,6 +185,8 @@ impl Client for OllamaClient {
185185
let mut invocations = vec![];
186186

187187
if let Some(tool_calls) = msg.tool_calls.as_ref() {
188+
log::debug!("ollama.tool.calls = {:?}", tool_calls);
189+
188190
for call in tool_calls {
189191
let mut attributes = HashMap::new();
190192
let mut payload = None;

src/agent/namespaces/shell/mod.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -37,27 +37,28 @@ impl Action for Shell {
3737
payload: Option<String>,
3838
) -> Result<Option<String>> {
3939
let command = payload.unwrap();
40+
log::debug!("{}", &command);
41+
4042
// TODO: make the shell configurable
4143
let output = Command::new("/bin/sh")
4244
.arg("-c")
4345
.arg(&command)
4446
.output()
4547
.await?;
4648

47-
let stdout = String::from_utf8_lossy(&output.stdout).to_string();
48-
println!("{}", &stdout);
49+
let mut result = String::from_utf8_lossy(&output.stdout).to_string();
50+
println!("{}", &result);
4951

5052
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
5153
if !stderr.is_empty() {
52-
eprintln!("{}", stderr);
54+
eprintln!("{}", &stderr);
55+
result += &format!("\nSTDERR: {}\n", stderr);
5356
}
5457

55-
let result = format!(
56-
"Exit Code: {}\n\nStdout:\n{}\n\nStderr:\n{}",
57-
output.status.code().unwrap_or(-1),
58-
stdout,
59-
stderr
60-
);
58+
let exit_code = output.status.code().unwrap_or(-1);
59+
if exit_code != 0 {
60+
result += &format!("\nEXIT CODE: {}", exit_code);
61+
}
6162

6263
log::debug!("{}", &result);
6364

0 commit comments

Comments
 (0)