Update app.py
Browse files
app.py
CHANGED
@@ -1,83 +0,0 @@
|
|
1 |
-
import os
|
2 |
-
import time
|
3 |
-
import base64
|
4 |
-
import streamlit as st
|
5 |
-
|
6 |
-
|
7 |
-
st.set_page_config(page_title='StoicCyber', page_icon="🏛️", layout="centered", initial_sidebar_state="collapsed")
|
8 |
-
|
9 |
-
# show background image
|
10 |
-
def get_base64_of_bin_file2(bin_file):
|
11 |
-
with open(bin_file, 'rb') as f:
|
12 |
-
data = f.read()
|
13 |
-
return base64.b64encode(data).decode()
|
14 |
-
|
15 |
-
def set_png_as_page_bg(png_file):
|
16 |
-
bin_str = get_base64_of_bin_file2(png_file)
|
17 |
-
page_bg_img = '''
|
18 |
-
<link href='https://fonts.googleapis.com/css?family=Libre Baskerville' rel='stylesheet'>
|
19 |
-
<style>
|
20 |
-
.stApp {
|
21 |
-
background-image: url("data:image/png;base64,%s");
|
22 |
-
background-size: cover;
|
23 |
-
background-repeat: no-repeat;
|
24 |
-
background-attachment: scroll;
|
25 |
-
}
|
26 |
-
</style>
|
27 |
-
''' % bin_str
|
28 |
-
st.markdown(page_bg_img, unsafe_allow_html=True)
|
29 |
-
return
|
30 |
-
|
31 |
-
set_png_as_page_bg('pxfuel.jpg')
|
32 |
-
|
33 |
-
# header
|
34 |
-
original_title = '<h1 style="font-family: Libre Baskerville; color:#faf8f8; font-size: 30px; text-align: left; ">STOIC Ω CYBER</h1>'
|
35 |
-
st.markdown(original_title, unsafe_allow_html=True)
|
36 |
-
|
37 |
-
@st.cache_resource
|
38 |
-
def load_model():
|
39 |
-
# return load()
|
40 |
-
pass
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
# chat componenets
|
45 |
-
|
46 |
-
def get_response(user_question):
|
47 |
-
progress_text = "Loading model. Please wait."
|
48 |
-
my_bar = st.progress(0, text=progress_text)
|
49 |
-
# run the functions in the place of time sleep
|
50 |
-
time. sleep(1)
|
51 |
-
my_bar.progress(0.3, "Loading Model. Please wait.")
|
52 |
-
time. sleep(5)
|
53 |
-
my_bar.progress(0.6, "Generating Answer. Please wait.")
|
54 |
-
time. sleep(5)
|
55 |
-
my_bar.progress(0.9, "Post Processing. Please wait.")
|
56 |
-
time. sleep(5)
|
57 |
-
my_bar.progress(1.0, "Done")
|
58 |
-
time. sleep(1)
|
59 |
-
my_bar.empty()
|
60 |
-
return "I don't know!"
|
61 |
-
|
62 |
-
|
63 |
-
user_question = st.chat_input('What do you want to ask ..')
|
64 |
-
|
65 |
-
if user_question is not None and user_question!="":
|
66 |
-
with st.chat_message("Human", avatar="🧔🏻"):
|
67 |
-
st.write(user_question)
|
68 |
-
response = get_response(user_question)
|
69 |
-
with st.chat_message("AI", avatar="🏛️"):
|
70 |
-
st.write(response)
|
71 |
-
|
72 |
-
|
73 |
-
# Hide footer and header
|
74 |
-
hide_st_style = """
|
75 |
-
<style>
|
76 |
-
header {visibility: hidden;}
|
77 |
-
footer {visibility: hidden;}
|
78 |
-
</style>
|
79 |
-
"""
|
80 |
-
st.markdown(hide_st_style, unsafe_allow_html=True)
|
81 |
-
|
82 |
-
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|