Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,16 +25,16 @@ STRENGE REGELN:
|
|
| 25 |
- Wenn Vorredner existieren: Zeige, was ihre Perspektive blind macht
|
| 26 |
- Sei der Teufelsadvokat, aber konstruktiv"""
|
| 27 |
),
|
| 28 |
-
"⚡
|
| 29 |
"openai/gpt-oss-120b:novita",
|
| 30 |
-
"""Du bist der **
|
| 31 |
|
| 32 |
STRENGE REGELN:
|
| 33 |
-
- Beginne JEDEN Beitrag mit: "[
|
| 34 |
-
- MAXIMUM 3 Sätze,
|
| 35 |
-
- Dein Job:
|
| 36 |
-
- Wenn Vorredner existieren: Übersetze
|
| 37 |
-
-
|
| 38 |
)
|
| 39 |
}
|
| 40 |
|
|
@@ -71,12 +71,10 @@ def run_council(user_prompt, rounds):
|
|
| 71 |
history = [{"role": "user", "content": user_prompt}]
|
| 72 |
yield history
|
| 73 |
|
| 74 |
-
# Hier speichern wir den reinen Text OHNE HTML für die Modelle
|
| 75 |
discussion_history = ""
|
| 76 |
|
| 77 |
# --- PHASE 1: DAS PLENUM DISKUTIERT ---
|
| 78 |
for r in range(int(rounds)):
|
| 79 |
-
# Visuelle Trennlinie und Überschrift für die UI
|
| 80 |
round_header = f"<h2 style='color: #FF5A4D; border-bottom: 2px solid #FFEBE8; padding-bottom: 5px; margin-top: 20px;'>🔄 ZYKLUS {r+1} - EXPERTENDEBATTE</h2>"
|
| 81 |
history.append({"role": "assistant", "content": round_header})
|
| 82 |
yield history
|
|
@@ -100,10 +98,8 @@ def run_council(user_prompt, rounds):
|
|
| 100 |
|
| 101 |
answer = ask_model(model_id, system_msg, current_prompt)
|
| 102 |
|
| 103 |
-
# 1. Reiner Text für das interne Kontext-Fenster der KIs
|
| 104 |
discussion_history += f"{name}: {answer}\n\n"
|
| 105 |
|
| 106 |
-
# 2. Schick formatiertes HTML/Markdown für die UI
|
| 107 |
display_answer = f"**<span style='color: #4241A6; font-size: 1.1em;'>👤 {name}</span>**\n\n> {answer}"
|
| 108 |
history.append({"role": "assistant", "content": display_answer})
|
| 109 |
yield history
|
|
@@ -114,11 +110,10 @@ def run_council(user_prompt, rounds):
|
|
| 114 |
|
| 115 |
prep_prompt = (
|
| 116 |
f"Hier ist das Protokoll einer Experten-Diskussion:\n{discussion_history}\n\n"
|
| 117 |
-
"Fasse die wichtigsten Argumente und den finalen Konsens neutral und prägnant
|
| 118 |
)
|
| 119 |
consensus_res = ask_model(MODERATOR_MODEL, "Du bist der Chef-Analyst des Rates.", prep_prompt)
|
| 120 |
|
| 121 |
-
# Auch hier nutzen wir Blockquotes für bessere Lesbarkeit
|
| 122 |
history.append({"role": "assistant", "content": f"> {consensus_res}"})
|
| 123 |
yield history
|
| 124 |
|
|
@@ -126,13 +121,20 @@ def run_council(user_prompt, rounds):
|
|
| 126 |
history.append({"role": "assistant", "content": "<h2 style='color: #FF5A4D; border-bottom: 2px solid #FFEBE8; padding-bottom: 5px; margin-top: 20px;'>🏆 FINALE AUSGABE</h2>"})
|
| 127 |
yield history
|
| 128 |
|
|
|
|
| 129 |
final_prompt = (
|
| 130 |
-
f"Der Benutzer hat
|
| 131 |
-
f"Hier ist der fachliche Konsens
|
| 132 |
-
"
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 134 |
)
|
| 135 |
-
final_res = ask_model(MODERATOR_MODEL, "Du bist ein brillanter Redakteur und Copywriter, KI-Assistent.", final_prompt)
|
| 136 |
history.append({"role": "assistant", "content": final_res})
|
| 137 |
yield history
|
| 138 |
|
|
@@ -154,19 +156,19 @@ with gr.Blocks() as demo:
|
|
| 154 |
|
| 155 |
with gr.Row():
|
| 156 |
with gr.Column(scale=1):
|
| 157 |
-
gr.Markdown("")
|
| 158 |
with gr.Column(scale=3):
|
| 159 |
gr.Image(
|
| 160 |
value="banner.png",
|
| 161 |
show_label=False,
|
| 162 |
interactive=False,
|
| 163 |
container=False,
|
| 164 |
-
height=200,
|
| 165 |
width="auto",
|
| 166 |
elem_classes="banner-center"
|
| 167 |
)
|
| 168 |
with gr.Column(scale=1):
|
| 169 |
-
gr.Markdown("")
|
| 170 |
|
| 171 |
gr.HTML("<div style='text-align: center; margin-bottom: 2rem;'><p style='color: #4B5563; font-size: 1.1rem;'>AI-Driven Multi-Agent Consensus System</p></div>")
|
| 172 |
|
|
@@ -174,7 +176,7 @@ with gr.Blocks() as demo:
|
|
| 174 |
with gr.Column(scale=4):
|
| 175 |
input_text = gr.Textbox(
|
| 176 |
label="Benutzerauftrag / Thema",
|
| 177 |
-
placeholder="z.B. '
|
| 178 |
lines=2
|
| 179 |
)
|
| 180 |
with gr.Column(scale=1):
|
|
|
|
| 25 |
- Wenn Vorredner existieren: Zeige, was ihre Perspektive blind macht
|
| 26 |
- Sei der Teufelsadvokat, aber konstruktiv"""
|
| 27 |
),
|
| 28 |
+
"⚡ Pragmatiker (GPTOSS120b)": (
|
| 29 |
"openai/gpt-oss-120b:novita",
|
| 30 |
+
"""Du bist der **Pragmatiker** im Rat. Deine Superkraft: Ideen greifbar machen, Optionen aufzeigen, Entscheidungen erleichtern.
|
| 31 |
|
| 32 |
STRENGE REGELN:
|
| 33 |
+
- Beginne JEDEN Beitrag mit: "[PRAGMATIK] "
|
| 34 |
+
- MAXIMUM 3 Sätze, lösungsorientiert
|
| 35 |
+
- Dein Job: Welche konkreten Optionen gibt es? Was sind Kriterien für eine gute Entscheidung?
|
| 36 |
+
- Wenn Vorredner existieren: Übersetze abstrakte Punkte in handhabbare Alternativen
|
| 37 |
+
- Biete Rahmenbedingungen, keine strikten Vorschriften"""
|
| 38 |
)
|
| 39 |
}
|
| 40 |
|
|
|
|
| 71 |
history = [{"role": "user", "content": user_prompt}]
|
| 72 |
yield history
|
| 73 |
|
|
|
|
| 74 |
discussion_history = ""
|
| 75 |
|
| 76 |
# --- PHASE 1: DAS PLENUM DISKUTIERT ---
|
| 77 |
for r in range(int(rounds)):
|
|
|
|
| 78 |
round_header = f"<h2 style='color: #FF5A4D; border-bottom: 2px solid #FFEBE8; padding-bottom: 5px; margin-top: 20px;'>🔄 ZYKLUS {r+1} - EXPERTENDEBATTE</h2>"
|
| 79 |
history.append({"role": "assistant", "content": round_header})
|
| 80 |
yield history
|
|
|
|
| 98 |
|
| 99 |
answer = ask_model(model_id, system_msg, current_prompt)
|
| 100 |
|
|
|
|
| 101 |
discussion_history += f"{name}: {answer}\n\n"
|
| 102 |
|
|
|
|
| 103 |
display_answer = f"**<span style='color: #4241A6; font-size: 1.1em;'>👤 {name}</span>**\n\n> {answer}"
|
| 104 |
history.append({"role": "assistant", "content": display_answer})
|
| 105 |
yield history
|
|
|
|
| 110 |
|
| 111 |
prep_prompt = (
|
| 112 |
f"Hier ist das Protokoll einer Experten-Diskussion:\n{discussion_history}\n\n"
|
| 113 |
+
"Fasse die wichtigsten Argumente und den finalen Konsens neutral und prägnant zusammen."
|
| 114 |
)
|
| 115 |
consensus_res = ask_model(MODERATOR_MODEL, "Du bist der Chef-Analyst des Rates.", prep_prompt)
|
| 116 |
|
|
|
|
| 117 |
history.append({"role": "assistant", "content": f"> {consensus_res}"})
|
| 118 |
yield history
|
| 119 |
|
|
|
|
| 121 |
history.append({"role": "assistant", "content": "<h2 style='color: #FF5A4D; border-bottom: 2px solid #FFEBE8; padding-bottom: 5px; margin-top: 20px;'>🏆 FINALE AUSGABE</h2>"})
|
| 122 |
yield history
|
| 123 |
|
| 124 |
+
# WICHTIG: Nur formatieren wenn explizit gewünscht
|
| 125 |
final_prompt = (
|
| 126 |
+
f"Der Benutzer hat folgende Aufgabe gestellt:\n'{user_prompt}'\n\n"
|
| 127 |
+
f"Hier ist der fachliche Konsens des Expertenrats:\n{consensus_res}\n\n"
|
| 128 |
+
"""ANWEISUNG:
|
| 129 |
+
- Falls der User explizit ein Format wollte (LinkedIn-Post, Code, Essay, etc.): Nutze den Konsens als Inhalt und formatiere exakt wie gewünscht.
|
| 130 |
+
- Falls der User NUR eine Frage/Analyse wollte (ohne Format-Wunsch): Beantworte die Frage direkt mit dem Konsens als Grundlage. Kein künstliches Format erfinden!"""
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
final_res = ask_model(
|
| 134 |
+
MODERATOR_MODEL,
|
| 135 |
+
"Du bist ein vielseitiger Assistent.",
|
| 136 |
+
final_prompt
|
| 137 |
)
|
|
|
|
| 138 |
history.append({"role": "assistant", "content": final_res})
|
| 139 |
yield history
|
| 140 |
|
|
|
|
| 156 |
|
| 157 |
with gr.Row():
|
| 158 |
with gr.Column(scale=1):
|
| 159 |
+
gr.Markdown("")
|
| 160 |
with gr.Column(scale=3):
|
| 161 |
gr.Image(
|
| 162 |
value="banner.png",
|
| 163 |
show_label=False,
|
| 164 |
interactive=False,
|
| 165 |
container=False,
|
| 166 |
+
height=200,
|
| 167 |
width="auto",
|
| 168 |
elem_classes="banner-center"
|
| 169 |
)
|
| 170 |
with gr.Column(scale=1):
|
| 171 |
+
gr.Markdown("")
|
| 172 |
|
| 173 |
gr.HTML("<div style='text-align: center; margin-bottom: 2rem;'><p style='color: #4B5563; font-size: 1.1rem;'>AI-Driven Multi-Agent Consensus System</p></div>")
|
| 174 |
|
|
|
|
| 176 |
with gr.Column(scale=4):
|
| 177 |
input_text = gr.Textbox(
|
| 178 |
label="Benutzerauftrag / Thema",
|
| 179 |
+
placeholder="z.B. 'Vergleiche Kubeflow vs ZenML' oder 'Schreibe einen LinkedIn Post über KI-Regulierung'",
|
| 180 |
lines=2
|
| 181 |
)
|
| 182 |
with gr.Column(scale=1):
|