| import os |
| import streamlit as st |
| import pandas as pd |
| from utils.helper import * |
|
|
| |
| st.set_page_config(layout="wide") |
|
|
| |
| 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"] |
|
|
|
|
| |
| if 'logged_in' not in st.session_state: |
| st.session_state.logged_in = False |
|
|
| |
| 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() |
| 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() |
| else: |
| st.sidebar.error("β Invalid username or password. Please try again.") |
|
|
| |
| st.title("π AIXNet π: Talk to Chad! He can help!") |
|
|
| |
| if st.session_state.logged_in: |
| st.subheader("π AIXNet Tasks") |
| |
| |
| 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": ["β
", "β
", "β
", "β
"], |
| "π SOC1-3": ["β
", "β
", "β
", "β
"], |
| "π³ PCI DSS": ["β
", "β
", "β
", "β
"] |
| } |
|
|
| |
| df = pd.DataFrame(data) |
|
|
| |
| |
|
|
| |
| with st.sidebar: |
| |
| if st.button("Clear Session"): |
| st.session_state.messages = [] |
| st.rerun() |
|
|
| |
| if "messages" not in st.session_state: |
| st.session_state.messages = [] |
| |
| |
| 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 = [] |
|
|
| |
| for message in st.session_state.messages: |
| if message["role"] != "system": |
| with st.chat_message(message["role"]): |
| st.markdown(message["content"]) |
| |
| |
| if prompt := st.chat_input("π Hi, Chad, what GPU shall I use?"): |
| |
| |
| st.chat_message("user").markdown(prompt) |
| |
| |
| 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}) |
| |
| |
| bot = ChatBot() |
| bot.history = st.session_state.messages.copy() |
| response = bot.generate_response(prompt) |
| |
| |
| with st.chat_message("assistant"): |
| st.markdown(response) |
| |
| |
| st.session_state.messages.append({"role": "assistant", "content": response}) |
|
|
| else: |
| st.info("π Please log in to view the tasks.") |
|
|