Merge pull request #388 from jweisman11/main
Add 2 new tutorials - Amazon Bedrock and S3 Cloud Storage
102
docs/tutorials/integrations/amazon-bedrock.md
Normal file
@ -0,0 +1,102 @@
|
||||
---
|
||||
sidebar_position: 31
|
||||
title: "🛌 Integrate with Amazon Bedrock"
|
||||
---
|
||||
|
||||
:::warning
|
||||
This tutorial is a community contribution and is not supported by the Open WebUI team. It serves only as a demonstration on how to customize Open WebUI for your specific use case. Want to contribute? Check out the contributing tutorial.
|
||||
:::
|
||||
|
||||
---
|
||||
|
||||
# Integrating Open-WebUI with Amazon Bedrock
|
||||
|
||||
In this tutorial, we'll explore one of the most common and popular approaches to integrate Open-WebUI with Amazon Bedrock.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
|
||||
In order to follow this tutorial, you must have the following:
|
||||
|
||||
- An active AWS account
|
||||
- An active AWS Access Key and Secret Key
|
||||
- IAM permissions in AWS to enable Bedrock models or already enabled models
|
||||
- Docker installed on your system
|
||||
|
||||
|
||||
## What is Amazon Bedrock
|
||||
|
||||
Direct from AWS' website:
|
||||
|
||||
"Amazon Bedrock is a fully managed service that offers a choice of high-performing foundation models (FMs) from leading AI companies like AI21 Labs, Anthropic, Cohere, Luma, Meta, Mistral AI, poolside (coming soon), Stability AI, and Amazon through a single API, along with a broad set of capabilities you need to build generative AI applications with security, privacy, and responsible AI. Using Amazon Bedrock, you can easily experiment with and evaluate top FMs for your use case, privately customize them with your data using techniques such as fine-tuning and Retrieval Augmented Generation (RAG), and build agents that execute tasks using your enterprise systems and data sources. Since Amazon Bedrock is serverless, you don't have to manage any infrastructure, and you can securely integrate and deploy generative AI capabilities into your applications using the AWS services you are already familiar with."
|
||||
|
||||
To learn more about Bedrock, visit: [Amazon Bedrock's Official Page](https://aws.amazon.com/bedrock/)
|
||||
|
||||
# Integration Steps
|
||||
|
||||
## Step 1: Verify access to Amazon Bedrock Base Models
|
||||
|
||||
Before we can integrate with Bedrock, you first have to verify that you have access to at least one, but preferably many, of the available Base Models. At the time of this writing (Feb 2025), there were 47 base models available. You can see in the screenshot below that I have access to multiple models. You'll know if you have access to a model if it says "✅ Access Granted" next to the model. If you don't have access to any models, you will get an error on the next step.
|
||||
|
||||
AWS provides good documentation for request accessing / enabling these models here: [Amazon Bedrock's Model Access Docs](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access-modify.html)
|
||||
|
||||

|
||||
|
||||
|
||||
## Step 2: Configure the Bedrock Access Gateway
|
||||
|
||||
Now that we have access to at least one Bedrock base model, we need to configure the Bedrock Access Gateway, or BAG. You can think of the BAG as kind of proxy or middleware developed by AWS that wraps around AWS native endpoints/SDK for Bedrock and, in turn, exposes endpoints that are compatible with OpenAI's schema, which is what Open-WebUI requires.
|
||||
|
||||
For reference, here is a simple mapping between the endpoints:
|
||||
|
||||
|
||||
| OpenAI Endpoint | Bedrock Method |
|
||||
|-----------------------|------------------------|
|
||||
| `/models` | list_inference_profiles |
|
||||
| `/models/{model_id}` | list_inference_profiles |
|
||||
| `/chat/completions` | converse or converse_stream |
|
||||
| `/embeddings` | invoke_model |
|
||||
|
||||
The BAG repo can be found here: [Bedrock Access Gateway Repo](https://github.com/aws-samples/bedrock-access-gateway)
|
||||
|
||||
To set-up the BAG, follow the below steps:
|
||||
- Clone the BAG repo
|
||||
- Remove the default `dockerfile`
|
||||
- Change the name of the `Dockerfile_ecs` to `Dockerfile`
|
||||
|
||||
We're now ready to build and launch the docker container using:
|
||||
|
||||
```bash
|
||||
docker build . -f Dockerfile -t bedrock-gateway
|
||||
|
||||
docker run -e AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" -e AWS_REGION=us-east-1 -d -p 8000:80 bedrock-gateway
|
||||
```
|
||||
|
||||
You should now be able to access the BAG's swagger page at: http://localhost:8000/docs
|
||||
|
||||

|
||||
|
||||
## Step 3: Add Connection in Open-WebUI
|
||||
|
||||
Now that you the BAG up-and-running, it's time to add it as a new connection in Open-WebUI.
|
||||
|
||||
- Under the Admin Panel, go to Settings -> Connections.
|
||||
- Use the "+" (plus) button to add a new connection under the OpenAI
|
||||
- For the URL, use "http://host.docker.internal:8000/api/v1"
|
||||
- For the password, the default password defined in BAG is "bedrock". You can always change this password in the BAG settings (see DEFAULT_API_KEYS)
|
||||
- Click the "Verify Connection" button and you should see "Server connection verified" alert in the top-right
|
||||
|
||||

|
||||
|
||||
## Step 4: Start using Bedrock Base Models
|
||||
|
||||
You should now see all your Bedrock models available!
|
||||
|
||||

|
||||
|
||||
## Other Helpful Tutorials
|
||||
|
||||
These are a few other very helpful tutorials when working to integrate Open-WebUI with Amazon Bedrock.
|
||||
|
||||
- https://gauravve.medium.com/connecting-open-webui-to-aws-bedrock-a1f0082c8cb2
|
||||
- https://jrpospos.blog/posts/2024/08/using-amazon-bedrock-with-openwebui-when-working-with-sensitive-data/
|
100
docs/tutorials/s3-storage.md
Normal file
@ -0,0 +1,100 @@
|
||||
---
|
||||
sidebar_position: 320
|
||||
title: "🪣 Switching to S3 Storage"
|
||||
---
|
||||
|
||||
:::warning
|
||||
This tutorial is a community contribution and is not supported by the Open WebUI team. It serves only as a demonstration on how to customize Open WebUI for your specific use case. Want to contribute? Check out the contributing tutorial.
|
||||
:::
|
||||
|
||||
# 🪣 Switching to S3 Storage
|
||||
|
||||
This guide provides instructions on how to switch the default `local` storage in Open WebUI config to Amazon S3.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
In order to follow this tutorial, you must have the following:
|
||||
|
||||
- An active AWS account
|
||||
- An active AWS Access Key and Secret Key
|
||||
- IAM permissions in AWS to create and put objects in S3
|
||||
- Docker installed on your system
|
||||
|
||||
## What is Amazon S3
|
||||
|
||||
Direct from AWS' website:
|
||||
|
||||
"Amazon S3 is an object storage service that offers industry-leading scalability, data availability, security, and performance. Store and protect any amount of data for a range of use cases, such as data lakes, websites, cloud-native applications, backups, archive, machine learning, and analytics. Amazon S3 is designed for 99.999999999% (11 9's) of durability, and stores data for millions of customers all around the world."
|
||||
|
||||
To learn more about S3, visit: [Amazon S3's Official Page](https://aws.amazon.com/s3/)
|
||||
|
||||
# How to Set-Up
|
||||
|
||||
## 1. Required environment variables
|
||||
|
||||
In order to configure this option, you need to gather the following environment variables:
|
||||
|
||||
| **Open-WebUI Environment Variable** | **Example Value** |
|
||||
|-------------------------------------|---------------------------------------------|
|
||||
| `S3_ACCESS_KEY_ID` | ABC123 |
|
||||
| `S3_SECRET_ACCESS_KEY` | SuperSecret |
|
||||
| `S3_ENDPOINT_URL` | https://s3.us-east-1.amazonaws.com |
|
||||
| `S3_REGION_NAME` | us-east-1 |
|
||||
| `S3_BUCKET_NAME` | my-awesome-bucket-name |
|
||||
|
||||
- S3_ACCESS_KEY_ID: This is an identifier for your AWS account's access key. You get this from the AWS Management Console or AWS CLI when creating an access key.
|
||||
- S3_SECRET_ACCESS_KEY: This is the secret part of your AWS access key pair. It's provided when you create an access key in AWS and should be stored securely.
|
||||
- S3_ENDPOINT_URL: This URL directs to your S3 service endpoint and can typically be found in AWS service documentation or account settings.
|
||||
- S3_REGION_NAME: This is the AWS region where your S3 bucket resides, like "us-east-1". You can identify this from the AWS Management Console under your S3 bucket details.
|
||||
- S3_BUCKET_NAME: This is the unique name of your S3 bucket, which you specified when creating the bucket in AWS.
|
||||
|
||||
For a complete list of the available S3 endpoint URLs, see: [Amazon S3 Regular Endpoints](https://docs.aws.amazon.com/general/latest/gr/s3.html)
|
||||
|
||||
See all the `Cloud Storage` configuration options here: [Open-WebUI Cloud Storage Config](https://docs.openwebui.com/getting-started/env-configuration#cloud-storage)
|
||||
|
||||
## 2. Run Open-WebUI
|
||||
|
||||
Before we launch our instance of Open-WebUI, there is one final environment variable called `STORAGE_PROVIDER` we need to set. This variable tells Open-WebUI which provider you want to use. By default, `STORAGE_PROVIDER` is empty which means Open-WebUI uses local storage.
|
||||
|
||||
| **Storage Provider** | **Type** | **Description** | **Default** |
|
||||
|----------------------|----------|-------------------------------------------------------------------------------------------------|-------------|
|
||||
| `local` | str | Defaults to local storage if an empty string (`' '`) is provided | Yes |
|
||||
| `s3` | str | Uses S3 client library and related environment variables mentioned in Amazon S3 Storage | No |
|
||||
| `gcs` | str | Uses GCS client library and related environment variables mentioned in Google Cloud Storage | No |
|
||||
|
||||
To use Amazon S3, we need to set `STORAGE_PROVIDER` to "S3" along with all the environment variables we gathered in Step 1 (`S3_ACCESS_KEY_ID`, `S3_SECRET_ACCESS_KEY`, `S3_ENDPOINT_URL`, `S3_REGION_NAME`, `S3_BUCKET_NAME`).
|
||||
|
||||
Here, I'm also setting the `ENV` to "dev", which will allow us to see the Open-WebUI Swagger docs so we can further test and confirm the S3 storage set-up is working as expected.
|
||||
|
||||
```sh
|
||||
docker run -d \
|
||||
-p 3000:8080 \
|
||||
-v open-webui:/app/backend/data \
|
||||
-e STORAGE_PROVIDER="s3" \
|
||||
-e S3_ACCESS_KEY_ID="ABC123" \
|
||||
-e S3_SECRET_ACCESS_KEY="SuperSecret" \
|
||||
-e S3_ENDPOINT_URL="https://s3.us-east-1.amazonaws.com" \
|
||||
-e S3_REGION_NAME="us-east-1" \
|
||||
-e S3_BUCKET_NAME="my-awesome-bucket-name" \
|
||||
-e ENV="dev" \
|
||||
--name open-webui \
|
||||
ghcr.io/open-webui/open-webui:main
|
||||
```
|
||||
|
||||
## 3. Test the set-up
|
||||
|
||||
Now that we have Open-WebUI running, let's upload a simple `Hello, World` text file and test our set-up.
|
||||
|
||||

|
||||
|
||||
And confirm that we're getting a response from the selected LLM.
|
||||
|
||||

|
||||
|
||||
Great! Looks like everything is worked as expected in Open-WebUI. Now let's verify that the text file was indeed uploaded and stored in the specified S3 bucket. Using the AWS Management Console, we can see that there is now a file in the S3 bucket. In addition to the name of the file we uploaded (`hello.txt`) you can see the object's name was appended with a unique ID. This is how Open-WebUI tracks all the files uploaded.
|
||||
|
||||

|
||||
|
||||
Using Open-WebUI's swagger docs, we can get all the information related to this file using the `/api/v1/files/{id}` endpoint and passing in the unique ID (4405fabb-603e-4919-972b-2b39d6ad7f5b).
|
||||
|
||||

|
After Width: | Height: | Size: 505 KiB |
After Width: | Height: | Size: 152 KiB |
After Width: | Height: | Size: 129 KiB |
After Width: | Height: | Size: 130 KiB |
BIN
static/images/tutorials/amazon-s3/amazon-s3-get-file-by-id.png
Normal file
After Width: | Height: | Size: 304 KiB |
BIN
static/images/tutorials/amazon-s3/amazon-s3-object-in-bucket.png
Normal file
After Width: | Height: | Size: 171 KiB |
BIN
static/images/tutorials/amazon-s3/amazon-s3-oui-response.png
Normal file
After Width: | Height: | Size: 137 KiB |
BIN
static/images/tutorials/amazon-s3/amazon-s3-upload-file.png
Normal file
After Width: | Height: | Size: 148 KiB |