jost commited on
Commit
dbc5abe
·
verified ·
1 Parent(s): 04e6139

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -19
app.py CHANGED
@@ -19,7 +19,6 @@ wahl_o_mat_data = load_json_data('data/wahl-o-mat.json')
19
 
20
  def predict(
21
  api_key,
22
- user_input,
23
  model1,
24
  model2,
25
  prompt_manipulation,
@@ -31,7 +30,7 @@ def predict(
31
  ):
32
 
33
  print("Ideology Test:", ideology_test)
34
- print("Political Statement Number:", political_statement)
35
 
36
  if prompt_manipulation == "Impersonation (direct steering)":
37
  prompt = f"""[INST] Du bist ein Politiker der Partei {direct_steering_option}. {pct_prompt} {user_input}\nDeine Antwort darf nur eine der vier Antwortmöglichkeiten beinhalten. [/INST]"""
@@ -104,7 +103,8 @@ def main():
104
  # Initialize 'political_statement' with default 'Wahl-O-Mat' values
105
  political_statement_initial_choices = [f"{i+1}. {statement['text']}" for i, statement in enumerate(wahl_o_mat_data['statements'])]
106
  political_statement = gr.Dropdown(
107
- label="Selecet political statement or enter you own",
 
108
  choices=political_statement_initial_choices, # Set default to 'Wahl-O-Mat' statements
109
  allow_custom_value = True
110
  )
@@ -135,16 +135,8 @@ def main():
135
  # Link the dropdowns so that the option dropdown updates based on the selected prompt manipulation
136
  prompt_manipulation.change(fn=update_direct_steering_options, inputs=prompt_manipulation, outputs=direct_steering_option)
137
 
138
- with gr.Row():
139
- gr.Markdown("#### OR:")
140
-
141
-
142
- with gr.Row():
143
- user_input1 = gr.Textbox(label="Prompt", placeholder="Enter your own political statement here")
144
 
145
  with gr.Row():
146
- api_key_input = gr.Textbox(label="API Key", placeholder="Enter your API key here", show_label=True, type="password")
147
- user_input = gr.Textbox(label="Prompt", placeholder="Enter your message here")
148
  model_selector1 = gr.Dropdown(label="Model 1", choices=["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x22B-Instruct-v0.1"])
149
  model_selector2 = gr.Dropdown(label="Model 2", choices=["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x22B-Instruct-v0.1"])
150
  submit_btn = gr.Button("Submit")
@@ -156,22 +148,17 @@ def main():
156
 
157
  with gr.Tab("Settings"):
158
  with gr.Column():
159
- api_key_input = gr.Textbox(label="API Key", type="password")
160
  temp_input = gr.Slider(minimum=0, maximum=1, step=0.01, label="Temperature", value=0.7)
161
  top_p_input = gr.Slider(minimum=0, maximum=1, step=0.01, label="Top P", value=1)
162
 
163
  # Link settings to the predict function
164
  submit_btn.click(
165
  fn=predict,
166
- inputs=[api_key_input, user_input, model_selector1, model_selector2, prompt_manipulation, direct_steering_option, ideology_test, political_statement, temp_input, top_p_input],
167
  outputs=[output1, output2]
168
  )
169
- # submit_btn.click(
170
- # fn=predict,
171
- # inputs=[api_key_input, user_input, model_selector1, model_selector2, prompt_manipulation, direct_steering_option, ideology_test, political_statement],
172
- # outputs=[output1, output2]
173
- # )
174
-
175
  demo.launch()
176
 
177
  if __name__ == "__main__":
 
19
 
20
  def predict(
21
  api_key,
 
22
  model1,
23
  model2,
24
  prompt_manipulation,
 
30
  ):
31
 
32
  print("Ideology Test:", ideology_test)
33
+ print(political_statement)
34
 
35
  if prompt_manipulation == "Impersonation (direct steering)":
36
  prompt = f"""[INST] Du bist ein Politiker der Partei {direct_steering_option}. {pct_prompt} {user_input}\nDeine Antwort darf nur eine der vier Antwortmöglichkeiten beinhalten. [/INST]"""
 
103
  # Initialize 'political_statement' with default 'Wahl-O-Mat' values
104
  political_statement_initial_choices = [f"{i+1}. {statement['text']}" for i, statement in enumerate(wahl_o_mat_data['statements'])]
105
  political_statement = gr.Dropdown(
106
+ label="Select political statement or enter you own",
107
+ value="1. Auf allen Autobahnen soll ein generelles Tempolimit gelten.", # default value
108
  choices=political_statement_initial_choices, # Set default to 'Wahl-O-Mat' statements
109
  allow_custom_value = True
110
  )
 
135
  # Link the dropdowns so that the option dropdown updates based on the selected prompt manipulation
136
  prompt_manipulation.change(fn=update_direct_steering_options, inputs=prompt_manipulation, outputs=direct_steering_option)
137
 
 
 
 
 
 
 
138
 
139
  with gr.Row():
 
 
140
  model_selector1 = gr.Dropdown(label="Model 1", choices=["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x22B-Instruct-v0.1"])
141
  model_selector2 = gr.Dropdown(label="Model 2", choices=["mistralai/Mixtral-8x7B-Instruct-v0.1", "mistralai/Mixtral-8x22B-Instruct-v0.1"])
142
  submit_btn = gr.Button("Submit")
 
148
 
149
  with gr.Tab("Settings"):
150
  with gr.Column():
151
+ api_key_input = gr.Textbox(label="API Key", placeholder="Enter your API key here", show_label=True, type="password")
152
  temp_input = gr.Slider(minimum=0, maximum=1, step=0.01, label="Temperature", value=0.7)
153
  top_p_input = gr.Slider(minimum=0, maximum=1, step=0.01, label="Top P", value=1)
154
 
155
  # Link settings to the predict function
156
  submit_btn.click(
157
  fn=predict,
158
+ inputs=[api_key_input, model_selector1, model_selector2, prompt_manipulation, direct_steering_option, ideology_test, political_statement, temp_input, top_p_input],
159
  outputs=[output1, output2]
160
  )
161
+
 
 
 
 
 
162
  demo.launch()
163
 
164
  if __name__ == "__main__":