georad commited on
Commit
383e99f
·
verified ·
1 Parent(s): 9f5f8bf

Update pages/type_text.py

Browse files
Files changed (1) hide show
  1. pages/type_text.py +10 -3
pages/type_text.py CHANGED
@@ -5,6 +5,7 @@ import json
5
  import torch
6
  from transformers import pipeline # AutoTokenizer, AutoModelForCausalLM, AutoModelForTokenClassification
7
  from sentence_transformers import SentenceTransformer, util
 
8
 
9
  import os
10
  os.getenv("HF_TOKEN")
@@ -73,7 +74,11 @@ def get_device_map() -> str:
73
  device = get_device_map() # 'cpu'
74
 
75
  def on_click():
76
- st.session_state.user_input = ""
 
 
 
 
77
 
78
  #@st.cache
79
  def convert_df(df:pd.DataFrame):
@@ -180,9 +185,11 @@ if INTdesc_input is not None and st.button("Map to SBS codes"):
180
  prompt = question + " " +"A: "+ shortlist[0] + " " +"B: " + shortlist[1] + " " + "C: " + shortlist[2] + " " + "D: " + shortlist[3] + " " + "E: " + shortlist[4]
181
  #st.write(prompt)
182
 
 
 
 
 
183
 
184
-
185
-
186
  messages = [
187
  {"role": "system", "content": "You are a knowledgable AI assistant who always answers truthfully and precisely!"},
188
  {"role": "user", "content": prompt},
 
5
  import torch
6
  from transformers import pipeline # AutoTokenizer, AutoModelForCausalLM, AutoModelForTokenClassification
7
  from sentence_transformers import SentenceTransformer, util
8
+ import time
9
 
10
  import os
11
  os.getenv("HF_TOKEN")
 
74
  device = get_device_map() # 'cpu'
75
 
76
  def on_click():
77
+ st.session_state.user_input = ""
78
+
79
+ def make_spinner(text = "In progress..."):
80
+ with st.spinner(text):
81
+ yield
82
 
83
  #@st.cache
84
  def convert_df(df:pd.DataFrame):
 
185
  prompt = question + " " +"A: "+ shortlist[0] + " " +"B: " + shortlist[1] + " " + "C: " + shortlist[2] + " " + "D: " + shortlist[3] + " " + "E: " + shortlist[4]
186
  #st.write(prompt)
187
 
188
+ sp = iter(make_spinner()) # this starts the spinning
189
+ next(sp) # heavy computation
190
+ time.sleep(3) # spinning end
191
+ next(sp, None)
192
 
 
 
193
  messages = [
194
  {"role": "system", "content": "You are a knowledgable AI assistant who always answers truthfully and precisely!"},
195
  {"role": "user", "content": prompt},