Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
#
|
| 55 |
if test_type == "Wahl-O-Mat":
|
| 56 |
-
choices = [statement[
|
| 57 |
-
else:
|
| 58 |
-
choices = [question[
|
| 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=
|
| 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
|