ajs2440 commited on
Commit
544b199
·
1 Parent(s): 035efeb

changed layout and added output text area for generated responses

Browse files
Files changed (1) hide show
  1. app.py +31 -5
app.py CHANGED
@@ -1,5 +1,7 @@
1
  import streamlit as st
2
  import torch
 
 
3
  from transformers import BartForConditionalGeneration, BartTokenizer
4
 
5
  # initialize model + tok variables
@@ -17,6 +19,7 @@ examples = [
17
  # descriptions = "Interview question remake is a model that..."
18
 
19
  # pass in Strings of model choice and input text for context
 
20
  def genQuestion(model_choice, context):
21
  # global descriptions
22
  if model_choice=="interview-question-remake":
@@ -42,12 +45,20 @@ def genQuestion(model_choice, context):
42
  return final_output
43
 
44
 
45
-
 
 
46
  # Title
47
  st.title("Interview AI Test Website")
48
 
49
- # Input field
50
- input = st.text_input('Context')
 
 
 
 
 
 
51
 
52
  option = st.selectbox(
53
  'Please select a model.',
@@ -60,8 +71,23 @@ elif option == 'interview-length-tagged':
60
  elif option == 'reverse-interview-question':
61
  st.write("This model asks a question that would have resulted in the context you provide (a.k.a. it traverses backward through the interview)")
62
 
63
- if st.button('Submit'):
 
 
 
 
64
  with st.spinner('Generating a response...'):
65
  output = genQuestion(option, input)
66
  print(output)
67
- st.write(output)
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import torch
3
+ from pandas import options
4
+ from streamlit_tags import st_tags
5
  from transformers import BartForConditionalGeneration, BartTokenizer
6
 
7
  # initialize model + tok variables
 
19
  # descriptions = "Interview question remake is a model that..."
20
 
21
  # pass in Strings of model choice and input text for context
22
+ @st.cache
23
  def genQuestion(model_choice, context):
24
  # global descriptions
25
  if model_choice=="interview-question-remake":
 
45
  return final_output
46
 
47
 
48
+ # Wide page layout (instead of having a narrower, one-column page layout)
49
+ st.set_page_config(layout="wide")
50
+
51
  # Title
52
  st.title("Interview AI Test Website")
53
 
54
+ # Adding a Session State to store stateful variables and for saving user's labels/tags for generated questions
55
+ if 'button_sent' not in st.session_state:
56
+ st.session_state.button_sent = False
57
+
58
+ # Input fields
59
+ input = st.text_input('Context') # user inputs context to construct a response (str)
60
+
61
+ maxl, minl = st.columns(2)
62
 
63
  option = st.selectbox(
64
  'Please select a model.',
 
71
  elif option == 'reverse-interview-question':
72
  st.write("This model asks a question that would have resulted in the context you provide (a.k.a. it traverses backward through the interview)")
73
 
74
+
75
+ # Column layout to display generated responses alongside tags
76
+ col1, col2 = st.columns((3, 1))
77
+
78
+ if st.button('Submit') or st.session_state.button_sent:
79
  with st.spinner('Generating a response...'):
80
  output = genQuestion(option, input)
81
  print(output)
82
+ # st.write(output)
83
+ st.session_state.button_sent = True
84
+ col1.text_area(label="Generated Responses:", value=output, disabled=True, height=200)
85
+
86
+
87
+
88
+ # TODO:
89
+ # - disable multiselect widget when responses are being generated AND when a question is not selected to be tagged
90
+ # - connect tags with an individual question
91
+ # - save session state so tags associated with their respective questions can also be saved
92
+ # - write/store the saved state data to some database for future use?
93
+ # - brainstorm good names for tags/labels OR allow users to enter their own tag names if possible