Amazon Bedrock Chat with History > Introduction to Amazon Bedrock Chat with History recipe > Amazon Bedrock Chat with History recipe contents
  

Amazon Bedrock Chat with History recipe contents

The Amazon Bedrock Chat with History recipe contains a process object, two app connections, and three processes.
The following image shows the assets that the Amazon Bedrock Chat with History recipe package contains:
The image shows the assets that the Amazon Bedrock Chat with History recipe package contains.

Amazon Bedrock Chat with History recipe assets

The following table lists the assets that the Amazon Bedrock Chat with History recipe package contains:
Asset Name
Asset Type
Description
AmazonBedrockConnection
App connection
Amazon Bedrock connection.
FileConnectionChatHistory
App connection
File connection.
GenerationConfig_AmazonBedrock_PO
Process object
Creates the prompt request.
Read History from File
Process
The subprocess reads history from a file if specified.
Write Chat History in File
Process
The subprocess saves the chat history in a file or creates a new file if one doesn't exist.
Amazon Bedrock Chat with History
Process
The process sets a prompt, saves the response, and uses it as context for future questions. You must set up a Secure Agent to store and retrieve the history.

Amazon Bedrock Chat with History process

The Amazon Bedrock Chat with History process is called by an HTTP request. It maintains chat history in a file and uses it as context for the last user question and LLM answer.
The process is called by an HTTP request using the following input parameters configured on the Input Fields tab of the Start Step:
The User_ID is used as the file name.
After configuring the prompt instructions, the process reads the file. If no file exists or the file is empty, the process prepares a request without history, and then creates or updates the file. It writes the last question and its LLM response in the following format:

Question_to_LLM: user question
LLM_Answer: Amazon Bedrock answer
If the file contains history, the process uses only the last question and response. The process then updates the file and appends the new question and answer. You can include additional parsing in a specific location and also include new changes to the request.