Streamlit Stepfunction Example
Implementation
Streamlit app invokes Step Functions workflow directly everytime user enters input in the textbox. Workflow invokes Amazon Bedrock converse API, identifies if a tool is needed to be called, routes to appropriate tools, builds the response and sends back to the streamlit app. We used Step Functions Express workflow. Express workflows are suitable for high scale short lived transaction type of use cases. They can be called synchronously.
Using this demo
To get started, you will need the following:
- AWS CLI Installed and Configured
- Amazon Bedrock Model Access for Claude 3 Sonnet
- Python Installed
- SAM CLI Installed
- Streamlit
With these installed and configured, you can clone this repo.
git clone https://github.com/aws-samples/anthropic-on-aws.git
cd anthropic-on-aws/complex-schema-tool-use/streamlit-stepfunction-example
And create a virtual environment and install the necessary packages.
python3 -m venv ./
source bin/activate
pip3 install -r requirements.txt
And deploy the cloudformation stack that creates the Step Functions
sam build
sam deploy -g
And now run the Streamlit App Copy the value for ToolUseCoverseAPIStateMachineArn from the output of the cloudformation stack. Substitute it in the command below
streamlit run tool_use/chatbot_example.py <Statemachine_ARN>
This should open a browser to http://localhost:8501/
or something similar. To get started, tell the bot you'd like to order a pizza.