kxx-kkk commited on
Commit
ddc7505
1 Parent(s): 9f6c9c3

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -9
app.py CHANGED
@@ -30,19 +30,22 @@ with tab1:
30
  with open("sample.txt", "r") as text_file:
31
  sample_text = text_file.read()
32
 
33
- example = st.button("Try example")
34
-
35
- contextInput= ""
36
- questionInput = ""
37
 
38
- context = st.text_area("Enter the essay below:", value=contextInput, height=330)
39
- question = st.text_input(label="Enter the question: ", value=questionInput)
40
 
 
41
  if example:
42
- questionInput = sample_question
43
- contextInput = sample_text
44
 
45
-
 
 
 
46
  button = st.button("Get answer")
47
  if button:
48
  with st.spinner(text="Loading question model..."):
 
30
  with open("sample.txt", "r") as text_file:
31
  sample_text = text_file.read()
32
 
33
+ # Get the initial values of context and question
34
+ context = st.session_state.get("contextInput", "")
35
+ question = st.session_state.get("questionInput", "")
 
36
 
37
+ # Button to try the example
38
+ example = st.button("Try example")
39
 
40
+ # Update the values if the "Try example" button is clicked
41
  if example:
42
+ context = sample_text
43
+ question = sample_question
44
 
45
+ # Display the text area and text input with the updated or default values
46
+ context = st.text_area("Enter the essay below:", value=context, key="contextInput", height=330)
47
+ question = st.text_input(label="Enter the question: ", value=question, key="questionInput")
48
+
49
  button = st.button("Get answer")
50
  if button:
51
  with st.spinner(text="Loading question model..."):