Aditya Patkar commited on
Commit
788ba6c
1 Parent(s): 5a123c6

Added explainer home page

Browse files
Files changed (1) hide show
  1. app.py +43 -65
app.py CHANGED
@@ -5,13 +5,36 @@ from job_description_generator import predict_job_description, get_job_descripti
5
  from job_description_fixer import fix_job_description, get_job_description_fixer_conversation
6
 
7
  conversation = get_job_description_conversation()
8
- if 'conversation' not in st.session_state:
9
- st.session_state['conversation'] = conversation
10
 
11
  fixer_conversation = get_job_description_fixer_conversation()
12
  if 'fixer_conversation' not in st.session_state:
13
  st.session_state['fixer_conversation'] = fixer_conversation
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
  def setup():
17
  """
@@ -26,7 +49,6 @@ def setup():
26
  """
27
  st.markdown(hide_streamlit_style, unsafe_allow_html=True)
28
 
29
-
30
  def main():
31
  '''
32
  Main function of the app.
@@ -38,12 +60,21 @@ def main():
38
  st.sidebar.markdown("---")
39
  #selector
40
  page = st.sidebar.selectbox(
41
- "Select a page", ["Job Description Generator", "Job Description Fixer"])
42
- if page == "Job Description Generator":
 
 
 
 
 
 
 
 
43
  c1 = st.container()
44
- c1.title("JobGPT: A Job Description Generating Chatbot")
45
  c1.markdown(
46
- "JobGPT is a chatbot that generates job descriptions. This is built just for demo purpose."
 
47
  )
48
  input_text = c1.text_input(
49
  "Prompt",
@@ -57,43 +88,17 @@ def main():
57
  clear_session = st.sidebar.button("New Chat")
58
 
59
  if clear_session:
60
- st.session_state['conversation'] = conversation
61
  c1.markdown("---")
62
 
63
  initial_message = "Hello, how can I help you?"
64
  message(initial_message)
65
 
66
  if button:
67
- messages = []
68
- current_message = ""
69
- current_is_user = True
70
- #clear prompt textbox
71
  response = predict_job_description(input_text,
72
- st.session_state['conversation'])
73
- for historical_message in response['history']:
74
- if "human" in historical_message.lower():
75
- messages.append([current_message, current_is_user])
76
- current_message = historical_message.replace("Human:", "")
77
- current_is_user = True
78
- # message(historical_message.replace("Human:", ""),
79
- # is_user=True)
80
- elif "JobGPT" in historical_message:
81
- messages.append([current_message, current_is_user])
82
- current_message = historical_message.replace("JobGPT:", "")
83
- current_is_user = False
84
- else:
85
- current_message = current_message + "\n" + historical_message
86
- # if message_to_send != "":
87
- # message(message_to_send.replace("JobGPT:",
88
- # "").replace("Human:", ""),
89
- # is_user=is_user)
90
- messages.append([current_message, current_is_user])
91
- for message_to_send, is_user in messages:
92
- if message_to_send.strip() != "":
93
- message(message_to_send, is_user=is_user)
94
- message(input_text, is_user=True)
95
- message(response['prediction'], is_user=False)
96
- else:
97
  c2 = st.container()
98
  c2.title("JobGPT: A Job Description Fixing Chatbot")
99
  c2.markdown(
@@ -118,35 +123,8 @@ def main():
118
  message(initial_message)
119
 
120
  if button:
121
- messages = []
122
- current_message = ""
123
- current_is_user = True
124
- #clear prompt textbox
125
  response = fix_job_description(
126
  input_text, st.session_state['fixer_conversation'])
127
- for historical_message in response['history']:
128
- if "human" in historical_message.lower():
129
- messages.append([current_message, current_is_user])
130
- current_message = historical_message.replace("Human:", "")
131
- current_is_user = True
132
- # message(historical_message.replace("Human:", ""),
133
- # is_user=True)
134
- elif "JobGPT" in historical_message:
135
- messages.append([current_message, current_is_user])
136
- current_message = historical_message.replace("JobGPT:", "")
137
- current_is_user = False
138
- else:
139
- current_message = current_message + "\n" + historical_message
140
- # if message_to_send != "":
141
- # message(message_to_send.replace("JobGPT:",
142
- # "").replace("Human:", ""),
143
- # is_user=is_user)
144
- messages.append([current_message, current_is_user])
145
- for message_to_send, is_user in messages:
146
- if message_to_send.strip() != "":
147
- message(message_to_send, is_user=is_user)
148
- message(input_text, is_user=True)
149
- message(response['prediction'], is_user=False)
150
-
151
 
152
  main()
 
5
  from job_description_fixer import fix_job_description, get_job_description_fixer_conversation
6
 
7
  conversation = get_job_description_conversation()
8
+ if 'generator_conversation' not in st.session_state:
9
+ st.session_state['generator_conversation'] = conversation
10
 
11
  fixer_conversation = get_job_description_fixer_conversation()
12
  if 'fixer_conversation' not in st.session_state:
13
  st.session_state['fixer_conversation'] = fixer_conversation
14
 
15
+ def message_writer(input_text, response):
16
+ messages = []
17
+ current_message = ""
18
+ current_is_user = True
19
+ for historical_message in response['history']:
20
+ if "human" in historical_message.lower():
21
+ messages.append([current_message, current_is_user])
22
+ current_message = historical_message.replace("Human:", "")
23
+ current_is_user = True
24
+ elif "JobGPT" in historical_message:
25
+ messages.append([current_message, current_is_user])
26
+ current_message = historical_message.replace("JobGPT:", "")
27
+ current_is_user = False
28
+ else:
29
+ current_message = current_message + "\n" + historical_message
30
+ messages.append([current_message, current_is_user])
31
+ for message_to_send, is_user in messages:
32
+ if message_to_send.strip() != "":
33
+ message(message_to_send, is_user=is_user)
34
+ message(input_text, is_user=True)
35
+ message(response['prediction'], is_user=False)
36
+ return 0
37
+
38
 
39
  def setup():
40
  """
 
49
  """
50
  st.markdown(hide_streamlit_style, unsafe_allow_html=True)
51
 
 
52
  def main():
53
  '''
