Skip to content

Commit

Permalink
Anthropic Bedrock support (#945)
Browse files Browse the repository at this point in the history
* feat: ✨ Add support for Anthropic Bedrock models

* feat: ✨ Add support for Anthropic Bedrock provider

* feat: integrate fetch with retry logic 🚀

* feat: ➕ add new model option to ModelType enum

* feat: ✨ add new Anthropics models to prompt options

* refactor: update fetch retries and logging enhancements ✨

* docs: 📝 update Anthropic Bedrock configuration info

* docs: update weather and tool sections 🌦️🛠️
  • Loading branch information
pelikhan authored Dec 13, 2024
1 parent fe1c3cc commit dc60e07
Show file tree
Hide file tree
Showing 14 changed files with 1,589 additions and 184 deletions.
12 changes: 11 additions & 1 deletion docs/src/content/docs/getting-started/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ The mapping of GenAIScript model names to Visual Studio Models is stored in the

## Anthropic

[Anthropic](https://www.anthropic.com/) is an AI research company that offers powerful language models, including the Claude series.
The `anthropic` provider access [Anthropic](https://www.anthropic.com/) models. Anthropic is an AI research company that offers powerful language models, including the Claude series.

```js "anthropic:"
script({ model: "anthropic:claude-2.1" })
Expand Down Expand Up @@ -865,6 +865,16 @@ script({

<LLMProviderFeatures provider="anthropic" />

## Anthropic Bedrock <a href="" id="anthropic_bedrock" />

The `anthropic_bedrock` provider accesses Anthropic models on Amazon Bedrock. You can find the model names in the [Anthropic model documentation](https://docs.anthropic.com/en/docs/about-claude/models#model-names).

GenAIScript assumes that you have configured AWS credentials in a way that the [AWS Node SDK will recognise](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/setting-credentials-node.html).

```js "anthropic_bedrock:"
script({ model: "anthropic_bedrock:anthropic.claude-3-sonnet-20240229-v1:0" })
```

## Hugging Face <a href="" id="huggingface" />

The `huggingface` provider allows you to use [Hugging Face Models](https://huggingface.co/models?other=text-generation-inference) using [Text Generation Inference](https://huggingface.co/docs/text-generation-inference/index).
Expand Down
21 changes: 12 additions & 9 deletions docs/src/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,25 +136,28 @@ defTool("weather", "live weather",
{ ... "sunny" }
)
```

or use [@agentic tools](/genaiscript/guides/agentic-tools/)

```js wrap
import { WeatherClient } from "@agentic/weather"
defTool(new WeatherClient())
````
```

</Card>

<Card title="Model Context Provider Client" icon="setting">

Use [tools](https://modelcontextprotocol.io/docs/concepts/tools) exposed in [MCP Servers](/genaiscript/reference/scripts/mcp-tools)

````js wrap
defTool({ "memory": {
command: "npx",
args: ["-y", "@modelcontextprotocol/server-memory"]
}})
````
```js wrap
defTool({
memory: {
command: "npx",
args: ["-y", "@modelcontextprotocol/server-memory"],
},
})
```

</Card>

Expand Down Expand Up @@ -338,9 +341,9 @@ script({ ..., model: "github:gpt-4o" })

</Card>

<Card title="Google, Anthropic, Alibaba, ..." icon="rocket">
<Card title="Azure, Google, Anthropic, Amazon, Alibaba, ..." icon="rocket">

Run models from [Google](https://aistudio.google.com/), [Anthropic](https://www.anthropic.com/), [Alibaba](https://www.alibaba.com/), and more.
Run models from [Azure](https://ai.azure.com/), [Google](https://aistudio.google.com/), [Anthropic](https://www.anthropic.com/), [Alibaba](https://www.alibaba.com/), and more.
See [Configuration](/genaiscript/getting-started/configuration/).

```js wrap
Expand Down
5 changes: 3 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"description": "A CLI for GenAIScript, a generative AI scripting framework.",
"license": "MIT",
"dependencies": {
"@anthropic-ai/bedrock-sdk": "^0.11.2",
"@anthropic-ai/sdk": "^0.32.1",
"@azure/identity": "^4.5.0",
"@inquirer/prompts": "^7.2.0",
Expand Down Expand Up @@ -113,9 +114,9 @@
"scripts": {
"compile:runtime": "tsc src/runtime.ts --skipLibCheck --outDir built --declaration --target es2020 --moduleResolution node && mv built/runtime.js built/runtime.mjs",
"compile:api": "esbuild src/api.ts --outfile=built/api.mjs",
"compile:cli": "esbuild src/main.ts --metafile=./esbuild.meta.json --bundle --platform=node --target=node20 --outfile=built/genaiscript.cjs --external:tsx --external:esbuild --external:get-tsconfig --external:resolve-pkg-maps --external:dockerode --external:pdfjs-dist --external:web-tree-sitter --external:tree-sitter-wasms --external:promptfoo --external:typescript --external:@lvce-editor/ripgrep --external:gpt-3-encoder --external:mammoth --external:xlsx --external:mathjs --external:@azure/identity --external:gpt-tokenizer --external:playwright --external:@inquirer/prompts --external:jimp --external:turndown --external:turndown-plugin-gfm --external:vectra --external:tabletojson --external:html-to-text --external:@octokit/rest --external:@octokit/plugin-throttling --external:@octokit/plugin-retry --external:@octokit/plugin-paginate-rest --external:skia-canvas --external:@huggingface/transformers --external:@modelcontextprotocol/sdk --external:@anthropic-ai/sdk --external:es-toolkit && node ../../scripts/patch-cli.mjs",
"compile:cli": "esbuild src/main.ts --metafile=./esbuild.meta.json --bundle --platform=node --target=node20 --outfile=built/genaiscript.cjs --external:tsx --external:esbuild --external:get-tsconfig --external:resolve-pkg-maps --external:dockerode --external:pdfjs-dist --external:web-tree-sitter --external:tree-sitter-wasms --external:promptfoo --external:typescript --external:@lvce-editor/ripgrep --external:gpt-3-encoder --external:mammoth --external:xlsx --external:mathjs --external:@azure/identity --external:gpt-tokenizer --external:playwright --external:@inquirer/prompts --external:jimp --external:turndown --external:turndown-plugin-gfm --external:vectra --external:tabletojson --external:html-to-text --external:@octokit/rest --external:@octokit/plugin-throttling --external:@octokit/plugin-retry --external:@octokit/plugin-paginate-rest --external:skia-canvas --external:@huggingface/transformers --external:@modelcontextprotocol/sdk --external:@anthropic-ai/sdk --external:@anthropic-ai/bedrock-sdk --external:es-toolkit && node ../../scripts/patch-cli.mjs",
"compile": "yarn compile:api && yarn compile:runtime && yarn compile:cli",
"compile-debug": "esbuild src/main.ts --sourcemap --metafile=./esbuild.meta.json --bundle --platform=node --target=node20 --outfile=built/genaiscript.cjs --external:tsx --external:esbuild --external:get-tsconfig --external:resolve-pkg-maps --external:dockerode --external:pdfjs-dist --external:web-tree-sitter --external:tree-sitter-wasms --external:promptfoo --external:typescript --external:@lvce-editor/ripgrep --external:gpt-3-encoder --external:mammoth --external:xlsx --external:mathjs --external:@azure/identity --external:gpt-tokenizer --external:playwright --external:@inquirer/prompts --external:jimp --external:turndown --external:turndown-plugin-gfm --external:vectra --external:tabletojson --external:html-to-text --external:@octokit/rest --external:@octokit/plugin-throttling --external:@octokit/plugin-retry --external:@octokit/plugin-paginate-rest --external:skia-canvas --external:@huggingface/transformers --external:@modelcontextprotocol/sdk --external:@anthropic-ai/sdk --external:es-toolkit",
"compile-debug": "esbuild src/main.ts --sourcemap --metafile=./esbuild.meta.json --bundle --platform=node --target=node20 --outfile=built/genaiscript.cjs --external:tsx --external:esbuild --external:get-tsconfig --external:resolve-pkg-maps --external:dockerode --external:pdfjs-dist --external:web-tree-sitter --external:tree-sitter-wasms --external:promptfoo --external:typescript --external:@lvce-editor/ripgrep --external:gpt-3-encoder --external:mammoth --external:xlsx --external:mathjs --external:@azure/identity --external:gpt-tokenizer --external:playwright --external:@inquirer/prompts --external:jimp --external:turndown --external:turndown-plugin-gfm --external:vectra --external:tabletojson --external:html-to-text --external:@octokit/rest --external:@octokit/plugin-throttling --external:@octokit/plugin-retry --external:@octokit/plugin-paginate-rest --external:skia-canvas --external:@huggingface/transformers --external:@modelcontextprotocol/sdk --external:@anthropic-ai/sdk --external:@anthropic-ai/bedrock-sdk --external:es-toolkit",
"postcompile": "node built/genaiscript.cjs info help > ../../docs/src/content/docs/reference/cli/commands.md",
"vis:treemap": "npx --yes esbuild-visualizer --metadata esbuild.meta.json --filename esbuild.treemap.html",
"vis:network": "npx --yes esbuild-visualizer --metadata esbuild.meta.json --filename esbuild.network.html --template network",
Expand Down
5 changes: 3 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"web-tree-sitter": "0.22.2"
},
"devDependencies": {
"@anthropic-ai/bedrock-sdk": "^0.11.2",
"@anthropic-ai/sdk": "^0.32.1",
"@azure/identity": "^4.5.0",
"@huggingface/jinja": "^0.3.2",
Expand Down Expand Up @@ -98,7 +99,7 @@
"dependencies": {
"@types/diff": "^6.0.0",
"@types/turndown": "^5.0.5",
"turndown-plugin-gfm": "^1.0.2",
"turndown": "^7.2.0"
"turndown": "^7.2.0",
"turndown-plugin-gfm": "^1.0.2"
}
}
Loading

0 comments on commit dc60e07

Please sign in to comment.