Entz commited on
Commit
b6a9e3d
·
verified ·
1 Parent(s): 5015203

Upload index.py

Browse files
Files changed (1) hide show
  1. index.py +29 -51
index.py CHANGED
@@ -135,58 +135,36 @@ with tab2:
135
  st.title("AI-Powered Registration System")
136
 
137
  if st.session_state.summary:
138
- st.success("Registration Complete!")
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
- if st.session_state.feedback:
155
- st.error(st.session_state.feedback)
156
- if st.session_state.prev_question and st.session_state.prev_question != st.session_state.current_question:
157
- transition_msg = random.choice(TRANSITION_MESSAGES).format(number=st.session_state.question_number)
158
- st.info(transition_msg)
159
- time.sleep(1)
160
- print(f"Displaying question: {st.session_state.current_question}")
161
- st.subheader(f"Question {st.session_state.question_number}: {st.session_state.current_question}")
162
-
163
- is_address_question = st.session_state.current_question == "What is your address?"
164
- is_phone_question = st.session_state.current_question == "What is your phone number?"
165
-
166
- if is_address_question or is_phone_question:
167
- st.info(
168
- f"This question is optional. Check the box to skip, or enter your information below.\n"
169
- 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"
170
- 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."
171
- )
172
- if is_address_question:
173
- st.session_state.skip_address = st.checkbox("Skip this question", value=st.session_state.skip_address)
174
- elif is_phone_question:
175
- st.session_state.skip_phone = st.checkbox("Skip this question", value=st.session_state.skip_phone)
176
-
177
- st.components.v1.html("""
178
- document.addEventListener('keypress', function(e) {
179
- if (e.key === 'Enter' && document.activeElement.tagName === 'INPUT') {
180
- e.preventDefault();
181
- const submitButton = document.querySelector('button[key="submit_button"]');
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...")