-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,722 additions
and
648 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@ai-sdk/anthropic': patch | ||
--- | ||
|
||
feat (provider/anthropic): add computer use tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
'@ai-sdk/amazon-bedrock': patch | ||
'@ai-sdk/google-vertex': patch | ||
'@ai-sdk/anthropic': patch | ||
'@ai-sdk/provider': patch | ||
'@ai-sdk/mistral': patch | ||
'@ai-sdk/cohere': patch | ||
'@ai-sdk/google': patch | ||
'@ai-sdk/openai': patch | ||
'@ai-sdk/groq': patch | ||
'ai': patch | ||
--- | ||
|
||
feat: provider-defined tools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
examples/ai-core/src/generate-text/anthropic-computer-use.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { anthropic } from '@ai-sdk/anthropic'; | ||
import { generateText } from 'ai'; | ||
import 'dotenv/config'; | ||
|
||
async function main() { | ||
const result = await generateText({ | ||
model: anthropic('claude-3-5-sonnet-20241022'), | ||
tools: { | ||
computer: anthropic.tools.computer_20241022({ | ||
displayWidthPx: 100, | ||
displayHeightPx: 100, | ||
async execute({ action, coordinate, text }) { | ||
return ''; | ||
}, | ||
}), | ||
bash: anthropic.tools.bash_20241022({ | ||
async execute({ command }) { | ||
return ` | ||
❯ ls | ||
README.md build data node_modules package.json src tsconfig.json | ||
`; | ||
}, | ||
}), | ||
str_replace_editor: anthropic.tools.textEditor_20241022({ | ||
async execute({ command, path, old_str, new_str }) { | ||
return ''; | ||
}, | ||
}), | ||
}, | ||
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.