|
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"] |
|
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"] |
|
|
|
|
|
|
|
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 π") |
|
|
|
|
|
if st.session_state.logged_in: |
|
st.subheader("π AIXNet Tasks") |
|
|
|
|
|
data = { |
|
"π Task": ["π» Code assist", "π§ Protein Compound"], |
|
"π₯οΈ Instance Type": ["t2.micro", "t2.micro"], |
|
"π GPU Accelerator": ["A40, 9 vCPU 50 GB RAM", "A40, 9 vCPU 50 GB RAM"], |
|
"π° Price": ["$0.67 / hour", "$0.78 / hour"], |
|
"π IPv4": [ |
|
f"[Link]({BASE_CONTENT_CODE_ASSIST_T2_MICRO})", |
|
f"[Link]({BASE_CONTENT_PROTEIN_T2_MICRO})"] |
|
} |
|
|
|
|
|
df = pd.DataFrame(data) |
|
|
|
|
|
st.markdown(df.to_markdown(index=False), unsafe_allow_html=True) |
|
|
|
|
|
with st.sidebar: |
|
|
|
if st.button("Clear Session"): |
|
st.session_state.messages = [] |
|
st.experimental_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: |
|
with st.chat_message(message["role"]): |
|
st.markdown(message["content"]) |
|
|
|
|
|
if prompt := st.chat_input("π What GPU shall I use?"): |
|
|
|
|
|
st.chat_message("user").markdown(prompt) |
|
|
|
|
|
|
|
st.session_state.messages.append({"role": "user", "content": prompt}) |
|
|
|
|
|
bot = ChatBot( |
|
protocol={"role": "system", "content": f""" |
|
You are a helpful assistant assiting users on GPU selections. |
|
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. |
|
"""}, |
|
conversation=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.") |
|
|