aidn commited on
Commit
1401dd9
·
verified ·
1 Parent(s): 45f1ed1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +38 -5
app.py CHANGED
@@ -47,8 +47,8 @@ def ask_model(model_id, system_prompt, user_input):
47
  for chunk in client.chat_completion(
48
  model=model_id,
49
  messages=messages,
50
- max_tokens=5000,
51
- temperature=0.4, # Wieder leicht runter auf 0.4 für mehr Bodenhaftung
52
  stream=True
53
  ):
54
  if hasattr(chunk, "choices") and chunk.choices and len(chunk.choices) > 0:
@@ -76,7 +76,6 @@ def run_council(user_prompt, rounds):
76
 
77
  for name, (model_id, role_focus) in COUNCIL_MEMBERS.items():
78
 
79
- # Ruhigere Global-Anweisung
80
  system_msg = (
81
  f"{role_focus}\n\n"
82
  "WICHTIG: Arbeite konstruktiv mit den anderen Experten zusammen. "
@@ -86,7 +85,6 @@ def run_council(user_prompt, rounds):
86
  if discussion_history == "":
87
  current_prompt = f"Das Thema lautet: '{user_prompt}'. Eröffne die Diskussion aus deiner Fachperspektive."
88
  else:
89
- # Sanfterer Zwang zur Interaktion
90
  current_prompt = (
91
  f"Das Thema lautet: '{user_prompt}'.\n\n"
92
  f"Bisheriges Protokoll:\n{discussion_history}\n\n"
@@ -99,8 +97,42 @@ def run_council(user_prompt, rounds):
99
 
100
  display_answer = f"**<span style='color: #4241A6; font-size: 1.1em;'>👤 {name}</span>**\n\n> {answer}"
101
  history.append({"role": "assistant", "content": display_answer})
102
- yield history
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  v_theme = gr.themes.Soft(
105
  primary_hue="indigo",
106
  font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"],
@@ -114,6 +146,7 @@ v_theme = gr.themes.Soft(
114
  color_accent_soft="#FFEBE8",
115
  )
116
 
 
117
  with gr.Blocks() as demo:
118
 
119
  gr.HTML("""
 
47
  for chunk in client.chat_completion(
48
  model=model_id,
49
  messages=messages,
50
+ max_tokens=800,
51
+ temperature=0.4,
52
  stream=True
53
  ):
54
  if hasattr(chunk, "choices") and chunk.choices and len(chunk.choices) > 0:
 
76
 
77
  for name, (model_id, role_focus) in COUNCIL_MEMBERS.items():
78
 
 
79
  system_msg = (
80
  f"{role_focus}\n\n"
81
  "WICHTIG: Arbeite konstruktiv mit den anderen Experten zusammen. "
 
85
  if discussion_history == "":
86
  current_prompt = f"Das Thema lautet: '{user_prompt}'. Eröffne die Diskussion aus deiner Fachperspektive."
87
  else:
 
88
  current_prompt = (
89
  f"Das Thema lautet: '{user_prompt}'.\n\n"
90
  f"Bisheriges Protokoll:\n{discussion_history}\n\n"
 
97
 
98
  display_answer = f"**<span style='color: #4241A6; font-size: 1.1em;'>👤 {name}</span>**\n\n> {answer}"
99
  history.append({"role": "assistant", "content": display_answer})
100
+ yield history
101
 
102
+ # --- PHASE 2: VORARBEIT DES MODERATORS (KONSENS FINDEN) ---
103
+ history.append({"role": "assistant", "content": "<h2 style='color: #FF5A4D; border-bottom: 2px solid #FFEBE8; padding-bottom: 5px; margin-top: 20px;'>🧠 MODERATOR: ANALYSE DER DISKUSSION</h2>"})
104
+ yield history
105
+
106
+ prep_prompt = (
107
+ f"Hier ist das Protokoll einer Experten-Diskussion:\n{discussion_history}\n\n"
108
+ "Fasse die wichtigsten Argumente und den finalen pragmatischen Konsens neutral und prägnant zusammen."
109
+ )
110
+ consensus_res = ask_model(MODERATOR_MODEL, "Du bist der Chef-Analyst des Rates.", prep_prompt)
111
+
112
+ history.append({"role": "assistant", "content": f"> {consensus_res}"})
113
+ yield history
114
+
115
+ # --- PHASE 3: FINALE UMSETZUNG (BENUTZERAUFTRAG ERFÜLLEN) ---
116
+ history.append({"role": "assistant", "content": "<h2 style='color: #FF5A4D; border-bottom: 2px solid #FFEBE8; padding-bottom: 5px; margin-top: 20px;'>🏆 FINALE AUSGABE</h2>"})
117
+ yield history
118
+
119
+ final_prompt = (
120
+ f"Der Benutzer hat folgende Aufgabe gestellt:\n'{user_prompt}'\n\n"
121
+ f"Hier ist der fachliche Konsens des Expertenrats:\n{consensus_res}\n\n"
122
+ """ANWEISUNG:
123
+ - Falls der User explizit ein Format wollte (LinkedIn-Post, Code, Essay, etc.): Nutze den Konsens als Inhalt und formatiere exakt wie gewünscht.
124
+ - 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!"""
125
+ )
126
+
127
+ final_res = ask_model(
128
+ MODERATOR_MODEL,
129
+ "Du bist ein vielseitiger Assistent.",
130
+ final_prompt
131
+ )
132
+ history.append({"role": "assistant", "content": final_res})
133
+ yield history
134
+
135
+ # --- VALANTIC THEME ---
136
  v_theme = gr.themes.Soft(
137
  primary_hue="indigo",
138
  font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"],
 
146
  color_accent_soft="#FFEBE8",
147
  )
148
 
149
+ # --- UI LAYOUT ---
150
  with gr.Blocks() as demo:
151
 
152
  gr.HTML("""