Ask-Your-PDFs / app_style.py
akarshrajsingh7's picture
RAG app
9b6e71b
import streamlit as st
import base64
def render_background_img(background_img_path, image_type = "jpg"):
'''
A function to unpack an image from root folder and set as bg.
Returns
-------
The background.
'''
# set bg name
main_bg_ext = image_type
st.markdown(
f"""
<style>
.stApp {{
background: url(data:image/{main_bg_ext};base64,{base64.b64encode(open(background_img_path, "rb").read()).decode()});
background-size: cover
}}
</style>
""",
unsafe_allow_html=True
)
####### CSS for the CHAT UI
css = '''
<style>
.chat-message {
padding: 1rem; border-radius: 0.5rem; margin-bottom: 0.8rem; display: flex; max-height: 40%; overflow: auto;
}
.chat-message.user {
background-color: #2b313e
}
.chat-message.bot {
background-color: #475063
}
.chat-message .avatar {
width: 15%;
}
.chat-message .avatar img {
max-width: 60px;
max-height: 60px;
border-radius: 50%;
object-fit: cover;
}
.chat-message .message {
width: 85%;
padding: 0 1.2rem;
color: #fff;
}
</style>
'''
bot_template = '''
<div class="chat-message bot">
<div class="avatar">
<img src="https://i.ibb.co/cN0nmSj/Screenshot-2023-05-28-at-02-37-21.png" style="max-height: 60px; max-width: 60px; border-radius: 50%; object-fit: cover;">
</div>
<div class="message">{{MSG}}</div>
</div>
'''
user_template = '''
<div class="chat-message user">
<div class="avatar">
<img src="https://i.ibb.co/XJBBhsD/IMG-7040.jpg" style="max-height: 60px; max-width: 60px; border-radius: 50%; object-fit: cover;">
</div>
<div class="message">{{MSG}}</div>
</div>
'''