Building a generative AI application on Kubernetes
In this section, we will build a generative AI application with Streamlit. A diagram representing the architecture for this application is shown in Figure 11.3. In this application, the user will be able to choose which foundational model they are going to talk to.
Figure 11.3 – Foundational models’ application architecture
Let’s start with the Python code for the application. The complete code is available under the Chapter 11/streamlit-claude/app
folders on GitHub. We will walk through the code, block by block:
- Create a folder named
app
and inside it, create amain.py
code file. First, we import the necessary files and create a client to access Amazon Bedrock runtime APIs:import boto3 from langchain_community.chat_models import BedrockChat from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler bedrock = boto3.client(service_name='bedrock-runtime...