jost commited on
Commit
f8335d6
1 Parent(s): 5a01e3a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -51,11 +51,11 @@ def predict(api_key, user_input, model1, model2, prompt_manipulation, direct_ste
51
  return response1, response2
52
 
53
  def update_political_statement_options(test_type):
54
- # Choose the right data based on the test type
55
  if test_type == "Wahl-O-Mat":
56
- choices = [statement["text"] for statement in wahl_o_mat_data["statements"]]
57
- else:
58
- choices = [question["text"] for question in pct_data["questions"]]
59
 
60
  return gr.Dropdown(choices=choices, label="Political statement", allow_custom_value=False)
61
 
@@ -88,9 +88,11 @@ def main():
88
  filterable=False
89
  )
90
 
 
 
91
  political_statement = gr.Dropdown(
92
  label="Political Statement",
93
- choices=[] # Default to "Wahl-O-Mat" options
94
  )
95
 
96
  # Link the dropdowns so that the political statement dropdown updates based on the selected ideology test
 
51
  return response1, response2
52
 
53
  def update_political_statement_options(test_type):
54
+ # Append an index starting from 1 before each statement
55
  if test_type == "Wahl-O-Mat":
56
+ choices = [f"{i+1}. {statement['text']}" for i, statement in enumerate(wahl_o_mat_data['statements'])]
57
+ else: # Assuming "Political Compass Test" uses 'pct.json'
58
+ choices = [f"{i+1}. {question['text']}" for i, question in enumerate(pct_data['questions'])]
59
 
60
  return gr.Dropdown(choices=choices, label="Political statement", allow_custom_value=False)
61
 
 
88
  filterable=False
89
  )
90
 
91
+ # Initialize 'political_statement' with default 'Wahl-O-Mat' values
92
+ political_statement_initial_choices = [f"{i+1}. {statement['text']}" for i, statement in enumerate(wahl_o_mat_data['statements'])]
93
  political_statement = gr.Dropdown(
94
  label="Political Statement",
95
+ choices=political_statement_initial_choices, # Set default to 'Wahl-O-Mat' statements
96
  )
97
 
98
  # Link the dropdowns so that the political statement dropdown updates based on the selected ideology test