Created
April 26, 2024 02:00
-
-
Save noahcoad/149954f49bcdafc5cb434fbaaf506d73 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# created 2024-04-25 by Noah Coad [email protected] | |
# demo video at https://youtu.be/9UkoTsXMnlQ | |
import streamlit as st, boto3 | |
# setup app | |
amazon_q = boto3.client('qbusiness', 'us-west-2') | |
st.title("Amazon Q Chatbot") #page title | |
# get user input | |
input_text = st.chat_input("Chat with your bot here") | |
# when there's user input | |
if input_text: | |
# show user msg | |
with st.chat_message("user"): st.markdown(input_text) | |
# call out to Amazon Q | |
answer = amazon_q.chat_sync(applicationId='be05d006-3c25-439e-b25d-781ad5b2xxxx', | |
userMessage=input_text, userId = 'AmazonQ-Administrator') | |
# get Q response to user | |
chat_response = answer['systemMessage'].replace("<answer> ", "").replace("</answer> ", "") | |
# show Q response | |
with st.chat_message("assistant"): st.markdown(chat_response) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment