osman93 commited on
Commit
c9fa163
·
verified ·
1 Parent(s): bf681f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -214
app.py CHANGED
@@ -47,75 +47,10 @@ if not st.session_state.setup_complete:
47
  # Button to complete setup
48
  if st.button("Start Interview", on_click=complete_setup):
49
  st.write("Setup complete. Starting interview...")
50
-
51
- # # Setup stage for collecting user details
52
- # if not st.session_state.setup_complete:
53
- # st.subheader('Personal Information')
54
-
55
- # # Initialize session state for personal information
56
- # if "name" not in st.session_state:
57
- # st.session_state["name"] = ""
58
- # if "experience" not in st.session_state:
59
- # st.session_state["experience"] = ""
60
- # if "skills" not in st.session_state:
61
- # st.session_state["skills"] = ""
62
-
63
-
64
- # # Get personal information input
65
- # st.session_state["name"] = st.text_input(label="Name", value=st.session_state["name"], placeholder="Enter your name", max_chars=40)
66
- # st.session_state["experience"] = st.text_area(label="Experience", value=st.session_state["experience"], placeholder="Describe your experience", max_chars=200)
67
- # st.session_state["skills"] = st.text_area(label="Skills", value=st.session_state["skills"], placeholder="List your skills", max_chars=200)
68
-
69
 
70
- # # Company and Position Section
71
- # st.subheader('Company and Position')
72
-
73
- # # Initialize session state for company and position information and setting default values
74
- # if "level" not in st.session_state:
75
- # st.session_state["level"] = "Junior"
76
- # if "position" not in st.session_state:
77
- # st.session_state["position"] = "Data Scientist"
78
- # if "company" not in st.session_state:
79
- # st.session_state["company"] = "Amazon"
80
-
81
- # col1, col2 = st.columns(2)
82
- # with col1:
83
- # st.session_state["level"] = st.radio(
84
- # "Choose level",
85
- # key="visibility",
86
- # options=["Junior", "Mid-level", "Senior"],
87
- # index=["Junior", "Mid-level", "Senior"].index(st.session_state["level"])
88
- # )
89
-
90
- # with col2:
91
- # st.session_state["position"] = st.selectbox(
92
- # "Choose a position",
93
- # ("Data Scientist", "Data Engineer", "ML Engineer", "BI Analyst", "Financial Analyst"),
94
- # index=("Data Scientist", "Data Engineer", "ML Engineer", "BI Analyst", "Financial Analyst").index(st.session_state["position"])
95
- # )
96
-
97
- # st.session_state["company"] = st.selectbox(
98
- # "Select a Company",
99
- # ("Amazon", "Meta", "Udemy", "365 Company", "Nestle", "LinkedIn", "Spotify"),
100
- # index=("Amazon", "Meta", "Udemy", "365 Company", "Nestle", "LinkedIn", "Spotify").index(st.session_state["company"])
101
- # )
102
-
103
-
104
-
105
- # # Button to complete setup
106
- # if st.button("Start Interview", on_click=complete_setup):
107
- # st.write("Setup complete. Starting interview...")
108
-
109
  # Interview phase
110
  if st.session_state.setup_complete and not st.session_state.chat_complete:
111
 
112
- st.info(
113
- """
114
- Start by introducing yourself
115
- """,
116
- icon="👋",
117
- )
118
-
119
  # Initialize OpenAI client
120
  client = OpenAI(api_key=st.secrets["OPENAI_API_KEY"])
121
 
@@ -160,152 +95,4 @@ if st.session_state.setup_complete and not st.session_state.chat_complete:
160
 
161
  # Check if the user message count reaches 5
162
  if st.session_state.user_message_count >= 5:
