fracapuano commited on
Commit
51a7497
1 Parent(s): 59359cb

add: task confirmation button

Browse files
Files changed (1) hide show
  1. app.py +44 -34
app.py CHANGED
@@ -19,39 +19,49 @@ OPTION1="Chat with a file 💬📖"
19
  OPTION2="Text summarization 🔎"
20
  OPTION_N="Other 🤔"
21
 
22
- option = st.radio(
23
- "Please select a task 🤖",
24
- options=[OPTION1, OPTION2, OPTION_N],
25
- )
26
-
27
- if option == OPTION1:
28
- from qa import qa_main
29
- with st.container():
30
- qa_main()
31
-
32
- elif option == OPTION2:
33
- from summarization import summarization_main
34
- with st.container():
35
- summarization_main()
36
-
37
- elif option == OPTION_N:
38
- from mailing import mailing_main
39
- with st.container():
40
- user_suggestion = st.text_input(
41
- "What other task would you like to perform?",
42
- placeholder="Transform meeting transcripts into rainbow-colored unicorns"
43
  )
44
- if user_suggestion:
45
- st.write("""
46
- Thanks for contributing with your suggestion! We are carefully reviewing every suggestion.
47
- If you wish to further discuss your task suggestion, consider reaching out to [email protected].
48
- We will get back to you as soon as possible!
49
- """)
50
-
51
- mailing_main(
52
- subject="**NEW TASK SUGGESTION** - Automatic email.",
53
- body=f"User suggestion\n: {user_suggestion}",
54
- to_address="francesco.[email protected]"
55
- )
56
- st.stop()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
 
 
19
  OPTION2="Text summarization 🔎"
20
  OPTION_N="Other 🤔"
21
 
22
+ col1, col2 = st.columns(2)
23
+ with col1:
24
+ option = st.radio(
25
+ "Please select a task 🤖",
26
+ options=[OPTION1, OPTION2, OPTION_N],
27
+ key="task_selection"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  )
29
+
30
+ with col2:
31
+ confirm = st.button("Confirm", key="task_selection_confirm")
32
+ if confirm:
33
+ st.session_state["task_confirmed"] = True
34
+
35
+ if st.session_state.get("task_confirmed"):
36
+ # only execute the actual app code when the user confirms the task selection
37
+ if st.session_state.get("task_selection") == OPTION1:
38
+ from qa import qa_main
39
+ with st.container():
40
+ qa_main()
41
+
42
+ elif st.session_state.get("task_selection") == OPTION2:
43
+ from summarization import summarization_main
44
+ with st.container():
45
+ summarization_main()
46
+
47
+ elif st.session_state.get("task_selection") == OPTION_N:
48
+ from mailing import mailing_main
49
+ with st.container():
50
+ user_suggestion = st.text_input(
51
+ "What other task would you like to perform?",
52
+ placeholder="Transform meeting transcripts into rainbow-colored unicorns"
53
+ )
54
+ if user_suggestion:
55
+ st.write("""
56
+ Thanks for contributing with your suggestion! We are carefully reviewing every suggestion.
57
+ If you wish to further discuss your task suggestion, consider reaching out to [email protected].
58
+ We will get back to you as soon as possible!
59
+ """)
60
+
61
+ mailing_main(
62
+ subject="**NEW TASK SUGGESTION** - Automatic email.",
63
+ body=f"User suggestion\n: {user_suggestion}",
64
+ to_address="[email protected]"
65
+ )
66
+ st.stop()
67