54
  Main function of the app.
 
60
  st.sidebar.markdown("---")
61
  #selector
62
  page = st.sidebar.selectbox(
63
+ "Select a page", ["Home", "Job Description Generator", "Job Description Fixer"])
64
+ if page == "Home":
65
+ st.title("JobGPT")
66
+ st.write("Select a page in the sidebar to get started.")
67
+ st.write("### Available options:")
68
+ st.write("1. Job Description Generator")
69
+ st.write("2. Job Description Fixer")
70
+ st.markdown("---")
71
+
72
+ elif page == "Job Description Generator":
73
  c1 = st.container()
74
+ c1.title("A Job Description Generating Chatbot")
75
  c1.markdown(
76
+ "JobGPT is a chatbot that generates job descriptions. \
77
+ This is built just for demo purpose."
78
  )
79
  input_text = c1.text_input(
80
  "Prompt",
 
88
  clear_session = st.sidebar.button("New Chat")
89
 
90
  if clear_session:
91
+ st.session_state['generator_conversation'] = conversation
92
  c1.markdown("---")
93
 
94
  initial_message = "Hello, how can I help you?"
95
  message(initial_message)
96
 
97
  if button:
 
 
 
 
98
  response = predict_job_description(input_text,
99
+ st.session_state['generator_conversation'])
100
+ message_writer(input_text, response)
101
+ elif page == "Job Description Fixer":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  c2 = st.container()
103
  c2.title("JobGPT: A Job Description Fixing Chatbot")
104
  c2.markdown(
 
123
  message(initial_message)
124
 
125
  if button:
 
 
 
 
126
  response = fix_job_description(
127
  input_text, st.session_state['fixer_conversation'])
128
+ message_writer(input_text, response)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
 
130
  main()