163
- st.session_state.chat_complete = True
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
- # import streamlit as st
172
- # from openai import OpenAI
173
-
174
- # # Setting up the Streamlit page configuration
175
- # st.set_page_config(page_title="StreamlitChatMessageHistory", page_icon="💬")
176
- # st.title("Chatbot")
177
-
178
- # # Initialize session state variables
179
- # if "setup_complete" not in st.session_state:
180
- # st.session_state.setup_complete = False
181
- # if "user_message_count" not in st.session_state:
182
- # st.session_state.user_message_count = 0
183
- # if "feedback_shown" not in st.session_state:
184
- # st.session_state.feedback_shown = False
185
- # if "chat_complete" not in st.session_state:
186
- # st.session_state.chat_complete = False
187
- # if "messages" not in st.session_state:
188
- # st.session_state.messages = []
189
-
190
- # # Helper functions to update session state
191
- # def complete_setup():
192
- # st.session_state.setup_complete = True
193
-
194
- # # Setup stage for collecting user details
195
- # if not st.session_state.setup_complete:
196
- # st.subheader('Personal Information')
197
-
198
- # # Initialize session state for personal information
199
- # if "name" not in st.session_state:
200
- # st.session_state["name"] = ""
201
- # if "experience" not in st.session_state:
202
- # st.session_state["experience"] = ""
203
- # if "skills" not in st.session_state:
204
- # st.session_state["skills"] = ""
205
-
206
-
207
- # # Get personal information input
208
- # st.session_state["name"] = st.text_input(label="Name", value=st.session_state["name"], placeholder="Enter your name", max_chars=40)
209
- # st.session_state["experience"] = st.text_area(label="Experience", value=st.session_state["experience"], placeholder="Describe your experience", max_chars=200)
210
- # st.session_state["skills"] = st.text_area(label="Skills", value=st.session_state["skills"], placeholder="List your skills", max_chars=200)
211
-
212
-
213
- # # Company and Position Section
214
- # st.subheader('Company and Position')
215
-
216
- # # Initialize session state for company and position information and setting default values
217
- # if "level" not in st.session_state:
218
- # st.session_state["level"] = "Junior"
219
- # if "position" not in st.session_state:
220
- # st.session_state["position"] = "Data Scientist"
221
- # if "company" not in st.session_state:
222
- # st.session_state["company"] = "Amazon"
223
-
224
- # col1, col2 = st.columns(2)
225
- # with col1:
226
- # st.session_state["level"] = st.radio(
227
- # "Choose level",
228
- # key="visibility",
229
- # options=["Junior", "Mid-level", "Senior"],
230
- # index=["Junior", "Mid-level", "Senior"].index(st.session_state["level"])
231
- # )
232
-
233
- # with col2:
234
- # st.session_state["position"] = st.selectbox(
235
- # "Choose a position",
236
- # ("Data Scientist", "Data Engineer", "ML Engineer", "BI Analyst", "Financial Analyst"),
237
- # index=("Data Scientist", "Data Engineer", "ML Engineer", "BI Analyst", "Financial Analyst").index(st.session_state["position"])
238
- # )
239
-
240
- # st.session_state["company"] = st.selectbox(
241
- # "Select a Company",
242
- # ("Amazon", "Meta", "Udemy", "365 Company", "Nestle", "LinkedIn", "Spotify"),
243
- # index=("Amazon", "Meta", "Udemy", "365 Company", "Nestle", "LinkedIn", "Spotify").index(st.session_state["company"])
244
- # )
245
-
246
-
247
-
248
- # # Button to complete setup
249
- # if st.button("Start Interview", on_click=complete_setup):
250
- # st.write("Setup complete. Starting interview...")
251
-
252
- # # Interview phase
253
- # if st.session_state.setup_complete and not st.session_state.chat_complete:
254
-
255
- # st.info(
256
- # """
257
- # Start by introducing yourself
258
- # """,
259
- # icon="👋",
260
- # )
261
-
262
- # # Initialize OpenAI client
263
- # client = OpenAI(api_key=st.secrets["OPENAI_API_KEY"])
264
-
265
- # # Setting OpenAI model if not already initialized
266
- # if "openai_model" not in st.session_state:
267
- # st.session_state["openai_model"] = "gpt-4o"
268
-
269
- # # Initializing the system prompt for the chatbot
270
- # if not st.session_state.messages:
271
- # st.session_state.messages = [{
272
- # "role": "system",
273
- # "content": (f"You are an HR executive that interviews an interviewee called {st.session_state['name']} "
274
- # f"with experience {st.session_state['experience']} and skills {st.session_state['skills']}. "
275
- # f"You should interview him for the position {st.session_state['level']} {st.session_state['position']} "
276
- # f"at the company {st.session_state['company']}")
277
- # }]
278
-
279
- # # Display chat messages
280
- # for message in st.session_state.messages:
281
- # if message["role"] != "system":
282
- # with st.chat_message(message["role"]):
283
- # st.markdown(message["content"])
284
-
285
- # # Handle user input and OpenAI response
286
- # # Put a max_chars limit
287
- # if st.session_state.user_message_count < 5:
288
- # if prompt := st.chat_input("Your response", max_chars=1000):
289
- # st.session_state.messages.append({"role": "user", "content": prompt})
290
- # with st.chat_message("user"):
291
- # st.markdown(prompt)
292
-
293
- # if st.session_state.user_message_count < 4:
294
- # with st.chat_message("assistant"):
295
- # stream = client.chat.completions.create(
296
- # model=st.session_state["openai_model"],
297
- # messages=[
298
- # {"role": m["role"], "content": m["content"]}
299
- # for m in st.session_state.messages
300
- # ],
301
- # stream=True,
302
- # )
303
- # response = st.write_stream(stream)
304
- # st.session_state.messages.append({"role": "assistant", "content": response})
305
-
306
- # # Increment the user message count
307
- # st.session_state.user_message_count += 1
308
-
309
- # # Check if the user message count reaches 5
310
- # if st.session_state.user_message_count >= 5:
311
- # st.session_state.chat_complete = True
 
47
  # Button to complete setup
48
  if st.button("Start Interview", on_click=complete_setup):
49
  st.write("Setup complete. Starting interview...")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
  # Interview phase
52
  if st.session_state.setup_complete and not st.session_state.chat_complete:
53
 
 
 
 
 
 
 
 
54
  # Initialize OpenAI client
55
  client = OpenAI(api_key=st.secrets["OPENAI_API_KEY"])
56
 
 
95
 
96
  # Check if the user message count reaches 5
97
  if st.session_state.user_message_count >= 5:
98
+ st.session_state.chat_complete = True