Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,13 +33,16 @@ with open("technical_interviewer_prompt.txt", "r") as file:
|
|
| 33 |
|
| 34 |
st.title("Real-World Programming Question Mock Interview")
|
| 35 |
|
| 36 |
-
# Initialize
|
| 37 |
if "messages" not in st.session_state:
|
| 38 |
st.session_state.messages = []
|
| 39 |
|
| 40 |
if "follow_up_mode" not in st.session_state:
|
| 41 |
st.session_state.follow_up_mode = False # Tracks whether we're in follow-up mode
|
| 42 |
|
|
|
|
|
|
|
|
|
|
| 43 |
# Function to find the top 1 most similar question based on user input
|
| 44 |
def find_top_question(query):
|
| 45 |
# Generate embedding for the query
|
|
@@ -102,6 +105,9 @@ if generate_button:
|
|
| 102 |
# Generate response using GPT-4 with detailed prompt and debugging logs
|
| 103 |
response = generate_response([{"role": "assistant", "content": question_generation_prompt}, {"role": "user", "content": detailed_prompt}])
|
| 104 |
|
|
|
|
|
|
|
|
|
|
| 105 |
# Display assistant response in chat message container and add to session history
|
| 106 |
with st.chat_message("assistant"):
|
| 107 |
st.markdown(response)
|
|
@@ -135,6 +141,13 @@ if st.session_state.follow_up_mode:
|
|
| 135 |
|
| 136 |
st.session_state.messages.append({"role": "assistant", "content": assistant_response})
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
st.sidebar.markdown("""
|
| 139 |
## About
|
| 140 |
This is a Real-World Interview Question Generator powered by OpenAI's API.
|
|
|
|
| 33 |
|
| 34 |
st.title("Real-World Programming Question Mock Interview")
|
| 35 |
|
| 36 |
+
# Initialize session state variables
|
| 37 |
if "messages" not in st.session_state:
|
| 38 |
st.session_state.messages = []
|
| 39 |
|
| 40 |
if "follow_up_mode" not in st.session_state:
|
| 41 |
st.session_state.follow_up_mode = False # Tracks whether we're in follow-up mode
|
| 42 |
|
| 43 |
+
if "generated_question" not in st.session_state:
|
| 44 |
+
st.session_state.generated_question = None # Stores the generated question for persistence
|
| 45 |
+
|
| 46 |
# Function to find the top 1 most similar question based on user input
|
| 47 |
def find_top_question(query):
|
| 48 |
# Generate embedding for the query
|
|
|
|
| 105 |
# Generate response using GPT-4 with detailed prompt and debugging logs
|
| 106 |
response = generate_response([{"role": "assistant", "content": question_generation_prompt}, {"role": "user", "content": detailed_prompt}])
|
| 107 |
|
| 108 |
+
# Store generated question in session state for persistence in sidebar
|
| 109 |
+
st.session_state.generated_question = response
|
| 110 |
+
|
| 111 |
# Display assistant response in chat message container and add to session history
|
| 112 |
with st.chat_message("assistant"):
|
| 113 |
st.markdown(response)
|
|
|
|
| 141 |
|
| 142 |
st.session_state.messages.append({"role": "assistant", "content": assistant_response})
|
| 143 |
|
| 144 |
+
# Sidebar content to display persistent generated question
|
| 145 |
+
st.sidebar.markdown("## Generated Question")
|
| 146 |
+
if st.session_state.generated_question:
|
| 147 |
+
st.sidebar.markdown(st.session_state.generated_question)
|
| 148 |
+
else:
|
| 149 |
+
st.sidebar.markdown("_No question generated yet._")
|
| 150 |
+
|
| 151 |
st.sidebar.markdown("""
|
| 152 |
## About
|
| 153 |
This is a Real-World Interview Question Generator powered by OpenAI's API.
|