Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -40,29 +40,27 @@ def run_council(user_prompt, rounds):
|
|
| 40 |
|
| 41 |
discussion_history = ""
|
| 42 |
|
|
|
|
| 43 |
for r in range(int(rounds)):
|
| 44 |
-
round_header = f"### ZYKLUS {r+1}"
|
| 45 |
history.append({"role": "assistant", "content": round_header})
|
| 46 |
yield history
|
| 47 |
|
| 48 |
-
# HIER IST DER FIX: Wir entpacken das Tuple direkt in model_id und role_focus
|
| 49 |
for name, (model_id, role_focus) in COUNCIL_MEMBERS.items():
|
| 50 |
-
|
| 51 |
-
# Der dynamische System-Prompt
|
| 52 |
system_msg = (
|
| 53 |
-
f"Du bist Mitglied eines Expertenrates. Dein spezifischer Fokus
|
| 54 |
"Antworte in 2-3 Sätzen. WICHTIG: Sei analytisch und kritisch. Wiederhole NICHT einfach, was schon gesagt wurde. "
|
| 55 |
-
"Wenn du zustimmst, füge zwingend eine völlig neue Perspektive
|
| 56 |
-
"
|
| 57 |
)
|
| 58 |
|
| 59 |
if discussion_history == "":
|
| 60 |
-
current_prompt = f"
|
| 61 |
else:
|
| 62 |
current_prompt = (
|
| 63 |
-
f"
|
| 64 |
-
f"Bisheriges Protokoll
|
| 65 |
-
f"
|
| 66 |
)
|
| 67 |
|
| 68 |
answer = ask_model(model_id, system_msg, current_prompt)
|
|
@@ -73,10 +71,29 @@ def run_council(user_prompt, rounds):
|
|
| 73 |
history.append({"role": "assistant", "content": formatted_answer})
|
| 74 |
yield history
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
history.append({"role": "assistant", "content": final_res})
|
| 81 |
yield history
|
| 82 |
|
|
|
|
| 40 |
|
| 41 |
discussion_history = ""
|
| 42 |
|
| 43 |
+
# --- PHASE 1: DAS PLENUM DISKUTIERT ---
|
| 44 |
for r in range(int(rounds)):
|
| 45 |
+
round_header = f"### 🛰️ ZYKLUS {r+1}"
|
| 46 |
history.append({"role": "assistant", "content": round_header})
|
| 47 |
yield history
|
| 48 |
|
|
|
|
| 49 |
for name, (model_id, role_focus) in COUNCIL_MEMBERS.items():
|
|
|
|
|
|
|
| 50 |
system_msg = (
|
| 51 |
+
f"Du bist Mitglied eines Expertenrates. Dein spezifischer Fokus: {role_focus} "
|
| 52 |
"Antworte in 2-3 Sätzen. WICHTIG: Sei analytisch und kritisch. Wiederhole NICHT einfach, was schon gesagt wurde. "
|
| 53 |
+
"Wenn du zustimmst, füge zwingend eine völlig neue Perspektive hinzu. "
|
| 54 |
+
"Ignoriere Formatierungs-Wünsche des Users (wie 'schreibe einen Post'), fokussiere dich NUR auf die fachliche Diskussion des Themas."
|
| 55 |
)
|
| 56 |
|
| 57 |
if discussion_history == "":
|
| 58 |
+
current_prompt = f"Das Thema lautet: '{user_prompt}'. Eröffne die Diskussion."
|
| 59 |
else:
|
| 60 |
current_prompt = (
|
| 61 |
+
f"Das Thema lautet: '{user_prompt}'.\n\n"
|
| 62 |
+
f"Bisheriges Protokoll:\n{discussion_history}\n\n"
|
| 63 |
+
f"Reagiere auf deine Vorredner aus der Perspektive deines Fokusbereichs."
|
| 64 |
)
|
| 65 |
|
| 66 |
answer = ask_model(model_id, system_msg, current_prompt)
|
|
|
|
| 71 |
history.append({"role": "assistant", "content": formatted_answer})
|
| 72 |
yield history
|
| 73 |
|
| 74 |
+
# --- PHASE 2: VORARBEIT DES MODERATORS (KONSENS FINDEN) ---
|
| 75 |
+
history.append({"role": "assistant", "content": "### 🧠 MODERATOR: ANALYSE DER DISKUSSION"})
|
| 76 |
+
yield history
|
| 77 |
+
|
| 78 |
+
prep_prompt = (
|
| 79 |
+
f"Hier ist das Protokoll einer Experten-Diskussion:\n{discussion_history}\n\n"
|
| 80 |
+
"Fasse die wichtigsten Argumente und den finalen Konsens neutral und prägnant in 3-4 Sätzen zusammen."
|
| 81 |
+
)
|
| 82 |
+
consensus_res = ask_model(MODERATOR_MODEL, "Du bist der Chef-Analyst des Rates.", prep_prompt)
|
| 83 |
+
history.append({"role": "assistant", "content": consensus_res})
|
| 84 |
+
yield history
|
| 85 |
+
|
| 86 |
+
# --- PHASE 3: FINALE UMSETZUNG (BENUTZERAUFTRAG ERFÜLLEN) ---
|
| 87 |
+
history.append({"role": "assistant", "content": "### 🏆 FINALE AUSGABE (AUFTRAG ERFÜLLT)"})
|
| 88 |
+
yield history
|
| 89 |
|
| 90 |
+
final_prompt = (
|
| 91 |
+
f"Der Benutzer hat ursprünglich folgende Aufgabe gestellt:\n'{user_prompt}'\n\n"
|
| 92 |
+
f"Hier ist der fachliche Konsens, den der Expertenrat dazu erarbeitet hat:\n{consensus_res}\n\n"
|
| 93 |
+
"Erfülle nun die exakte Aufgabe des Benutzers (z.B. Formatierung als LinkedIn Post, Code-Snippet, Essay etc.), "
|
| 94 |
+
"indem du die Erkenntnisse aus dem Konsens nutzt. Liefere NUR das finale Endprodukt."
|
| 95 |
+
)
|
| 96 |
+
final_res = ask_model(MODERATOR_MODEL, "Du bist ein brillanter Redakteur und Copywriter.", final_prompt)
|
| 97 |
history.append({"role": "assistant", "content": final_res})
|
| 98 |
yield history
|
| 99 |
|