mojakob commited on
Commit
0aaeda6
·
verified ·
1 Parent(s): 99709af

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -39
app.py CHANGED
@@ -1058,46 +1058,46 @@ with gr.Blocks(css=css) as app:
1058
  )
1059
 
1060
  # 4) After User Profile, go to Chatbot
1061
- def show_chatbot_after_profile(age, profession, interest, app_state=None):
1062
- # Check if app_state exists
1063
- if app_state is None:
1064
- raise ValueError("app_state is None. The state dictionary must be passed to the function.")
1065
-
1066
- # Debug inputs
1067
- if not age or not profession or not interest:
1068
- raise ValueError(f"Missing input values: Age={age}, Profession={profession}, Interest={interest}")
1069
-
1070
- # Update app_state
1071
- app_state["standardized_data"]["Age"] = age.strip()
1072
- app_state["standardized_data"]["Profession"] = profession.strip()
1073
- app_state["standardized_data"]["Interests"] = interest.strip()
1074
-
1075
- # Check app_state updates
1076
- if not app_state["standardized_data"]["Age"] or not app_state["standardized_data"]["Profession"] or not app_state["standardized_data"]["Interests"]:
1077
- raise ValueError(f"app_state['standardized_data'] not updated correctly: {app_state['standardized_data']}")
1078
-
1079
- # Debugging output
1080
- print(f"Updated app_state: {app_state}")
1081
-
1082
- # Return Gradio updates
1083
- return (
1084
- gr.update(visible=False), # Hide profile page
1085
- gr.update(visible=True), # Show chatbot page
1086
- "Profile submitted successfully. Proceeding to the chatbot." # Feedback message
1087
- )
1088
-
1089
- # Now back at the main script level (de-indented from the function)
1090
- debug_state_output = gr.JSON(label="State Debug")
1091
 
1092
- user_profile_button.click(
1093
- fn=show_chatbot_after_profile,
1094
- inputs=[age_input, profession_input, interest_input, gr.State(app_state)],
1095
- # We now have FOUR outputs, so you need four items here:
1096
- outputs=[page_3b, page_3, user_profile_output, debug_state_output]
1097
- )
1098
- # 5) After chatbot is done, go to Usability (button initially hidden)
1099
- def go_to_usability():
1100
- return gr.update(visible=False), gr.update(visible=True)
 
 
 
1101
 
1102
  # Transition to usability page after chatbot
1103
  # chatbot_done.click(
 
1058
  )
1059
 
1060
  # 4) After User Profile, go to Chatbot
1061
+ def show_chatbot_after_profile(age, profession, interest, app_state=None):
1062
+ # Check if app_state exists
1063
+ if app_state is None:
1064
+ raise ValueError("app_state is None. The state dictionary must be passed to the function.")
1065
+
1066
+ # Debug inputs
1067
+ if not age or not profession or not interest:
1068
+ raise ValueError(f"Missing input values: Age={age}, Profession={profession}, Interest={interest}")
1069
+
1070
+ # Update app_state
1071
+ app_state["standardized_data"]["Age"] = age.strip()
1072
+ app_state["standardized_data"]["Profession"] = profession.strip()
1073
+ app_state["standardized_data"]["Interests"] = interest.strip()
1074
+
1075
+ # Check app_state updates
1076
+ if not app_state["standardized_data"]["Age"] or not app_state["standardized_data"]["Profession"] or not app_state["standardized_data"]["Interests"]:
1077
+ raise ValueError(f"app_state['standardized_data'] not updated correctly: {app_state['standardized_data']}")
1078
+
1079
+ # Debugging output
1080
+ print(f"Updated app_state: {app_state}")
1081
+
1082
+ # Return Gradio updates
1083
+ return (
1084
+ gr.update(visible=False), # Hide profile page
1085
+ gr.update(visible=True), # Show chatbot page
1086
+ "Profile submitted successfully. Proceeding to the chatbot." # Feedback message
1087
+ )
 
 
 
1088
 
1089
+ # Now back at the main script level (de-indented from the function)
1090
+ debug_state_output = gr.JSON(label="State Debug")
1091
+
1092
+ user_profile_button.click(
1093
+ fn=show_chatbot_after_profile,
1094
+ inputs=[age_input, profession_input, interest_input, gr.State(app_state)],
1095
+ # We now have FOUR outputs, so you need four items here:
1096
+ outputs=[page_3b, page_3, user_profile_output, debug_state_output]
1097
+ )
1098
+ # 5) After chatbot is done, go to Usability (button initially hidden)
1099
+ def go_to_usability():
1100
+ return gr.update(visible=False), gr.update(visible=True)
1101
 
1102
  # Transition to usability page after chatbot
1103
  # chatbot_done.click(