├── .gitignore
├── 01_ProductRecommendations
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── bedrock-similarity-search.ipynb
├── bedrock-text-search.ipynb
├── bedrock_requirements.txt
├── data
│ ├── FEIDEGGER_release_1.2.json
│ └── amazon.csv
├── genai-pgvector-similarity-search.ipynb
├── opensource-similarity-search.ipynb
├── opensource_requirements.txt
├── requirements.txt
└── static
│ └── architecture.png
├── 02_RetrievalAugmentedGeneration
├── 02_QuestionAnswering_Bedrock_LLMs
│ ├── .gitignore
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── app.py
│ ├── data
│ │ ├── Amazon Aurora FAQs.pdf
│ │ └── Amazon Bedrock FAQs.pdf
│ ├── env.example
│ ├── htmlTemplates.py
│ ├── rag_app.py
│ ├── requirements.txt
│ └── static
│ │ ├── Powered-By_logo-stack_RGB_REV.png
│ │ └── RAG_APG.png
├── 02_QuestionAnswering_Open_Source_LLMs
│ ├── .gitignore
│ ├── CITATION.cff
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── app.py
│ ├── data
│ │ ├── amazon-aurora-design-considerations-for-high-throughput-cloud-native-relational-databases.pdf
│ │ └── constitution.pdf
│ ├── env.example
│ ├── htmlTemplates.py
│ ├── psql.sh
│ ├── requirements.txt
│ └── static
│ │ └── APG-pgvector-streamlit.png
└── 02_ResponseStreaming
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── app.py
│ ├── data
│ ├── AMZN-2020-Shareholder-Letter.pdf
│ ├── AMZN-2021-Shareholder-Letter.pdf
│ ├── AMZN-2022-Shareholder-Letter.pdf
│ └── AMZN-2023-Shareholder-Letter.pdf
│ ├── env.example
│ ├── htmlTemplates.py
│ ├── requirements.txt
│ ├── static
│ ├── Powered-By_logo-stack_RGB_REV.png
│ └── Streaming_Responses_RAG.png
│ └── streaming_app.py
├── 03_SimilaritySearchSentimentAnalysis
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── data
│ └── fictitious_hotel_reviews_trimmed_500.csv
├── env.example
├── pgvector_with_langchain_auroraml.ipynb
├── requirements1.txt
├── requirements2.txt
└── static
│ └── APG-pgvector-sagemaker.png
├── 04_AuroraML_Bedrock_MovieRecommendations
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── app.py
├── data
│ ├── functions.sql
│ └── movies.sql.gz
├── env.example
├── requirements.txt
└── static
│ ├── ARCH.png
│ ├── Powered-By_logo-stack_RGB_REV.png
│ └── Preview_App.png
├── 05_AuroraML_Bedrock_Chatbot
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── chatbot-app.py
├── chatbot.py
├── env.example
├── requirements.txt
└── static
│ ├── architecture.png
│ └── postgres_cli.png
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── DAT303
├── 01_ProductRecommendations
│ ├── data
│ │ └── amazon.csv
│ ├── images
│ │ └── arch_product_recommendation.png
│ └── product-recommendations.ipynb
├── 02_QuestionAndAnswering
│ ├── .gitignore
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── app.py
│ ├── data
│ │ ├── Amazon Aurora FAQs.pdf
│ │ └── Amazon Bedrock FAQs.pdf
│ ├── env.example
│ ├── htmlTemplates.py
│ ├── rag_app.py
│ ├── requirements.txt
│ └── static
│ │ ├── Powered-By_logo-stack_RGB_REV.png
│ │ └── RAG_APG.png
├── 03_ResponseStreaming
│ ├── CODE_OF_CONDUCT.md
│ ├── CONTRIBUTING.md
│ ├── LICENSE
│ ├── README.md
│ ├── app.py
│ ├── data
│ │ ├── AMZN-2019-Shareholder-Letter.pdf
│ │ ├── AMZN-2020-Shareholder-Letter.pdf
│ │ ├── AMZN-2021-Shareholder-Letter.pdf
│ │ └── AMZN-2022-Shareholder-Letter.pdf
│ ├── htmlTemplates.py
│ ├── requirements.txt
│ ├── static
│ │ ├── Powered-By_logo-stack_RGB_REV.png
│ │ └── Streaming_RAG_APG.png
│ └── streaming_app.py
├── README.md
└── scripts
│ └── prereq.sh
├── DAT307
├── data
│ └── dump.sql.gz
├── knowledge-base
│ ├── documents
│ │ ├── Amazon-Aurora-DB-engines-for-Blue_Green-Deployments.pdf
│ │ ├── Amazon-RDS-Blue_Green-Deployments.pdf
│ │ ├── aurora-postgresql-relnotes.pdf
│ │ └── rds-postgresql-relnotes.pdf
│ └── runbooks
│ │ ├── exercise
│ │ └── rds_acu_capacity_remediation_steps.md
│ │ ├── rds_cpu_remediation_steps.md
│ │ └── rds_iops_remediation_steps.md
├── lambda
│ ├── api-action-runbook-kb.py
│ ├── api-get-incidents.py
│ ├── api-list-runbook-kb.py
│ ├── cw-ingest-to-dynamodb.py
│ ├── idr-bedrock-agent-action-group-good.py
│ ├── idr-bedrock-agent-action-group.py
│ └── qa-bedrock-agent-action-group.py
├── loadtest
│ └── stress_test.py
├── notebooks
│ ├── .DS_Store
│ ├── images
│ │ └── gen_embeddings.png
│ ├── module-1-part-1-tsne.ipynb
│ └── module-1-part-2-embeddings-and-pgvector.ipynb
├── script
│ ├── agent_action_group_for_acu.json
│ ├── agent_action_group_for_acu.sh
│ ├── cloudwatch_alarm_for_acu.sh
│ ├── fix_cloud9.sh
│ ├── lambda_update_for_acu.sh
│ ├── misc
│ │ ├── lambda
│ │ │ ├── auto-remediate
│ │ │ │ ├── alertToaction.py
│ │ │ │ ├── idr-agent-action-group-fn.py
│ │ │ │ └── idr-fn.py
│ │ │ ├── idr_get_active_alerts
│ │ │ │ └── idr_get_active_alerts.py
│ │ │ ├── ingest-dynamo
│ │ │ │ └── ingestdynamodb.py
│ │ │ ├── list-runbook-steps-kb
│ │ │ │ └── list-runbook-steps-kb.py
│ │ │ ├── psycopg2_layer
│ │ │ │ ├── Makefile
│ │ │ │ ├── psycopg2.zip
│ │ │ │ └── publish_lambda_layer.sh
│ │ │ ├── publish_lambda.sh
│ │ │ ├── runbook-steps-action
│ │ │ │ └── runbook-steps-action.py
│ │ │ ├── s3upload
│ │ │ │ ├── Dockerfile
│ │ │ │ ├── app.py
│ │ │ │ └── requirements.txt
│ │ │ └── stress.test
│ │ │ │ └── stress.test.lambda.py
│ │ └── validate_api.py
│ └── prereq.sh
└── ui
│ ├── .streamlit
│ └── config.toml.old
│ ├── image
│ ├── aws_logo.png
│ ├── demo.png
│ ├── idr_logo.png
│ ├── incident_management.png
│ └── powered_by_aws.png
│ ├── index.py
│ ├── page
│ ├── all_incidents.py
│ ├── app.orig.py
│ ├── login_page.py
│ ├── login_page.py.orig
│ ├── pending_incidents.py
│ └── signup_page.py
│ ├── requirements.txt
│ └── utils
│ ├── apigw_handler.py
│ ├── cognito_handler.py
│ └── init_session.py
├── DAT326
├── env_sample
├── requirements.txt
├── static
│ └── AZFlights.jpg
├── travel_knowledge_base.csv
└── valkey-chatbot.py
├── LICENSE
├── README.md
├── data
├── Amazon Aurora FAQs.pdf
├── Amazon Bedrock FAQs.pdf
└── postgresql-16-US.pdf
├── scripts
└── prereq.sh
└── setup_cloud9.sh
/.gitignore:
--------------------------------------------------------------------------------
1 | .ipynb_checkpoints
2 |
--------------------------------------------------------------------------------
/01_ProductRecommendations/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
5 |
--------------------------------------------------------------------------------
/01_ProductRecommendations/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4 | documentation, we greatly value feedback and contributions from our community.
5 |
6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7 | information to effectively respond to your bug report or contribution.
8 |
9 |
10 | ## Reporting Bugs/Feature Requests
11 |
12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13 |
14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16 |
17 | * A reproducible test case or series of steps
18 | * The version of our code being used
19 | * Any modifications you've made relevant to the bug
20 | * Anything unusual about your environment or deployment
21 |
22 |
23 | ## Contributing via Pull Requests
24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25 |
26 | 1. You are working against the latest source on the *main* branch.
27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29 |
30 | To send us a pull request, please:
31 |
32 | 1. Fork the repository.
33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34 | 3. Ensure local tests pass.
35 | 4. Commit to your fork using clear commit messages.
36 | 5. Send us a pull request, answering any default questions in the pull request interface.
37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38 |
39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41 |
42 |
43 | ## Finding contributions to work on
44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
45 |
46 |
47 | ## Code of Conduct
48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50 | opensource-codeofconduct@amazon.com with any additional questions or comments.
51 |
52 |
53 | ## Security issue notifications
54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55 |
56 |
57 | ## Licensing
58 |
59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
60 |
--------------------------------------------------------------------------------
/01_ProductRecommendations/LICENSE:
--------------------------------------------------------------------------------
1 | MIT No Attribution
2 |
3 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of
6 | this software and associated documentation files (the "Software"), to deal in
7 | the Software without restriction, including without limitation the rights to
8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 | the Software, and to permit persons to whom the Software is furnished to do so.
10 |
11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
13 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
15 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17 |
18 |
--------------------------------------------------------------------------------
/01_ProductRecommendations/bedrock_requirements.txt:
--------------------------------------------------------------------------------
1 | pandarallel==1.6.5
2 | pgvector==0.3.6
3 | boto3==1.36.0
4 | psycopg==3.2.4
5 | numexpr==2.10.2
6 | awscli==1.37.0
7 |
--------------------------------------------------------------------------------
/01_ProductRecommendations/opensource_requirements.txt:
--------------------------------------------------------------------------------
1 | psycopg2-binary==2.9.10
2 | pgvector==0.3.6
3 | tqdm==4.67.1
4 | boto3==1.36.0
5 | requests==2.32.3
6 | scikit-image==0.25.0
7 |
--------------------------------------------------------------------------------
/01_ProductRecommendations/requirements.txt:
--------------------------------------------------------------------------------
1 | packaging==24.2
2 | setuptools==65.5.0
3 |
--------------------------------------------------------------------------------
/01_ProductRecommendations/static/architecture.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aurora-postgresql-pgvector/81e197513381392765f190dbf0b25b90b2137e09/01_ProductRecommendations/static/architecture.png
--------------------------------------------------------------------------------
/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | share/python-wheels/
24 | *.egg-info/
25 | .installed.cfg
26 | *.egg
27 | MANIFEST
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .nox/
43 | .coverage
44 | .coverage.*
45 | .cache
46 | nosetests.xml
47 | coverage.xml
48 | *.cover
49 | *.py,cover
50 | .hypothesis/
51 | .pytest_cache/
52 | cover/
53 |
54 | # Translations
55 | *.mo
56 | *.pot
57 |
58 | # Django stuff:
59 | *.log
60 | local_settings.py
61 | db.sqlite3
62 | db.sqlite3-journal
63 |
64 | # Flask stuff:
65 | instance/
66 | .webassets-cache
67 |
68 | # Scrapy stuff:
69 | .scrapy
70 |
71 | # Sphinx documentation
72 | docs/_build/
73 |
74 | # PyBuilder
75 | .pybuilder/
76 | target/
77 |
78 | # Jupyter Notebook
79 | .ipynb_checkpoints
80 |
81 | # IPython
82 | profile_default/
83 | ipython_config.py
84 |
85 | # pyenv
86 | # For a library or package, you might want to ignore these files since the code is
87 | # intended to run in multiple environments; otherwise, check them in:
88 | # .python-version
89 |
90 | # pipenv
91 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92 | # However, in case of collaboration, if having platform-specific dependencies or dependencies
93 | # having no cross-platform support, pipenv may install dependencies that don't work, or not
94 | # install all needed dependencies.
95 | #Pipfile.lock
96 |
97 | # poetry
98 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99 | # This is especially recommended for binary packages to ensure reproducibility, and is more
100 | # commonly ignored for libraries.
101 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102 | #poetry.lock
103 |
104 | # pdm
105 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106 | #pdm.lock
107 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108 | # in version control.
109 | # https://pdm.fming.dev/#use-with-ide
110 | .pdm.toml
111 |
112 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
113 | __pypackages__/
114 |
115 | # Celery stuff
116 | celerybeat-schedule
117 | celerybeat.pid
118 |
119 | # SageMath parsed files
120 | *.sage.py
121 |
122 | # Environments
123 | .env
124 | .venv
125 | env/
126 | venv/
127 | ENV/
128 | env.bak/
129 | venv.bak/
130 |
131 | # Spyder project settings
132 | .spyderproject
133 | .spyproject
134 |
135 | # Rope project settings
136 | .ropeproject
137 |
138 | # mkdocs documentation
139 | /site
140 |
141 | # mypy
142 | .mypy_cache/
143 | .dmypy.json
144 | dmypy.json
145 |
146 | # Pyre type checker
147 | .pyre/
148 |
149 | # pytype static type analyzer
150 | .pytype/
151 |
152 | # Cython debug symbols
153 | cython_debug/
154 |
155 | # PyCharm
156 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
157 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
158 | # and can be added to the global gitignore or merged into this file. For a more nuclear
159 | # option (not recommended) you can uncomment the following to ignore the entire idea folder.
160 | #.idea/
161 |
--------------------------------------------------------------------------------
/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
3 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
4 | opensource-codeofconduct@amazon.com with any additional questions or comments.
--------------------------------------------------------------------------------
/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing Guidelines
2 |
3 | Thank you for your interest in contributing to our project. Whether it's a bug report, new feature, correction, or additional
4 | documentation, we greatly value feedback and contributions from our community.
5 |
6 | Please read through this document before submitting any issues or pull requests to ensure we have all the necessary
7 | information to effectively respond to your bug report or contribution.
8 |
9 |
10 | ## Reporting Bugs/Feature Requests
11 |
12 | We welcome you to use the GitHub issue tracker to report bugs or suggest features.
13 |
14 | When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already
15 | reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:
16 |
17 | * A reproducible test case or series of steps
18 | * The version of our code being used
19 | * Any modifications you've made relevant to the bug
20 | * Anything unusual about your environment or deployment
21 |
22 |
23 | ## Contributing via Pull Requests
24 | Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
25 |
26 | 1. You are working against the latest source on the *main* branch.
27 | 2. You check existing open, and recently merged, pull requests to make sure someone else hasn't addressed the problem already.
28 | 3. You open an issue to discuss any significant work - we would hate for your time to be wasted.
29 |
30 | To send us a pull request, please:
31 |
32 | 1. Fork the repository.
33 | 2. Modify the source; please focus on the specific change you are contributing. If you also reformat all the code, it will be hard for us to focus on your change.
34 | 3. Ensure local tests pass.
35 | 4. Commit to your fork using clear commit messages.
36 | 5. Send us a pull request, answering any default questions in the pull request interface.
37 | 6. Pay attention to any automated CI failures reported in the pull request, and stay involved in the conversation.
38 |
39 | GitHub provides additional document on [forking a repository](https://help.github.com/articles/fork-a-repo/) and
40 | [creating a pull request](https://help.github.com/articles/creating-a-pull-request/).
41 |
42 |
43 | ## Finding contributions to work on
44 | Looking at the existing issues is a great way to find something to contribute on. As our projects, by default, use the default GitHub issue labels (enhancement/bug/duplicate/help wanted/invalid/question/wontfix), looking at any 'help wanted' issues is a great place to start.
45 |
46 |
47 | ## Code of Conduct
48 | This project has adopted the [Amazon Open Source Code of Conduct](https://aws.github.io/code-of-conduct).
49 | For more information see the [Code of Conduct FAQ](https://aws.github.io/code-of-conduct-faq) or contact
50 | opensource-codeofconduct@amazon.com with any additional questions or comments.
51 |
52 |
53 | ## Security issue notifications
54 | If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our [vulnerability reporting page](http://aws.amazon.com/security/vulnerability-reporting/). Please do **not** create a public github issue.
55 |
56 |
57 | ## Licensing
58 |
59 | See the [LICENSE](LICENSE) file for our project's licensing. We will ask you to confirm the licensing of your contribution.
--------------------------------------------------------------------------------
/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/LICENSE:
--------------------------------------------------------------------------------
1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2 | // SPDX-License-Identifier: MIT-0
3 |
4 | Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this
7 | software and associated documentation files (the "Software"), to deal in the Software
8 | without restriction, including without limitation the rights to use, copy, modify,
9 | merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so.
11 |
12 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
14 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
15 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
16 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/README.md:
--------------------------------------------------------------------------------
1 | # 🤖 Enterprise RAG Question-Answering System
2 |
3 | Build an enterprise-ready Retrieval Augmented Generation (RAG) application leveraging Amazon Web Services and open-source technologies. This implementation creates an intelligent question-answering system that combines the power of vector databases with state-of-the-art language models.
4 |
5 | ## 🎯 Overview
6 |
7 | This solution demonstrates the implementation of a production-ready RAG system using:
8 |
9 | - 🚀 Amazon Bedrock for accessing foundation models
10 | - 📊 pgvector extension on Amazon Aurora PostgreSQL for vector operations
11 | - 🧠 Anthropic's Claude for advanced language understanding
12 | - 💫 Titan Text for generating high-quality text embeddings
13 | - 🔗 LangChain for orchestrating AI components
14 | - 🖥️ Streamlit for creating an intuitive user interface
15 |
16 | ## 🏗️ Architecture
17 |
18 | 
19 |
20 | ## ⚙️ System Workflow
21 |
22 | Our RAG implementation follows a sophisticated pipeline to deliver accurate answers:
23 |
24 | 1. **Document Ingestion** 📄
25 | - Processes PDF documents through advanced text extraction
26 | - Maintains document structure and metadata
27 |
28 | 2. **Semantic Processing** 🔄
29 | - Implements intelligent text chunking algorithms
30 | - Preserves context across document segments
31 |
32 | 3. **Vector Embedding** 🎯
33 | - Utilizes Amazon Bedrock's Titan Text for generating embeddings
34 | - Creates high-dimensional vector representations of content
35 |
36 | 4. **Query Processing** 💭
37 | - Accepts natural language questions
38 | - Converts queries into compatible vector representations
39 |
40 | 5. **Context Retrieval** 🔍
41 | - Performs semantic similarity matching
42 | - Identifies relevant document segments
43 |
44 | 6. **Answer Generation** ✨
45 | - Leverages Anthropic's Claude for response synthesis
46 | - Ensures responses are grounded in source documents
47 |
48 | ## 🚀 Getting Started
49 |
50 | ### Prerequisites
51 |
52 | - Python 3.9 or higher
53 | - AWS account with Bedrock access
54 | - Amazon Aurora PostgreSQL cluster
55 | - Git
56 |
57 | ### Installation
58 |
59 | 1. Clone the repository:
60 | ```bash
61 | git clone [repository-url]
62 | cd [repository-name]
63 | ```
64 |
65 | 2. Create and activate a virtual environment:
66 | ```bash
67 | python3.9 -m venv env
68 | source env/bin/activate
69 | ```
70 |
71 | 3. Configure environment variables:
72 | ```bash
73 | # Create .env file with the following structure
74 | PGVECTOR_DRIVER='psycopg2'
75 | PGVECTOR_USER=''
76 | PGVECTOR_PASSWORD=''
77 | PGVECTOR_HOST=''
78 | PGVECTOR_PORT=5432
79 | PGVECTOR_DATABASE=''
80 | ```
81 |
82 | 4. Install dependencies:
83 | ```bash
84 | pip install -r requirements.txt
85 | ```
86 |
87 | ### Database Setup
88 |
89 | 1. Connect to your Aurora PostgreSQL cluster
90 | 2. Enable the pgvector extension:
91 | ```sql
92 | CREATE EXTENSION vector;
93 | ```
94 |
95 | ## 💻 Usage
96 |
97 | 1. Launch the application:
98 | ```bash
99 | streamlit run app.py
100 | ```
101 |
102 | 2. Navigate to the web interface in your browser
103 | 3. Upload PDF documents through the provided interface
104 | 4. Start asking questions about your documents
105 |
106 | ## 🔒 Security Considerations
107 |
108 | - Implement appropriate IAM roles and permissions
109 | - Secure database connections using SSL/TLS
110 | - Follow AWS security best practices for Bedrock access
111 | - Properly handle sensitive information in environment variables
112 |
113 | ## 📈 Performance Optimization
114 |
115 | - Utilize connection pooling for database operations
116 | - Implement caching strategies where appropriate
117 | - Configure proper chunk sizes for optimal retrieval
118 | - Monitor and adjust embedding dimensions based on requirements
119 |
120 | ## 🤝 Contributing
121 |
122 | This project is maintained for educational purposes and demonstrates AWS best practices. While we don't accept direct contributions, we encourage:
123 |
124 | - Creating issues for bugs or suggested improvements
125 | - Forking the repository for personal customization
126 | - Sharing your experiences and optimizations
127 |
128 | ## 📝 License
129 |
130 | This project is licensed under the [MIT-0 License](https://spdx.org/licenses/MIT-0.html) - see the LICENSE file for details.
131 |
--------------------------------------------------------------------------------
/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/data/Amazon Aurora FAQs.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aurora-postgresql-pgvector/81e197513381392765f190dbf0b25b90b2137e09/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/data/Amazon Aurora FAQs.pdf
--------------------------------------------------------------------------------
/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/data/Amazon Bedrock FAQs.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/aws-samples/aurora-postgresql-pgvector/81e197513381392765f190dbf0b25b90b2137e09/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/data/Amazon Bedrock FAQs.pdf
--------------------------------------------------------------------------------
/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/env.example:
--------------------------------------------------------------------------------
1 | PGVECTOR_USER=''
2 | PGVECTOR_PASSWORD=''
3 | PGVECTOR_HOST=''
4 | PGVECTOR_PORT=5432
5 | PGVECTOR_DATABASE=''
6 |
--------------------------------------------------------------------------------
/02_RetrievalAugmentedGeneration/02_QuestionAnswering_Bedrock_LLMs/htmlTemplates.py:
--------------------------------------------------------------------------------
1 | css = '''
2 | {metricname}