-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
feat: 🚀 Integrate Amazon Bedrock Support2 #733
Open
Sunwood-ai-labs
wants to merge
12
commits into
stackblitz:main
Choose a base branch
from
Sunwood-ai-labs:feat/any-llm-bedrock
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,830
−141
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
90a206f
Added the ability to use practically any LLM you can dream of within …
coleam00 4f7a06f
Added the OpenRouter provider and a few models from OpenRouter (easil…
coleam00 d86eaa4
🚀 [feat] Integrate Amazon Bedrock support
Sunwood-ai-labs 2470806
🔑 [refactor] Improve API key and AWS credentials management
Sunwood-ai-labs 2c1045a
📚 [docs] Remove fork-specific information from README
Sunwood-ai-labs 7e0287f
🔑 [feat] Add Gemini API key support
Sunwood-ai-labs e5d16df
🤖 [feat] Implement Gemini model integration
Sunwood-ai-labs bada1b5
📋 [feat] Add Gemini models to MODEL_LIST
Sunwood-ai-labs 0a7f92c
📦 [chore] Add @ai-sdk/google dependency
Sunwood-ai-labs 8b3b78a
🔒 [chore] Update pnpm-lock.yaml with new dependencies
Sunwood-ai-labs e141171
📝 [docs] Update repository URL in clone instructions
Sunwood-ai-labs 9e5e73a
🔐 [feat] Add AWS credentials configuration
Sunwood-ai-labs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,24 @@ | ||
# Rename this file to .env.local once you have filled in the below environment variables! | ||
|
||
# Get your GROQ API Key here - | ||
# https://console.groq.com/keys | ||
# You only need this environment variable set if you want to use Groq models | ||
GROQ_API_KEY= | ||
|
||
# Get your Open AI API Key by following these instructions - | ||
# https://help.openai.com/en/articles/4936850-where-do-i-find-my-openai-api-key | ||
# You only need this environment variable set if you want to use GPT models | ||
OPENAI_API_KEY= | ||
|
||
# Get your Anthropic API Key in your account settings - | ||
# https://console.anthropic.com/settings/keys | ||
# You only need this environment variable set if you want to use Claude models | ||
ANTHROPIC_API_KEY= | ||
|
||
# Get your OpenRouter API Key in your account settings - | ||
# https://openrouter.ai/settings/keys | ||
# You only need this environment variable set if you want to use OpenRouter models | ||
OPEN_ROUTER_API_KEY= | ||
|
||
# Include this environment variable if you want more logging for debugging locally | ||
VITE_LOG_LEVEL=debug |
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 |
---|---|---|
|
@@ -24,7 +24,8 @@ dist-ssr | |
|
||
/.cache | ||
/build | ||
.env* | ||
.env.local | ||
.env | ||
*.vars | ||
.wrangler | ||
_worker.bundle |
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 |
---|---|---|
|
@@ -21,34 +21,80 @@ Whether you’re an experienced developer, a PM or designer, Bolt.new allows you | |
|
||
For developers interested in building their own AI-powered development tools with WebContainers, check out the open-source Bolt codebase in this repo! | ||
|
||
## Tips and Tricks | ||
## Prerequisites | ||
|
||
Here are some tips to get the most out of Bolt.new: | ||
Before you begin, ensure you have the following installed: | ||
|
||
- **Be specific about your stack**: If you want to use specific frameworks or libraries (like Astro, Tailwind, ShadCN, or any other popular JavaScript framework), mention them in your initial prompt to ensure Bolt scaffolds the project accordingly. | ||
- Node.js (v20.15.1) | ||
- pnpm (v9.4.0) | ||
|
||
- **Use the enhance prompt icon**: Before sending your prompt, try clicking the 'enhance' icon to have the AI model help you refine your prompt, then edit the results before submitting. | ||
## Setup | ||
|
||
- **Scaffold the basics first, then add features**: Make sure the basic structure of your application is in place before diving into more advanced functionality. This helps Bolt understand the foundation of your project and ensure everything is wired up right before building out more advanced functionality. | ||
1. Clone the repository (if you haven't already): | ||
|
||
- **Batch simple instructions**: Save time by combining simple instructions into one message. For example, you can ask Bolt to change the color scheme, add mobile responsiveness, and restart the dev server, all in one go saving you time and reducing API credit consumption significantly. | ||
```bash | ||
git clone https://github.com/stackblitz/bolt.new | ||
``` | ||
|
||
2. Install dependencies: | ||
|
||
```bash | ||
pnpm install | ||
``` | ||
|
||
3. Rename `.env.example` to .env.local and add your LLM API keys (you only have to set the ones you want to use and Ollama doesn't need an API key because it runs locally on your computer): | ||
|
||
``` | ||
GROQ_API_KEY=XXX | ||
OPENAI_API_KEY=XXX | ||
ANTHROPIC_API_KEY=XXX | ||
``` | ||
|
||
Optionally, you can set the debug level: | ||
|
||
``` | ||
VITE_LOG_LEVEL=debug | ||
``` | ||
|
||
**Important**: Never commit your `.env.local` file to version control. It's already included in .gitignore. | ||
|
||
## Adding New LLMs: | ||
|
||
## FAQs | ||
To make new LLMs available to use in this version of Bolt.new, head on over to `app/utils/constants.ts` and find the constant MODEL_LIST. Each element in this array is an object that has the model ID for the name (get this from the provider's API documentation), a lable for the frontend model dropdown, and the provider. | ||
|
||
**Where do I sign up for a paid plan?** | ||
Bolt.new is free to get started. If you need more AI tokens or want private projects, you can purchase a paid subscription in your [Bolt.new](https://bolt.new) settings, in the lower-left hand corner of the application. | ||
By default, Anthropic, OpenAI, Groq, and Ollama are implemented as providers, but the YouTube video for this repo covers how to extend this to work with more providers if you wish! | ||
|
||
**What happens if I hit the free usage limit?** | ||
Once your free daily token limit is reached, AI interactions are paused until the next day or until you upgrade your plan. | ||
When you add a new model to the MODEL_LIST array, it will immediately be available to use when you run the app locally or reload it. For Ollama models, make sure you have the model installed already before trying to use it here! | ||
|
||
**Is Bolt in beta?** | ||
Yes, Bolt.new is in beta, and we are actively improving it based on feedback. | ||
## Available Scripts | ||
|
||
**How can I report Bolt.new issues?** | ||
Check out the [Issues section](https://github.com/bolt.new/issues) to report an issue or request a new feature. Please use the search feature to check if someone else has already submitted the same issue/request. | ||
- `pnpm run dev`: Starts the development server. | ||
- `pnpm run build`: Builds the project. | ||
- `pnpm run start`: Runs the built application locally using Wrangler Pages. This script uses `bindings.sh` to set up necessary bindings so you don't have to duplicate environment variables. | ||
- `pnpm run preview`: Builds the project and then starts it locally, useful for testing the production build. Note, HTTP streaming currently doesn't work as expected with `wrangler pages dev`. | ||
- `pnpm test`: Runs the test suite using Vitest. | ||
- `pnpm run typecheck`: Runs TypeScript type checking. | ||
- `pnpm run typegen`: Generates TypeScript types using Wrangler. | ||
- `pnpm run deploy`: Builds the project and deploys it to Cloudflare Pages. | ||
|
||
**What frameworks/libraries currently work on Bolt?** | ||
Bolt.new supports most popular JavaScript frameworks and libraries. If it runs on StackBlitz, it will run on Bolt.new as well. | ||
## Development | ||
|
||
**How can I add make sure my framework/project works well in bolt?** | ||
We are excited to work with the JavaScript ecosystem to improve functionality in Bolt. Reach out to us via [[email protected]](mailto:[email protected]) to discuss how we can partner! | ||
To start the development server: | ||
|
||
```bash | ||
pnpm run dev | ||
``` | ||
|
||
This will start the Remix Vite development server. You will need Google Chrome Canary to run this locally! It's a very easy install and a good browser for web development anyway. | ||
|
||
## Tips and Tricks | ||
|
||
Here are some tips to get the most out of Bolt.new: | ||
|
||
- **Be specific about your stack**: If you want to use specific frameworks or libraries (like Astro, Tailwind, ShadCN, or any other popular JavaScript framework), mention them in your initial prompt to ensure Bolt scaffolds the project accordingly. | ||
|
||
- **Use the enhance prompt icon**: Before sending your prompt, try clicking the 'enhance' icon to have the AI model help you refine your prompt, then edit the results before submitting. | ||
|
||
- **Scaffold the basics first, then add features**: Make sure the basic structure of your application is in place before diving into more advanced functionality. This helps Bolt understand the foundation of your project and ensure everything is wired up right before building out more advanced functionality. | ||
|
||
- **Batch simple instructions**: Save time by combining simple instructions into one message. For example, you can ask Bolt to change the color scheme, add mobile responsiveness, and restart the dev server, all in one go saving you time and reducing API credit consumption significantly. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,34 @@ | ||
// @ts-nocheck | ||
// Preventing TS checks with files presented in the video for a better presentation. | ||
import { env } from 'node:process'; | ||
|
||
export function getAPIKey(cloudflareEnv: Env) { | ||
export function getAPIKey(cloudflareEnv: Env, provider: string) { | ||
/** | ||
* The `cloudflareEnv` is only used when deployed or when previewing locally. | ||
* In development the environment variables are available through `env`. | ||
*/ | ||
return env.ANTHROPIC_API_KEY || cloudflareEnv.ANTHROPIC_API_KEY; | ||
switch (provider) { | ||
case 'Anthropic': | ||
return env.ANTHROPIC_API_KEY || cloudflareEnv.ANTHROPIC_API_KEY; | ||
case 'OpenAI': | ||
return env.OPENAI_API_KEY || cloudflareEnv.OPENAI_API_KEY; | ||
case 'Groq': | ||
return env.GROQ_API_KEY || cloudflareEnv.GROQ_API_KEY; | ||
case 'OpenRouter': | ||
return env.OPEN_ROUTER_API_KEY || cloudflareEnv.OPEN_ROUTER_API_KEY; | ||
case 'Gemini': | ||
return env.GEMINI_API_KEY || cloudflareEnv.GEMINI_API_KEY; | ||
// AWS credentials for Bedrock are obtained separately | ||
default: | ||
return ""; | ||
} | ||
} | ||
|
||
// This function retrieves AWS credentials from environment variables | ||
export function getAWSCredentials(cloudflareEnv: Env) { | ||
return { | ||
accessKeyId: env.AWS_ACCESS_KEY_ID || cloudflareEnv.AWS_ACCESS_KEY_ID, | ||
secretAccessKey: env.AWS_SECRET_ACCESS_KEY || cloudflareEnv.AWS_SECRET_ACCESS_KEY, | ||
region: env.AWS_REGION || cloudflareEnv.AWS_REGION || 'us-east-1', // Default region | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
// see https://docs.anthropic.com/en/docs/about-claude/models | ||
export const MAX_TOKENS = 8192; | ||
export const MAX_TOKENS_BEDROCK = 4096; | ||
|
||
// limits the number of model responses that can be returned in a single request | ||
export const MAX_RESPONSE_SEGMENTS = 2; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
add api key from gemini provider
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.
I responded with 7e0287f