diff --git a/src/gui_2.py b/src/gui_2.py index 3a10785..0a32e45 100644 --- a/src/gui_2.py +++ b/src/gui_2.py @@ -131,7 +131,7 @@ class App: self._new_bias_tool_name = "run_powershell" self._new_bias_category_name = "General" self._editing_preset_name = "" - self._editing_preset_content = "" + self._editing_preset_system_prompt = "" self._editing_preset_temperature = 0.0 self._editing_preset_top_p = 1.0 self._editing_preset_max_output_tokens = 4096 @@ -146,6 +146,8 @@ class App: self._bias_split_v = 0.6 self._tool_list_open = True self._bias_list_open = True + self._bias_weights_open = True + self._bias_cats_open = True self._prompt_md_preview = False # Aliases for controller-owned locks self._send_thread_lock = self.controller._send_thread_lock @@ -952,9 +954,6 @@ class App: if imgui.button("New Preset", imgui.ImVec2(-1, 0)): self._editing_preset_name = "" self._editing_preset_system_prompt = "" - self._editing_preset_temperature = 0.7 - self._editing_preset_top_p = 1.0 - self._editing_preset_max_output_tokens = 4096 self._editing_preset_scope = "project" self._selected_preset_idx = -1 imgui.separator() @@ -965,20 +964,17 @@ class App: self._editing_preset_name = name p = self.controller.presets[name] self._editing_preset_system_prompt = p.system_prompt - self._editing_preset_temperature = p.temperature - self._editing_preset_top_p = p.top_p - self._editing_preset_max_output_tokens = p.max_output_tokens self._editing_preset_scope = self.controller.preset_manager.get_preset_scope(name) imgui.end_child() # Right Column: Editor imgui.table_next_column() avail_r = imgui.get_content_region_avail() - # Subtract space for bottom buttons (approx 45px) + # Subtract space for bottom buttons imgui.begin_child("prompt_edit_pane", imgui.ImVec2(0, avail_r.y - 45), False) p_disp = self._editing_preset_name or "(New Preset)" - imgui.text_colored(C_IN, f"Editing Preset: {p_disp}") + imgui.text_colored(C_IN, f"Editing Prompt Preset: {p_disp}") imgui.separator() if imgui.begin_table("p_meta", 2): @@ -1001,41 +997,6 @@ class App: self._editing_preset_scope = "project" imgui.end_table() - imgui.dummy(imgui.ImVec2(0, 4)) - imgui.separator() - imgui.text("Parameters:") - if imgui.begin_table("p_params", 2): - imgui.table_setup_column("L", imgui.TableColumnFlags_.width_fixed, 120) - imgui.table_setup_column("C", imgui.TableColumnFlags_.width_stretch) - imgui.table_next_row() - imgui.table_next_column() - imgui.text("Temperature:") - imgui.table_next_column() - cw = imgui.get_content_region_avail().x - imgui.set_next_item_width(cw * 0.7) - _, self._editing_preset_temperature = imgui.slider_float("##pts", self._editing_preset_temperature, 0.0, 2.0, "%.1f") - imgui.same_line() - imgui.set_next_item_width(-1) - _, self._editing_preset_temperature = imgui.input_float("##pti", self._editing_preset_temperature, 0.1, 0.1, "%.1f") - - imgui.table_next_row() - imgui.table_next_column() - imgui.text("Top-P:") - imgui.table_next_column() - imgui.set_next_item_width(cw * 0.7) - _, self._editing_preset_top_p = imgui.slider_float("##ptp_s", self._editing_preset_top_p, 0.0, 1.0, "%.2f") - imgui.same_line() - imgui.set_next_item_width(-1) - _, self._editing_preset_top_p = imgui.input_float("##ptp_i", self._editing_preset_top_p, 0.05, 0.05, "%.2f") - - imgui.table_next_row() - imgui.table_next_column() - imgui.text("Max Tokens:") - imgui.table_next_column() - imgui.set_next_item_width(-1) - _, self._editing_preset_max_output_tokens = imgui.input_int("##pmaxt", self._editing_preset_max_output_tokens) - imgui.end_table() - imgui.dummy(imgui.ImVec2(0, 4)) imgui.separator() imgui.text("Prompt Content:") @@ -1054,13 +1015,13 @@ class App: # Bottom Buttons imgui.separator() imgui.dummy(imgui.ImVec2(0, 4)) - if imgui.button("Save Preset", imgui.ImVec2(150, 0)): + if imgui.button("Save", imgui.ImVec2(100, 0)): if self._editing_preset_name.strip(): - p = models.Preset(name=self._editing_preset_name.strip(), system_prompt=self._editing_preset_system_prompt, temperature=self._editing_preset_temperature, top_p=self._editing_preset_top_p, max_output_tokens=self._editing_preset_max_output_tokens) + p = models.Preset(name=self._editing_preset_name.strip(), system_prompt=self._editing_preset_system_prompt) self.controller._cb_save_preset(p, self._editing_preset_scope) self.ai_status = f"Saved: {p.name}" imgui.same_line() - if imgui.button("Delete Preset", imgui.ImVec2(120, 0)): + if imgui.button("Delete", imgui.ImVec2(100, 0)): if self._editing_preset_name: self.controller._cb_delete_preset(self._editing_preset_name, self._editing_preset_scope) self._editing_preset_name = "" @@ -1099,6 +1060,8 @@ class App: if not hasattr(self, "_bias_split_v"): self._bias_split_v = 0.6 if not hasattr(self, "_tool_list_open"): self._tool_list_open = True if not hasattr(self, "_bias_list_open"): self._bias_list_open = True + if not hasattr(self, "_bias_weights_open"): self._bias_weights_open = True + if not hasattr(self, "_bias_cats_open"): self._bias_cats_open = True try: if imgui.begin_table("tp_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v): @@ -1142,8 +1105,7 @@ class App: # Vertical split calculation rem_y = imgui.get_content_region_avail().y - 80 if self._tool_list_open and self._bias_list_open: - h1 = rem_y * self._tool_split_v - h2 = rem_y - h1 - 10 + h1 = rem_y * self._tool_split_v; h2 = rem_y - h1 - 10 elif self._tool_list_open: h1, h2 = rem_y, 0 elif self._bias_list_open: h1, h2 = 0, rem_y else: h1, h2 = 0, 0 @@ -1172,7 +1134,7 @@ class App: mode = "disabled" if tool is None else tool.approval imgui.table_next_row(); imgui.table_next_column(); imgui.text(tool_name); imgui.table_next_column() if imgui.radio_button(f"Off##{cat_name}_{tool_name}", mode == "disabled"): - if tool: curr_cat_tools.remove(tool) + if tool: current_cat_tools.remove(tool) imgui.same_line(); if imgui.radio_button(f"Auto##{cat_name}_{tool_name}", mode == "auto"): if not tool: tool = models.Tool(name=tool_name, approval="auto"); current_cat_tools.append(tool) @@ -1181,13 +1143,6 @@ class App: if imgui.radio_button(f"Ask##{cat_name}_{tool_name}", mode == "ask"): if not tool: tool = models.Tool(name=tool_name, approval="ask"); current_cat_tools.append(tool) else: tool.approval = "ask" - if tool: - imgui.same_line(); imgui.text(" W:"); imgui.same_line(); imgui.set_next_item_width(60); _, tool.weight = imgui.slider_int(f"##w_{cat_name}_{tool_name}", tool.weight, 1, 5) - imgui.same_line(); imgui.text(" P:"); imgui.same_line(); imgui.set_next_item_width(-1); pb_str = json.dumps(tool.parameter_bias) - ch_pb, pb_new = imgui.input_text(f"##pb_{cat_name}_{tool_name}", pb_str) - if ch_pb: - try: tool.parameter_bias = json.loads(pb_new) - except: pass imgui.end_table(); imgui.tree_pop() imgui.end_child() if self._bias_list_open: @@ -1217,43 +1172,52 @@ class App: imgui.begin_child("bedit_pane", imgui.ImVec2(0, 0), False) imgui.text("Name:"); imgui.same_line(); imgui.set_next_item_width(-1); _, self._editing_bias_profile_name = imgui.input_text("##bname", self._editing_bias_profile_name) - # Bias Split: Weights vs Multipliers - rem_bias_y = imgui.get_content_region_avail().y - 40 - bh1 = rem_bias_y * self._bias_split_v - bh2 = rem_bias_y - bh1 - 10 + rem_bias_y = imgui.get_content_region_avail().y - 45 # Save button space + if self._bias_weights_open and self._bias_cats_open: + bh1 = rem_bias_y * self._bias_split_v; bh2 = rem_bias_y - bh1 - 10 + elif self._bias_weights_open: bh1, bh2 = rem_bias_y, 0 + elif self._bias_cats_open: bh1, bh2 = 0, rem_bias_y + else: bh1, bh2 = 0, 0 + + opened_bw = imgui.collapsing_header("Tool Weights", imgui.TreeNodeFlags_.default_open) + if opened_bw != self._bias_weights_open: self._bias_weights_open = opened_bw + if self._bias_weights_open: + imgui.begin_child("btool_scroll", imgui.ImVec2(0, bh1), True) + for cat_name, default_tools in models.DEFAULT_TOOL_CATEGORIES.items(): + if imgui.tree_node(f"{cat_name}##b"): + if imgui.begin_table(f"bt_{cat_name}", 2): + imgui.table_setup_column("T", imgui.TableColumnFlags_.width_fixed, 220); imgui.table_setup_column("W", imgui.TableColumnFlags_.width_stretch) + for tn in default_tools: + imgui.table_next_row(); imgui.table_next_column(); imgui.text(tn); imgui.table_next_column() + curr_w = self._editing_bias_profile_tool_weights.get(tn, 3); imgui.set_next_item_width(-1) + ch_w, n_w = imgui.slider_int(f"##bw_{tn}", curr_w, 1, 10); + if ch_w: self._editing_bias_profile_tool_weights[tn] = n_w + imgui.end_table(); imgui.tree_pop() + imgui.end_child() + if self._bias_cats_open: + imgui.button("###bias_splitter", imgui.ImVec2(-1, 4)) + if imgui.is_item_active(): self._bias_split_v = max(0.1, min(0.9, self._bias_split_v + imgui.get_io().mouse_delta.y / rem_bias_y)) - imgui.text_colored(C_KEY, "Tool Weights:"); imgui.begin_child("btool_scroll", imgui.ImVec2(0, bh1), True) - for cat_name, default_tools in models.DEFAULT_TOOL_CATEGORIES.items(): - if imgui.tree_node(f"{cat_name}##b"): - if imgui.begin_table(f"bt_{cat_name}", 2): - imgui.table_setup_column("T", imgui.TableColumnFlags_.width_fixed, 250); imgui.table_setup_column("W", imgui.TableColumnFlags_.width_stretch) - for tn in default_tools: - imgui.table_next_row(); imgui.table_next_column(); imgui.text(tn); imgui.table_next_column() - curr_w = self._editing_bias_profile_tool_weights.get(tn, 3); imgui.set_next_item_width(-1) - ch_w, n_w = imgui.slider_int(f"##bw_{tn}", curr_w, 1, 10); - if ch_w: self._editing_bias_profile_tool_weights[tn] = n_w - imgui.end_table(); imgui.tree_pop() - imgui.end_child() - - imgui.button("###bias_splitter", imgui.ImVec2(-1, 4)) - if imgui.is_item_active(): self._bias_split_v = max(0.1, min(0.9, self._bias_split_v + imgui.get_io().mouse_delta.y / rem_bias_y)) - - imgui.text_colored(C_KEY, "Category Multipliers:"); imgui.begin_child("bcat_scroll", imgui.ImVec2(0, bh2), True) - if imgui.begin_table("bcats", 2): - imgui.table_setup_column("C", imgui.TableColumnFlags_.width_fixed, 250); imgui.table_setup_column("M", imgui.TableColumnFlags_.width_stretch) - for cn in sorted(models.DEFAULT_TOOL_CATEGORIES.keys()): - imgui.table_next_row(); imgui.table_next_column(); imgui.text(cn); imgui.table_next_column() - curr_m = self._editing_bias_profile_category_multipliers.get(cn, 1.0); imgui.set_next_item_width(-1) - ch_m, n_m = imgui.slider_float(f"##cm_{cn}", curr_m, 0.1, 5.0, "%.1fx"); - if ch_m: self._editing_bias_profile_category_multipliers[cn] = n_m - imgui.end_table(); imgui.end_child() + opened_bc = imgui.collapsing_header("Category Multipliers", imgui.TreeNodeFlags_.default_open) + if opened_bc != self._bias_cats_open: self._bias_cats_open = opened_bc + if self._bias_cats_open: + imgui.begin_child("bcat_scroll", imgui.ImVec2(0, bh2), True) + if imgui.begin_table("bcats", 2): + imgui.table_setup_column("C", imgui.TableColumnFlags_.width_fixed, 220); imgui.table_setup_column("M", imgui.TableColumnFlags_.width_stretch) + for cn in sorted(models.DEFAULT_TOOL_CATEGORIES.keys()): + imgui.table_next_row(); imgui.table_next_column(); imgui.text(cn); imgui.table_next_column() + curr_m = self._editing_bias_profile_category_multipliers.get(cn, 1.0); imgui.set_next_item_width(-1) + ch_m, n_m = imgui.slider_float(f"##cm_{cn}", curr_m, 0.1, 5.0, "%.1fx"); + if ch_m: self._editing_bias_profile_category_multipliers[cn] = n_m + imgui.end_table(); imgui.end_child() if imgui.button("Save Profile", imgui.ImVec2(-1, 0)): try: p = models.BiasProfile(name=self._editing_bias_profile_name, tool_weights=self._editing_bias_profile_tool_weights, category_multipliers=self._editing_bias_profile_category_multipliers) self.controller._cb_save_bias_profile(p, self._editing_tool_preset_scope); self.ai_status = f"Saved: {p.name}" except Exception as e: self.ai_status = f"Error: {e}" - imgui.end_child(); imgui.end_table() + imgui.end_child() + imgui.end_table() imgui.end_child() imgui.end_child() @@ -1264,8 +1228,8 @@ class App: imgui.same_line(); if imgui.button("Delete", imgui.ImVec2(100, 0)): if self._editing_tool_preset_name: self.controller._cb_delete_tool_preset(self._editing_tool_preset_name, self._editing_tool_preset_scope); self._editing_tool_preset_name = ""; self._selected_tool_preset_idx = -1 + imgui.same_line(); if not is_embedded: - imgui.same_line(); if imgui.button("Close", imgui.ImVec2(100, 0)): self.show_tool_preset_manager_window = False imgui.end_table() finally: @@ -1310,7 +1274,7 @@ class App: if imgui.button("New Persona", imgui.ImVec2(-1, 0)): self._editing_persona_name = ""; self._editing_persona_system_prompt = "" self._editing_persona_tool_preset_id = ""; self._editing_persona_bias_profile_id = "" - self._editing_persona_preferred_models_list = [{"provider": self.current_provider, "model": self.current_model, "temperature": 0.7, "max_output_tokens": 4096, "history_trunc_limit": 900000}] + self._editing_persona_preferred_models_list = [{"provider": self.current_provider, "model": self.current_model, "temperature": 0.7, "top_p": 1.0, "max_output_tokens": 4096, "history_trunc_limit": 900000}] self._editing_persona_scope = "project"; self._editing_persona_is_new = True imgui.separator() personas = getattr(self.controller, 'personas', {}) @@ -1341,12 +1305,9 @@ class App: imgui.end_table() # Vertical Distribution Logic - header_h = 30 - rem_y = imgui.get_content_region_avail().y - 100 # Adjust for tables/headers - + rem_y = imgui.get_content_region_avail().y - 100 if self._persona_models_open and self._persona_prompt_open: - h1 = rem_y * self._persona_split_v - h2 = rem_y - h1 - 10 + h1 = rem_y * self._persona_split_v; h2 = rem_y - h1 - 10 elif self._persona_models_open: h1, h2 = rem_y, 0 elif self._persona_prompt_open: h1, h2 = 0, rem_y else: h1, h2 = 0, 0 @@ -1366,7 +1327,7 @@ class App: if imgui.button("-" if is_expanded else "+"): self._persona_pref_models_expanded[i] = not is_expanded imgui.same_line(); imgui.text(f"{i+1}."); imgui.same_line(); imgui.text_colored(C_LBL, f"{prov}"); imgui.same_line(); imgui.text("-"); imgui.same_line(); imgui.text_colored(C_IN, f"{mod}") if not is_expanded: - imgui.same_line(); summary = f" (T:{entry.get('temperature', 0.7):.1f}, M:{entry.get('max_output_tokens', 0)}, H:{entry.get('history_trunc_limit', 0)})" + imgui.same_line(); summary = f" (T:{entry.get('temperature', 0.7):.1f}, P:{entry.get('top_p', 1.0):.2f}, M:{entry.get('max_output_tokens', 0)})" imgui.text_colored(C_SUB, summary) imgui.same_line(imgui.get_content_region_avail().x - 30); if imgui.button("x"): to_remove.append(i) @@ -1384,6 +1345,9 @@ class App: imgui.table_next_row(); imgui.table_next_column(); imgui.text("Temperature:"); imgui.table_next_column(); cw = imgui.get_content_region_avail().x imgui.set_next_item_width(cw * 0.7); _, entry["temperature"] = imgui.slider_float("##ts", entry.get("temperature", 0.7), 0.0, 2.0, "%.1f") imgui.same_line(); imgui.set_next_item_width(-1); _, entry["temperature"] = imgui.input_float("##ti", entry.get("temperature", 0.7), 0.1, 0.1, "%.1f") + imgui.table_next_row(); imgui.table_next_column(); imgui.text("Top-P:"); imgui.table_next_column() + imgui.set_next_item_width(cw * 0.7); _, entry["top_p"] = imgui.slider_float("##tp_s", entry.get("top_p", 1.0), 0.0, 1.0, "%.2f") + imgui.same_line(); imgui.set_next_item_width(-1); _, entry["top_p"] = imgui.input_float("##tp_i", entry.get("top_p", 1.0), 0.05, 0.05, "%.2f") imgui.table_next_row(); imgui.table_next_column(); imgui.text("Max Tokens:"); imgui.table_next_column(); imgui.set_next_item_width(-1); _, entry["max_output_tokens"] = imgui.input_int("##maxt", entry.get("max_output_tokens", 4096)) imgui.table_next_row(); imgui.table_next_column(); imgui.text("History Limit:"); imgui.table_next_column(); imgui.set_next_item_width(-1); _, entry["history_trunc_limit"] = imgui.input_int("##hist", entry.get("history_trunc_limit", 900000)) imgui.end_table() @@ -1396,7 +1360,7 @@ class App: if imgui.is_item_active(): self._persona_split_v = max(0.1, min(0.9, self._persona_split_v + imgui.get_io().mouse_delta.y / rem_y)) imgui.dummy(imgui.ImVec2(0, 2)) - if imgui.button("Add Preferred Model", imgui.ImVec2(-1, 0)): self._editing_persona_preferred_models_list.append({"provider": self.current_provider, "model": self.current_model, "temperature": 0.7, "max_output_tokens": 4096, "history_trunc_limit": 900000}) + if imgui.button("Add Preferred Model", imgui.ImVec2(-1, 0)): self._editing_persona_preferred_models_list.append({"provider": self.current_provider, "model": self.current_model, "temperature": 0.7, "top_p": 1.0, "max_output_tokens": 4096, "history_trunc_limit": 900000}) imgui.dummy(imgui.ImVec2(0, 2)) if imgui.begin_table("p_assign", 2): @@ -1448,8 +1412,7 @@ class App: if imgui.button("Close", imgui.ImVec2(100, 0)): self.show_persona_editor_window = False imgui.end_table() except Exception as e: - import traceback - traceback.print_exc() + import traceback; traceback.print_exc() imgui.text_colored(vec4(255, 0, 0), f"Error in Persona Editor: {e}") finally: if not is_embedded: imgui.end()