georad commited on
Commit
41dc7c1
·
verified ·
1 Parent(s): 304ff77

Update pages/type_text.py

Browse files
Files changed (1) hide show
  1. pages/type_text.py +58 -14
pages/type_text.py CHANGED
@@ -22,6 +22,56 @@ def make_spinner(text = "In progress..."):
22
  with st.spinner(text):
23
  yield
24
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  #@st.cache
26
  def convert_df(df:pd.DataFrame):
27
  return df.to_csv(index=False).encode('utf-8')
@@ -176,13 +226,10 @@ if INTdesc_input is not None and st.button("Map to SBS codes", key="run_st_model
176
  dfALL = pd.concat([dfALL, pd.DataFrame([dictA])], ignore_index=True)
177
 
178
  st.dataframe(data=dfALL, hide_index=True)
179
- with bottom_anchor:
180
- st.markdown("""
181
- <div id="bottom"></div>
182
- <script>
183
- window.location.href = "#bottom";
184
- </script>
185
- """, unsafe_allow_html=True)
186
 
187
  display_format = "ask REASONING MODEL: Which, if any, of the following SBS descriptions corresponds best to " + INTdesc_input +"? "
188
  #st.write(display_format)
@@ -206,13 +253,10 @@ if INTdesc_input is not None and st.button("Map to SBS codes", key="run_st_model
206
  max_new_tokens=256,
207
  )
208
  st.write(outputs[0]["generated_text"][-1]["content"])
209
- with bottom_anchor:
210
- st.markdown("""
211
- <div id="bottom"></div>
212
- <script>
213
- window.location.href = "#bottom";
214
- </script>
215
- """, unsafe_allow_html=True)
216
 
217
  bs, b1, b2, b3, bLast = st.columns([0.75, 1.5, 1.5, 1.5, 0.75])
218
  with b1:
 
22
  with st.spinner(text):
23
  yield
24
 
25
+ def scroll_past_status_bar():
26
+ st.markdown("""
27
+ <script>
28
+ // This function finds the correct elements in Streamlit's DOM structure
29
+ function scrollPastStatusBar() {
30
+ try {
31
+ // Get the document of the parent (Streamlit app)
32
+ const doc = window.parent.document;
33
+
34
+ // Find all the major containers
35
+ const appFrame = doc.querySelector('.stApp');
36
+ const mainSection = appFrame.querySelector('section.main');
37
+ const blockContainer = mainSection.querySelector('.block-container');
38
+ const stStatusWidget = doc.querySelector('.stStatusWidget');
39
+
40
+ if (blockContainer && stStatusWidget) {
41
+ // Get the height of the status widget
42
+ const statusHeight = stStatusWidget.offsetHeight;
43
+
44
+ // Calculate the position to scroll to
45
+ // This will scroll to just above the status bar
46
+ const scrollPosition = blockContainer.scrollHeight - window.innerHeight + statusHeight + 20;
47
+
48
+ // Perform the scroll on the appropriate container
49
+ if (mainSection.scrollTo) {
50
+ mainSection.scrollTo({
51
+ top: scrollPosition,
52
+ behavior: 'smooth'
53
+ });
54
+ }
55
+
56
+ // Also try scrolling the window as a fallback
57
+ window.parent.scrollTo({
58
+ top: document.body.scrollHeight,
59
+ behavior: 'smooth'
60
+ });
61
+ }
62
+ } catch (e) {
63
+ console.error("Scroll error:", e);
64
+ }
65
+ }
66
+
67
+ // Set multiple attempts with delays
68
+ setTimeout(scrollPastStatusBar, 100);
69
+ setTimeout(scrollPastStatusBar, 300);
70
+ setTimeout(scrollPastStatusBar, 600);
71
+ </script>
72
+ """, unsafe_allow_html=True)
73
+
74
+
75
  #@st.cache
76
  def convert_df(df:pd.DataFrame):
77
  return df.to_csv(index=False).encode('utf-8')
 
226
  dfALL = pd.concat([dfALL, pd.DataFrame([dictA])], ignore_index=True)
227
 
228
  st.dataframe(data=dfALL, hide_index=True)
229
+ # Add extra space at the bottom to ensure results aren't hidden by status bar
230
+ st.markdown("<div style='height: 70px;'></div>", unsafe_allow_html=True)
231
+ # Call the scroll function
232
+ scroll_past_status_bar()
 
 
 
233
 
234
  display_format = "ask REASONING MODEL: Which, if any, of the following SBS descriptions corresponds best to " + INTdesc_input +"? "
235
  #st.write(display_format)
 
253
  max_new_tokens=256,
254
  )
255
  st.write(outputs[0]["generated_text"][-1]["content"])
256
+ # Add extra space at the bottom to ensure results aren't hidden by status bar
257
+ st.markdown("<div style='height: 70px;'></div>", unsafe_allow_html=True)
258
+ # Call the scroll function
259
+ scroll_past_status_bar()
 
 
 
260
 
261
  bs, b1, b2, b3, bLast = st.columns([0.75, 1.5, 1.5, 1.5, 0.75])
262
  with b1: