File size: 2,970 Bytes
25eb2b4 53dcb25 f4ae373 25eb2b4 f4ae373 1c7dd78 f4ae373 1c7dd78 f4ae373 1c7dd78 f4ae373 1c7dd78 f4ae373 1c7dd78 122a897 f4ae373 1c7dd78 f4ae373 122a897 f4ae373 1c7dd78 122a897 f4ae373 122a897 f4ae373 25eb2b4 dbb0d31 f4ae373 122a897 f4ae373 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
import streamlit as st
# Looking at the UCSF example, they use a custom component approach with specific CSS
# Let's implement a similar solution
# Custom CSS based on the UCSF implementation
st.markdown("""
<style>
/* CSS similar to UCSF implementation */
div.block-container {
padding-top: 1rem;
}
div[data-testid="stDecoratedAppViewContainer"] > div:first-child {
position: sticky !important;
top: 0 !important;
background-color: white;
z-index: 999;
padding: 0px !important;
}
/* Custom header styling */
.custom-header {
background-color: #90EE90;
padding: 1rem;
border-bottom: 1px solid #ddd;
width: 100%;
}
/* Hide default Streamlit header */
header[data-testid="stHeader"] {
display: none;
}
/* Additional fixes specific to Hugging Face embedding */
section[data-testid="stSidebar"] {
z-index: 0;
}
</style>
""", unsafe_allow_html=True)
# Create a custom header at the very top (this is key)
# This must be the very first Streamlit element
with st.container():
st.markdown('<div class="custom-header">', unsafe_allow_html=True)
col1, col2 = st.columns([1, 9])
with col1:
# Add logo
try:
st.image("images/menu_book_60dp_75FBFD.png", width=60)
except:
st.write("π") # Fallback emoji if image doesn't load
with col2:
st.markdown("""
<h2 style="margin: 0; padding: 0;">Map descriptions to SBS codes with Sentence Transformer + Reasoning</h2>
<p style="margin: 0; padding: 0;">Select specific Chapter for quicker results</p>
""", unsafe_allow_html=True)
st.markdown('</div>', unsafe_allow_html=True)
# Add a bit of spacing
st.write("")
# Sidebar content (similar to your original code)
st.sidebar.header("SBS V2.0 mapper")
st.sidebar.write("(work in progress)")
st.sidebar.text("Demo by JA-RAD")
# Page setup
type_text_page = st.Page(
page="pages/type_text.py",
title="DEMO (work in progress)",
icon=":material/keyboard:",
default=True,)
# Navigation
pg = st.navigation(pages=[type_text_page])
pg.run()
# Inject CSS and JS as early as possible in your app
st.markdown(custom_css, unsafe_allow_html=True)
st.markdown(js_fix, unsafe_allow_html=True)
# --- PAGE SETUP ---
type_text_page = st.Page(
page="pages/type_text.py",
title="DEMO (work in progress)",
icon=":material/keyboard:",
default=True,)
# --- Your Streamlit App ---
st.title("Map descriptions to SBS codes with Sentence Transformer + Reasoning")
st.subheader("Select specific Chapter for quicker results")
st.logo(image="images/menu_book_60dp_75FBFD.png")
st.sidebar.header("SBS V2.0 mapper")
st.sidebar.write("(work in progress)")
st.sidebar.text("Demo by JA-RAD")
# --- NAVIGATION SETUP ---
pg = st.navigation(pages=[type_text_page]) # WITHOUT SECTIONS
pg.run()
|