Upload index.py
Browse files
index.py
CHANGED
@@ -135,58 +135,36 @@ with tab2:
|
|
135 |
st.title("AI-Powered Registration System")
|
136 |
|
137 |
if st.session_state.summary:
|
138 |
-
|
139 |
-
st.subheader("Summary")
|
140 |
-
for key, value in st.session_state.summary.items():
|
141 |
-
st.write(f"**{key}**: {value}")
|
142 |
-
new_value = st.text_input(f"Edit {key}", key=f"edit_{key}")
|
143 |
-
if st.button(f"Update {key}", key=f"update_{key}"):
|
144 |
-
edit_field(key, new_value)
|
145 |
-
col1, col2 = st.columns(2)
|
146 |
-
with col1:
|
147 |
-
if st.button("Next Registration", key="next_reg", on_click=start_registration):
|
148 |
-
pass
|
149 |
-
with col2:
|
150 |
-
if st.button("End Session", key="end_sess", on_click=start_registration):
|
151 |
-
pass
|
152 |
else:
|
153 |
if st.session_state.current_question:
|
154 |
-
|
155 |
-
st.
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
if (submitButton && !submitButton.disabled) submitButton.click();
|
183 |
-
}
|
184 |
-
});
|
185 |
-
""", height=0)
|
186 |
-
|
187 |
-
st.session_state.answer = st.text_input("Your Answer", value="", key=f"answer_input_{st.session_state.question_number}")
|
188 |
-
|
189 |
-
if st.button("Submit", key="submit_button"):
|
190 |
-
submit_response()
|
191 |
else:
|
192 |
print("Waiting for session to initialize...")
|
|
|
135 |
st.title("AI-Powered Registration System")
|
136 |
|
137 |
if st.session_state.summary:
|
138 |
+
# [Summary code remains unchanged]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
else:
|
140 |
if st.session_state.current_question:
|
141 |
+
with st.form(key=f"question_form_{st.session_state.question_number}"):
|
142 |
+
if st.session_state.feedback:
|
143 |
+
st.error(st.session_state.feedback)
|
144 |
+
if st.session_state.prev_question and st.session_state.prev_question != st.session_state.current_question:
|
145 |
+
transition_msg = random.choice(TRANSITION_MESSAGES).format(number=st.session_state.question_number)
|
146 |
+
st.info(transition_msg)
|
147 |
+
time.sleep(1)
|
148 |
+
print(f"Displaying question: {st.session_state.current_question}")
|
149 |
+
st.subheader(f"Question {st.session_state.question_number}: {st.session_state.current_question}")
|
150 |
+
|
151 |
+
is_address_question = st.session_state.current_question == "What is your address?"
|
152 |
+
is_phone_question = st.session_state.current_question == "What is your phone number?"
|
153 |
+
|
154 |
+
if is_address_question or is_phone_question:
|
155 |
+
st.info(
|
156 |
+
f"This question is optional. Check the box to skip, or enter your information below.\n"
|
157 |
+
f"- For address: Include house number (e.g., 123), street name (e.g., High Street), town/city (e.g., London), and postcode (e.g., SW1A 1AA). Example: 123 High Street, London, SW1A 1AA.\n"
|
158 |
+
f"- For phone: Use 10 digits for landlines (e.g., 020 123 4567) or 11 digits for mobiles starting with 07 (e.g., 07700 900 123). Do not use +44 or other region numbers."
|
159 |
+
)
|
160 |
+
if is_address_question:
|
161 |
+
st.session_state.skip_address = st.checkbox("Skip this question", value=st.session_state.skip_address)
|
162 |
+
elif is_phone_question:
|
163 |
+
st.session_state.skip_phone = st.checkbox("Skip this question", value=st.session_state.skip_phone)
|
164 |
+
|
165 |
+
st.session_state.answer = st.text_input("Your Answer", value="", key=f"answer_input_{st.session_state.question_number}")
|
166 |
+
|
167 |
+
if st.form_submit_button("Submit", key="submit_button"):
|
168 |
+
submit_response()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
else:
|
170 |
print("Waiting for session to initialize...")
|