|
import os |
|
import time |
|
import base64 |
|
import streamlit as st |
|
|
|
|
|
st.set_page_config(page_title='StoicCyber', page_icon="ποΈ", layout="centered", initial_sidebar_state="collapsed") |
|
|
|
|
|
def get_base64_of_bin_file2(bin_file): |
|
with open(bin_file, 'rb') as f: |
|
data = f.read() |
|
return base64.b64encode(data).decode() |
|
|
|
def set_png_as_page_bg(png_file): |
|
bin_str = get_base64_of_bin_file2(png_file) |
|
page_bg_img = ''' |
|
<link href='https://fonts.googleapis.com/css?family=Libre Baskerville' rel='stylesheet'> |
|
<style> |
|
.stApp { |
|
background-image: url("data:image/png;base64,%s"); |
|
background-size: cover; |
|
background-repeat: no-repeat; |
|
background-attachment: scroll; |
|
} |
|
</style> |
|
''' % bin_str |
|
st.markdown(page_bg_img, unsafe_allow_html=True) |
|
return |
|
|
|
set_png_as_page_bg('pxfuel.jpg') |
|
|
|
|
|
original_title = '<h1 style="font-family: Libre Baskerville; color:#faf8f8; font-size: 30px; text-align: left; ">STOIC Ξ© CYBER</h1>' |
|
st.markdown(original_title, unsafe_allow_html=True) |
|
|
|
@st.cache_resource |
|
def load_model(): |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
def get_response(user_question): |
|
progress_text = "Loading model. Please wait." |
|
my_bar = st.progress(0, text=progress_text) |
|
|
|
time. sleep(1) |
|
my_bar.progress(0.3, "Loading Model. Please wait.") |
|
time. sleep(5) |
|
my_bar.progress(0.6, "Generating Answer. Please wait.") |
|
time. sleep(5) |
|
my_bar.progress(0.9, "Post Processing. Please wait.") |
|
time. sleep(5) |
|
my_bar.progress(1.0, "Done") |
|
time. sleep(1) |
|
my_bar.empty() |
|
return "I don't know!" |
|
|
|
|
|
user_question = st.chat_input('What do you want to ask ..') |
|
|
|
if user_question is not None and user_question!="": |
|
with st.chat_message("Human", avatar="π§π»"): |
|
st.write(user_question) |
|
response = get_response(user_question) |
|
with st.chat_message("AI", avatar="ποΈ"): |
|
st.write(response) |
|
|
|
|
|
|
|
hide_st_style = """ |
|
<style> |
|
header {visibility: hidden;} |
|
footer {visibility: hidden;} |
|
</style> |
|
""" |
|
st.markdown(hide_st_style, unsafe_allow_html=True) |
|
|
|
|
|
|
|
|