-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amazon Bedrock Provider #2016
Amazon Bedrock Provider #2016
Changes from 8 commits
d280dd8
8f9c37f
27f80f7
fdb8b65
4f74103
1dccbe4
99e4462
c065cf1
bd9180c
20a89bc
0054022
531ed89
ea90391
3c4c7eb
0339d68
efbdb06
fe62403
bed12bf
4496d7f
63da891
4d8b740
c61e5f5
6a7730b
db73f9c
ec9ddbe
91f434d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @ai-sdk/amazon-bedrock | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Vercel AI SDK - Amazon Bedrock Provider | ||
|
||
The **[Amazon Bedrock provider](https://sdk.vercel.ai/providers/ai-sdk-providers/amazon-bedrock)** for the [Vercel AI SDK](https://sdk.vercel.ai/docs) | ||
contains language model support for the Amazon Bedrock [converse API](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html). | ||
|
||
## Setup | ||
|
||
The Amazon Bedrock provider is available in the `@ai-sdk/amazon-bedrock` module. You can install it with | ||
|
||
```bash | ||
npm i @ai-sdk/amazon-bedrock | ||
``` | ||
|
||
## Provider Instance | ||
|
||
You can import the default provider instance `bedrock` from `@ai-sdk/amazon-bedrock`: | ||
|
||
```ts | ||
import { bedrock } from '@ai-sdk/amazon-bedrock'; | ||
``` | ||
|
||
## Example | ||
|
||
```ts | ||
import { bedrock } from '@ai-sdk/amazon-bedrock'; | ||
import { generateText } from 'ai'; | ||
|
||
const { text } = await generateText({ | ||
model: bedrock('meta.llama3-8b-instruct-v1:0'), | ||
prompt: 'Write a vegetarian lasagna recipe for 4 people.', | ||
}); | ||
``` | ||
|
||
## Documentation | ||
|
||
Please check out the **[Amazon Bedrock provider documentation](https://sdk.vercel.ai/providers/ai-sdk-providers/amazon-bedrock)** for more information. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
{ | ||
"name": "@ai-sdk/amazon-bedrock", | ||
"version": "0.0.29", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. set to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
"license": "Apache-2.0", | ||
"sideEffects": false, | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"files": [ | ||
"dist/**/*", | ||
"internal/dist/**/*" | ||
], | ||
"scripts": { | ||
"build": "tsup", | ||
"clean": "rm -rf dist && rm -rf internal/dist", | ||
"dev": "tsup --watch", | ||
"lint": "eslint \"./**/*.ts*\"", | ||
"type-check": "tsc --noEmit", | ||
"prettier-check": "prettier --check \"./**/*.ts*\"", | ||
"test": "pnpm test:node && pnpm test:edge", | ||
"test:edge": "vitest --config vitest.edge.config.js --run", | ||
"test:node": "vitest --config vitest.node.config.js --run" | ||
}, | ||
"exports": { | ||
"./package.json": "./package.json", | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.js" | ||
}, | ||
"./internal": { | ||
"types": "./internal/dist/index.d.ts", | ||
"import": "./internal/dist/index.mjs", | ||
"module": "./internal/dist/index.mjs", | ||
"require": "./internal/dist/index.js" | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the whole There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed |
||
}, | ||
"dependencies": { | ||
"@ai-sdk/provider": "0.0.10", | ||
"@ai-sdk/provider-utils": "0.0.14", | ||
"@aws-sdk/client-bedrock-runtime": "^3.598.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. preference is usually to call the api directly using fetch, unless it's not easily possible because of e.g. auth. does the bedrock runtime have any limitations (e.g. does it work on edge)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a rest API for these calls so I could use fetch but I would have to convert the auth and I also would have to define all the types the library provides explicitly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. auth can make this fairly complicated and is the reason why i used a similar approach for the vertex provider. fine to leave as is. btw, would you mind documenting how auth works? (e.g. in a separate file, or in something similar to https://github.com/vercel/ai/blob/main/content/providers/01-ai-sdk-providers/11-google-vertex.mdx There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added documentation with auth and model capabilities etc. |
||
}, | ||
"devDependencies": { | ||
"@smithy/types": "^3.1.0", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is this for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I used this to force the aws-sdk-client-mock to use this specific version because it gives a bunch of type errors if I don't |
||
"@types/node": "^18", | ||
"@vercel/ai-tsconfig": "workspace:*", | ||
"aws-sdk-client-mock": "^4.0.1", | ||
"tsup": "^8", | ||
"typescript": "5.1.3", | ||
"zod": "3.23.8" | ||
}, | ||
"peerDependencies": { | ||
"zod": "^3.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"homepage": "https://sdk.vercel.ai/docs", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/vercel/ai.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/vercel/ai/issues" | ||
}, | ||
"keywords": [ | ||
"ai" | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file can be removed, will be automatically created by changesets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed