CoolFace
Apppublic

snowjf/ISA414_AWS_SupportBot

sourceHugging Faceapache-2.0updated 11mo agoView on Hugging Face
1likes
app.py57 linesDownload Raw Back to root
1import openai2import streamlit as st3from PIL import Image4 5st.title("AWS Outage/SLA Support Bot")6 7# Streamlit Secrets8openai.api_key = st.secrets["OPENAI_API_KEY"]9grounding = st.secrets["GROUNDING"]10 11image = Image.open('logo.png')12 13st.image(image)14 15st.markdown(16    "Hello. I am an AWS Support Bot. I can help explain ongoing AWS service disruptions, regional impact, SLA concerns, and possible workarounds. "17    "I will only provide verified information and will not guess about root cause."18)19 20if "openai_model" not in st.session_state:21    st.session_state["openai_model"] = "gpt-5-mini"22 23if "messages" not in st.session_state:24    st.session_state.messages = []    25 26for message in st.session_state.messages:27    with st.chat_message(message["role"]):28        st.markdown(message["content"])29 30if prompt := st.chat_input("Please list your AWS issue or outage concern."):    31    st.session_state.messages.append({"role": "user", "content": prompt})32    with st.chat_message("user"):33        st.markdown(prompt)34 35    with st.chat_message("assistant"):36        message_placeholder = st.empty()37        full_response = ""38        39        response = openai.responses.create(40            model=st.session_state["openai_model"],41            instructions = grounding,42            input=[43                {"role": m["role"], "content": m["content"]}44                for m in st.session_state.messages45            ],46            stream=True,47        )48        49        for event in response:50            if event.type == 'response.output_text.delta':51                full_response += event.delta.replace('\\$','$').replace('$','\\$')52                message_placeholder.markdown(full_response + "▌")53        54        message_placeholder.markdown(full_response)55        print(full_response)56        57    st.session_state.messages.append({"role": "assistant", "content": full_response})