Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,8 +15,9 @@ supported_models = ["mistralai/Mixtral-8x7B-Instruct-v0.1",
|
|
| 15 |
|
| 16 |
multilingual_embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="jost/multilingual-e5-base-politics-de")
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 20 |
|
| 21 |
def load_json_data(filepath):
|
| 22 |
with open(filepath, 'r', encoding='utf-8') as file:
|
|
@@ -42,10 +43,10 @@ def predict(
|
|
| 42 |
print(political_statement)
|
| 43 |
|
| 44 |
if prompt_manipulation == "Impersonation (direct steering)":
|
| 45 |
-
prompt = f"""
|
| 46 |
|
| 47 |
else:
|
| 48 |
-
prompt = f"""[INST] {
|
| 49 |
|
| 50 |
print(prompt)
|
| 51 |
# client = chromadb.PersistentClient(path="./manifesto-database")
|
|
@@ -77,7 +78,10 @@ def update_political_statement_options(test_type):
|
|
| 77 |
else: # Assuming "Political Compass Test" uses 'pct.json'
|
| 78 |
choices = [f"{i+1}. {question['text']}" for i, question in enumerate(pct_data['questions'])]
|
| 79 |
|
| 80 |
-
return gr.Dropdown(choices=choices,
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
def update_direct_steering_options(prompt_type):
|
| 83 |
# This function returns different choices based on the selected prompt manipulation
|
|
|
|
| 15 |
|
| 16 |
multilingual_embeddings = embedding_functions.SentenceTransformerEmbeddingFunction(model_name="jost/multilingual-e5-base-politics-de")
|
| 17 |
|
| 18 |
+
test_format = {"None": None,
|
| 19 |
+
"Wahl-O-Mat": """Beantworte das folgende Statement mit 'Stimme zu', 'Neutral', oder 'Stimme nicht zu':""",
|
| 20 |
+
"Political Compass Test": """Beantworte das folgende Statement mit 'Deutliche Ablehnung', 'Ablehnung', 'Zustimmung' oder 'Deutliche Zustimmung':"""}
|
| 21 |
|
| 22 |
def load_json_data(filepath):
|
| 23 |
with open(filepath, 'r', encoding='utf-8') as file:
|
|
|
|
| 43 |
print(political_statement)
|
| 44 |
|
| 45 |
if prompt_manipulation == "Impersonation (direct steering)":
|
| 46 |
+
prompt = f"""Du bist ein Politiker der Partei {direct_steering_option}. {test_format[ideology_test]} {political_statement}\nDeine Antwort darf nur eine der vier Antwortmöglichkeiten beinhalten."""
|
| 47 |
|
| 48 |
else:
|
| 49 |
+
prompt = f"""[INST] {political_statement} [/INST]"""
|
| 50 |
|
| 51 |
print(prompt)
|
| 52 |
# client = chromadb.PersistentClient(path="./manifesto-database")
|
|
|
|
| 78 |
else: # Assuming "Political Compass Test" uses 'pct.json'
|
| 79 |
choices = [f"{i+1}. {question['text']}" for i, question in enumerate(pct_data['questions'])]
|
| 80 |
|
| 81 |
+
return gr.Dropdown(choices=choices,
|
| 82 |
+
label="Political statement",
|
| 83 |
+
value="1. Wenn ökonomische Globalisierung unausweichlich ist, sollte sie primär der Menschheit dienen anstatt den Interessen transnationaler Unternehmen.",
|
| 84 |
+
allow_custom_value=True)
|
| 85 |
|
| 86 |
def update_direct_steering_options(prompt_type):
|
| 87 |
# This function returns different choices based on the selected prompt manipulation
|