{"id":21001473,"url":"https://github.com/divio/amazon-bedrock-chatbot-demo","last_synced_at":"2026-03-09T12:04:57.406Z","repository":{"id":254147869,"uuid":"836748082","full_name":"divio/amazon-bedrock-chatbot-demo","owner":"divio","description":null,"archived":false,"fork":false,"pushed_at":"2024-09-04T12:59:12.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-10T03:26:32.441Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/divio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-01T13:28:24.000Z","updated_at":"2024-09-04T12:59:17.000Z","dependencies_parsed_at":"2024-08-21T18:22:34.441Z","dependency_job_id":"b380be84-494b-4144-abf0-7ccc7d9d193d","html_url":"https://github.com/divio/amazon-bedrock-chatbot-demo","commit_stats":null,"previous_names":["divio/amazon-bedrock-chatbot-demo"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/divio/amazon-bedrock-chatbot-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divio%2Famazon-bedrock-chatbot-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divio%2Famazon-bedrock-chatbot-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divio%2Famazon-bedrock-chatbot-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divio%2Famazon-bedrock-chatbot-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/divio","download_url":"https://codeload.github.com/divio/amazon-bedrock-chatbot-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/divio%2Famazon-bedrock-chatbot-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30294720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T11:12:22.024Z","status":"ssl_error","status_checked_at":"2026-03-09T11:10:54.577Z","response_time":61,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T08:15:26.429Z","updated_at":"2026-03-09T12:04:57.384Z","avatar_url":"https://github.com/divio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Amazon Bedrock Chatbot Demo\n\nA simple chatbot capable of conducting general and document based\nconversations using the Amazon Bedrock API including the required\nconfiguration for deployment on Divio Cloud.\n\n## Technology Stack\n\n- Python\n- Docker\n- Streamlit\n- Amazon Bedrock API\n\n## Requirements\n\n- Python needs to be installed on your machine. If you don't have it\nalready, you can download it [here](https://www.python.org/downloads/).\n\n- Docker is optional for local development but required for deployment on\nDivio Cloud. Docker can be downloaded\n[here](https://www.docker.com/products/docker-desktop).\n\n\n## Local Development\n\n#### Step 1: Clone the repository\n\n```bash\ngit clone https://github.com/divio/amazon-bedrock-chatbot-demo.git\n```\n\n#### Step 2: Navigate to the project directory\n\n```bash\ncd amazon-bedrock-chatbot-demo\n```\n\n#### Step 3: Create a virtual environment\n\n```bash\npython -m venv venv\n```\n\n#### Step 4: Activate the virtual environment\n\n```bash\nsource venv/bin/activate (Linux/Mac) or venv\\Scripts\\activate (Windows)\n```\n\n#### Step 5: Install the required packages\n\n```bash\npip install -r requirements.txt\n```\n\n#### Step 6: Run the app locally\n\nOption 1: Run the app locally using Python:\n\n```bash\nstreamlit run app.py\n```\n\nOption 2: Run the app locally using Docker:\n```bash\ndocker build -t amazon-bedrock-chatbot-demo .\ndocker run --rm -p 80:80 amazon-bedrock-chatbot-demo\n```\n\nOpen your browser and navigate to the URL displayed in the terminal\ndepending on the option you chose.\n\n## Amazon Bedrock Setup\n\nThis chatbot requires:\n- AWS credentials with access to the Amazon Bedrock API\n- Requesting access to a model provided by Amazon Bedrock\n- Access to an S3 bucket where the documents will be stored\n- Configuring a Vector Store for the Knowledge Base\n\nThe first two requirements should be enough for general conversations while\nthe rest are needed for document based conversations.\n\n#### Step 1: Create an AWS account([docs](https://aws.amazon.com/free/))\n\n#### Step 2: Create an IAM user ([docs](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users_create))\n\n#### Step 3: Attach the `AmazonBedrockFullAccess` policy to the IAM user  ([docs](https://docs.aws.amazon.com/apigateway/latest/developerguideapi-gateway-create-and-attach-iam-policy))\n\n#### Step 4: Create an access key for the IAM user ([docs](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys))\n\n#### Step 5: Request access to a model provided by Amazon Bedrock ([docs](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access))\n\nYou can already navigate back to your browser and start interacting with the\nchatbot for general conversations using this access key. Follow the\ninstructions displayed in the chatbot interface to start the conversation.\nThis will require authenticating using the access key and selecting both the\nregion and the model you have access to. Remember, the model you requested\naccess to was also grouped under a specific region. Make sure to select that\nsame region in the chatbot interface.\n\n\u003e [!WARNING]\n\u003e Depending on the model, AWS will charge you based on usage. Although we might\n\u003e talk about pennies here, it's always good to keep an eye on the costs as\n\u003e pennies can easily turn into dollars if you're not careful.\n\u003e For text-generation models, such as those we are using here, you will be\n\u003e charged for every input token processed and every output token generated. For\n\u003e more information on pricing, have a look [here](https://aws.amazon.com/bedrock/pricing).\n\n## Creating a Knowledge Base for Document Based Conversations\n\nTo enable document based conversations, you need to create a Knowledge Base\nin Amazon Bedrock, upload the documents to an S3 bucket attached to that\nKnowledge Base as well as configuring a Vector Store.\n\n#### Step 1: Attach the `AmazonS3FullAccess` policy to the IAM user ([docs](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-and-attach-iam-policy)).\n\n#### Step 2: Create an S3 bucket ([docs](https://docs.aws.amazon.com/AmazonS3/latest/userguide/create-bucket-overview.html)).\n\n#### Step 3: Attach the `IAMFullAccess` policy to your IAM user ([docs](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-create-and-attach-iam-policy)).\n\n\u003e [!CAUTION]\n\u003e Please note that we are giving our IAM user too much power here. This is just\n\u003e for the sake of simplicity. In a real-world scenario, you would want to follow\n\u003e the principle of least privilege and only grant the necessary permissions. For\n\u003e example, there is no need for full access to all S3 buckets, just the ones you\n\u003e want to use. The same applies tenfold for the `IAMFullAccess` policy. This one\n\u003e is added just to avoid an issue while creating the Knowledge Base and it is\n\u003e related to creating an IAM role that will handle the permissions for the\n\u003e actions performed by the Knowledge Base. You can, and probably should, remove\n\u003e the `IAMFullAccess` policy after the Knowledge Base is created. The other two\n\u003e (`AmazonBedrockFullAccess` and `AmazonS3FullAccess`) are needed for the\n\u003e chatbot to function properly. As a side note, root users cannot create\n\u003e Knowledge Bases and this is the reason behind the hustle of creating and\n\u003e properly configuring this IAM user.\n\n\n#### Step 4: Navigate to the Amazon Bedrock console to create a Knowledge Base\n\nSearch for `Amazon Bedrock` in the AWS Management Console and click on it.\nNext, click on `Get started` and you will find yourself in the main dashboard\nof the Bedrock console. Click on `Knowledge bases` in the left-hand menu and\nthen on `Create Knowledge Base`.\n\n#### Step 5: Providing the Knowledge Base Details\n\nYou can give your Knowledge Base a name and a description (optional) but\nother than that, proceed with the default settings. Notice that `Amazon S3`\nis selected as the data source type. Hit `Next`.\n\n#### Step 6: Configuring the Data Source\n\nClick on `Browse S3` and select the bucket you created earlier. Once again,\nproceed with the default settings for the rest of the options.\n\n#### Step 7: Selecting an Embeddings Model\n\nSelect one of the available embeddings models. For this tutorial, we'll go\non with the default one provided by Amazon (`Titan Embeddings G1 - Text v1.2`).\nYou are free to select any other model but I would strongly suggest sticking\nwith the default one as some of the next steps will depend on it.\n\n#### Step 8: Configuring the Vector Store\n\nThis is probably the most demanding step in terms of configuration. You can\neither proceed with the default one provided by Amazon (`Amazon OpenSearch\nServerless vector store`) or create your own. Although the default one seems\ntempting, there are some caveats to it. Amazon is, at the time of writing,\nactively improving the pricing algorithms for this service but it might still\nbe a bit expensive for simple use cases such as our own. For more information,\nhave a look [here](https://aws.amazon.com/opensearch-service/pricing/).\n\nThat being said, we will proceed using `Pinecone` as our vector store and\nleverage their free tier, which is more than enough for our use case. To be\nable to do so, you need to create a `Pinecone` account first. Visit their\nwebsite [here](https://www.pinecone.io/) and sign up. Once you have an\naccount, log in and create a new index. To do so, select `Indexes` from the\nleft-hand menu and then click on `Create index`.\n\nGive your index a name and assign `1536` as the value for the `Dimension`\nfield. Hit `Create index` and you are good to go. This is the exact same value\nas the one in the `vector dimensions` field for the `Titan Embeddings G1 - Text\nv1.2` model back in the Bedrock console. This is not a coincidence. The vector\nstore needs to have the same dimensionality as the embeddings model. This is\ncrucial for the RAG technique to work properly.\n\nHit `Create index`. Once the index is created, copy the `Host` value at the\ntop and head back to the Bedrock console. Paste the `Host` value in the\n`Endpoint URL` as shown below.\n\nFor the next field (`Credentials secret ARN`), you need to create a secret in\nAWS `Secrets Manager`. This secret will hold the API key for your Pinecone\nindex in an encrypted form. To do so, search for `Secrets Manager` in the AWS\nManagement Console and click on it. Next, click on `Store a new secret` and\nselect `Other type of secret`. For the `Key/value` pair, it's crucial that the\nkey is `apiKey` spelled exactly like that. For the value, paste the API key\nyou got from Pinecone. Hit `Next` and follow the rest of the steps to create\nthe secret. Once the secret is created, copy its `Secret ARN` and paste it in\nthe `Credentials secret ARN` field back in the Bedrock console.\n\nUse the default values suggested for the last two required fields:\n\n- Text field name: `text`\n- Bedrock-managed metadata field name: `metadata`\n\nand hit `Next`.\n\nMake sure everything is set up as expected and hit `Create Knowledge Base`.\n\n## Utilizing the Knowledge Base\n\nHead back to the chatbot and select your newly created Knowledge Base from the\nselector.\n\nKnowledge base search mode is now enabled. In this mode, the chatbot will only\nrespond based on the context of the documents in your Knowledge Base. If no\nrelevant information is found, the chatbot will respond with a generic message\nstating that it cannot assist you with that request. Let's upload a document\nand see how the chatbot can help us with it.\n\nRight below the Knowledge Base selector, select a data source (the S3 bucket\nyou created and attached to the Knowledge Base earlier) and upload a document.\n\nHit `Upload \u0026 Sync`.\n\nThe document is being uploaded to the S3  bucket and then processed by the\nKnowledge Base. In other words, the document has been read and understood by\nthe chatbot. Go ahead and ask a question related to the document you just\nuploaded!\n\n## Deploying Your Chatbot on Divio Cloud\n\nThe Dockerfile included in this repository is all you need to deploy your\nchatbot on Divio Cloud. The only thing you need to do is to create a new\nproject on Divio Cloud.\n\n#### Step 1: Create a Divio Account\n\nIf you don't already have one, create a Divio account by signing up\n[here](https://auth.divio.com/realms/cloud-users/protocol/openid-connect/registrations?response_type=code\u0026client_id=control-panel\u0026redirect_uri=https://control.divio.com\u0026ref=divio-signup).\nOnce registered, log in to proceed.\n\n#### Step 2: Creating and Configuring a New Application\n\n1. Create Application: Click on the Plus icon (+) in the left-hand menu to\ncreate a new application\n2. Repository Setup: Select `I already have a repository`. You can fork the\nrepository provided in this blog post and use it freely as your own. For more\ninformation on how to fork a repository, have a look\n[here](https://docs.github.com/en/get-started/quickstart/fork-a-repo).\n3. Connect Repository: Select either \"Connect to GitHub\" or \"Provide a git\nURL\". Both are fine but let's go with the latter for simplicity here. The\nwizard will guide you through all the necessary steps. For more information\nand all the available ways to connect a repository with your Divio\napplication, have a look\n[here](https://docs.divio.com/features/repository/#how-to-configure-external-git-hosting)\n4. Application Details: Name your application and choose a plan. `Free Trial`\nis selected by default. Expand the `Customize Subscription` section to\nconfirm. Leave other settings as default.\n5. Finalize Creation: Click `Create application` and you're done. After that,\nyou will end up in the main view of a Divio application.\n\n#### Step 3: Configure Webhook (Optional)\n\nConnect a Webhook to your repository (optional). From the left-hand menu on\nyour application view click on `Repository` and add a new webhook. After\ncompleting the required steps, you will have a webhook set up. This will allow\nDivio to listen for changes in your repository and automatically include those\nchanges in each new deployment. For more information on how to set up a webhook,\nhave a look\n[here](https://docs.divio.com/features/repository/#configure-a-webhook-for-the-git-repository-recommended).\n\n#### Step 4: Deploy Your Application\n\n1. Initiate Deployment: Back in the main view of your application, click on\n`Deploy` on any of the available environments. Environments is a powerful\nfeature of Divio that allows you to have different stages of your application,\nsuch as development (test), production (live) and so forth. For now, let's\njust deploy the default test environment. For more information on\nenvironments, have a look\n[here](https://docs.divio.com/features/environments/).\n2. Payment Method: You will be asked to provide a payment method if you\nhaven't already. Don't worry, you won't be charged anything, you are in the\nfree trial after all. This is just a security measure to prevent abuse of\nthis plan. Once you've provided the payment method, sit back and relax. Your\napplication is being deployed. You can follow the progress right from the view\nyou're in.\n3. Monitor Deployment: Watch the deployment progress in the current view. Once\ncompleted, you can access your application via the newly activated environment\nURL. That's it! Your chatbot is now live!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivio%2Famazon-bedrock-chatbot-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdivio%2Famazon-bedrock-chatbot-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdivio%2Famazon-bedrock-chatbot-demo/lists"}