File size: 6,039 Bytes
ee27a37 fb254d5 662d24b ee27a37 a6a4d5c ee27a37 d6e94f2 c7db349 14b8e65 371a318 14b8e65 ee27a37 c7db349 ee27a37 c7db349 ee27a37 c7db349 520c62b ee27a37 c7db349 520c62b c7db349 e61bdf2 cccdc5b e61bdf2 c7db349 e61bdf2 01d1d57 c7db349 1a1bd77 371a318 91d0ca7 371a318 14b8e65 4858029 c67948b 371a318 91d0ca7 c7db349 fb254d5 47d336d 662d24b aa290df 662d24b 8303bff 662d24b 8303bff 662d24b cccdc5b 662d24b 507afd7 662d24b cccdc5b 662d24b 7233b30 d6e94f2 7233b30 91d0ca7 507afd7 662d24b c7db349 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
import os
import streamlit as st
import pandas as pd
from utils.helper import *
# Set page layout to wide mode
st.set_page_config(layout="wide")
# Hardcoded credentials
USERNAME = os.environ["USERNAME"]
PASSWORD = os.environ["PASSWORD"]
JUPYTER_USERNAME = os.environ["JUPYTER_USERNAME"]
JUPYTER_PASSWORD = os.environ["JUPYTER_PASSWORD"]
BASE_CONTENT_CODE_ASSIST_T2_MICRO = os.environ["BASE_CONTENT_CODE_ASSIST_T2_MICRO"]
BASE_CONTENT_PROTEIN_T2_MICRO = os.environ["BASE_CONTENT_PROTEIN_T2_MICRO"]
BASE_CONTENT_CODE_ASSIST_DS1 = os.environ["BASE_CONTENT_CODE_ASSIST_DS1"]
# Initialize session state
if 'logged_in' not in st.session_state:
st.session_state.logged_in = False
# Sidebar for login/logout with emojis
st.sidebar.title("π AIXNet")
if st.session_state.logged_in:
st.sidebar.success("π You are logged in!")
if st.sidebar.button("π Log out"):
st.session_state.logged_in = False
st.sidebar.info("You have logged out.")
st.rerun() # Rerun the app to reflect the logged-out state
else:
with st.sidebar.form(key='login_form'):
username = st.text_input("π€ Username")
password = st.text_input("π Password", type="password")
login_button = st.form_submit_button(label="π Log in")
if login_button:
if username == USERNAME and password == PASSWORD:
st.session_state.logged_in = True
st.sidebar.success("π Login successful!")
st.rerun() # Rerun the app to reflect the logged-in state
else:
st.sidebar.error("β Invalid username or password. Please try again.")
# Main title area
st.title("π AIXNet π: Talk to Chad! He can help!")
# Display table only if logged in
if st.session_state.logged_in:
st.subheader("π AIXNet Tasks")
# Create the table data with hyperlink
data = {
"π’ Company": ["AWS", "AWS", "AWS", "Azure"],
"π Task": ["π» Code assist", "π§ Protein Compound", "π» Code assist", "π» Code assist"],
"π₯οΈ Instance Type": [
"t2.micro (1 vcpu, 1.0 GiB memory)",
"t2.micro (1 vcpu, 1.0 GiB memory)",
"t2.micro (1 vcpu, 1.0 GiB memory)",
"Standard DS1 v2 (1 vcpu, 3.5 GiB memory)"
],
"π GPU Accelerator": ["A40, 9 vCPU 50 GB RAM", "A40, 9 vCPU 50 GB RAM", "A100, 24 vCPU 125 GB RAM", "A100, 24 vCPU 125 GB RAM"],
"π° Price": ["$0.67 / hour", "$0.78 / hour", "$1.89 / hour", "$0.78 / hour"],
"π IPv4": [
f"[Link]({BASE_CONTENT_CODE_ASSIST_T2_MICRO})",
f"[Link]({BASE_CONTENT_PROTEIN_T2_MICRO})",
f"[Link]({BASE_CONTENT_CODE_ASSIST_T2_MICRO})",
f"[Link]({BASE_CONTENT_CODE_ASSIST_DS1})"
],
"π‘οΈ HIPAA": ["β
", "β
", "β
", "β
"], # All rows have HIPAA compliance
"π SOC1-3": ["β
", "β
", "β
", "β
"], # All rows have SOC1-3 compliance
"π³ PCI DSS": ["β
", "β
", "β
", "β
"] # All rows have PCI DSS compliance
}
# Convert the data to a DataFrame
df = pd.DataFrame(data)
# Render the DataFrame with the URL as a hyperlink [optional]
# st.markdown(df.to_markdown(index=False), unsafe_allow_html=True)
# Chatbot
with st.sidebar:
# Add a button to clear the session state
if st.button("Clear Session"):
st.session_state.messages = []
st.rerun()
# Initialize chat history
if "messages" not in st.session_state:
st.session_state.messages = []
# Ensure messages are a list of dictionaries
if not isinstance(st.session_state.messages, list):
st.session_state.messages = []
if not all(isinstance(msg, dict) for msg in st.session_state.messages):
st.session_state.messages = []
# Display chat messages from history on app rerun
for message in st.session_state.messages:
if message["role"] != "system": # Skip system messages
with st.chat_message(message["role"]):
st.markdown(message["content"])
# React to user input
if prompt := st.chat_input("π Hi, Chad, what GPU shall I use?"):
# Display user message in chat message container
st.chat_message("user").markdown(prompt)
# Add user message to chat history
st.session_state.messages.append({"role": "system", "content": f"""
You are a helpful assistant assiting users on GPU selections.
Your name is Chad.
Here's the data:
{df.to_markdown(index=False)}
User may ask what is the best GPU selection.
You will need to ask user: 1) type of task, 2) size of data, 3) size of models.
You will then make a suggestion of what type of GPU or instance is the best for the user.
When you make a suggestion, use the link from the data above.
When you make a suggestion, also make sure to mention, for first time user, use sample login info:
username={JUPYTER_USERNAME}, and password={JUPYTER_PASSWORD} when click on the link recommended.
User can also ask you certification eligibility. Currently, the data provided above has check marks.
The check marks indicate which certification and data protection eligibility each instance has.
You can recommend each instance according to user question if user asks about this part.
"""})
st.session_state.messages.append({"role": "user", "content": prompt})
# API Call
bot = ChatBot()
bot.history = st.session_state.messages.copy() # Update history from messages
response = bot.generate_response(prompt)
# Display assistant response in chat message container
with st.chat_message("assistant"):
st.markdown(response)
# Add assistant response to chat history
st.session_state.messages.append({"role": "assistant", "content": response})
else:
st.info("π Please log in to view the tasks.")
|