Skip to content

Commit

Permalink
update bash example
Browse files Browse the repository at this point in the history
  • Loading branch information
lgrammel committed Oct 25, 2024
1 parent 61d3cbb commit 73a2013
Showing 1 changed file with 1 addition and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ async function main() {
tools: {
bash: anthropic.tools.bash_20241022({
async execute({ command }) {
console.log('COMMAND', command);
return [
{
type: 'text',
Expand All @@ -19,30 +20,12 @@ async function main() {
];
},
}),
str_replace_editor: anthropic.tools.textEditor_20241022({
async execute({ command, path, old_str, new_str }) {
return [{ type: 'text', text: '' }];
},
}),
},
prompt: 'List the files in my home directory.',
maxSteps: 2,
});

for (const toolResult of result.toolResults) {
switch (toolResult.toolName) {
case 'bash': {
toolResult.args.command; // string
toolResult.result; // string
break;
}
}
}

console.log(result.text);
console.log(result.finishReason);
console.log(JSON.stringify(result.toolCalls, null, 2));
console.log(JSON.stringify(result.steps, null, 2));
}

main().catch(console.error);

0 comments on commit 73a2013

Please sign in to comment.