|
|
|
|
@@ -942,8 +942,8 @@ class App:
|
|
|
|
|
avail = imgui.get_content_region_avail()
|
|
|
|
|
if not hasattr(self, "_prompt_md_preview"): self._prompt_md_preview = False
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
if imgui.begin_table("prompt_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v):
|
|
|
|
|
if imgui.begin_table("prompt_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v):
|
|
|
|
|
try:
|
|
|
|
|
imgui.table_setup_column("List", imgui.TableColumnFlags_.width_fixed, 200)
|
|
|
|
|
imgui.table_setup_column("Editor", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
imgui.table_next_row()
|
|
|
|
|
@@ -951,66 +951,68 @@ class App:
|
|
|
|
|
# Left Column: Presets
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
imgui.begin_child("prompt_list_pane", imgui.ImVec2(0, 0), False)
|
|
|
|
|
if imgui.button("New Preset", imgui.ImVec2(-1, 0)):
|
|
|
|
|
self._editing_preset_name = ""
|
|
|
|
|
self._editing_preset_system_prompt = ""
|
|
|
|
|
self._editing_preset_scope = "project"
|
|
|
|
|
self._selected_preset_idx = -1
|
|
|
|
|
imgui.separator()
|
|
|
|
|
preset_names = sorted(self.controller.presets.keys())
|
|
|
|
|
for i, name in enumerate(preset_names):
|
|
|
|
|
if imgui.selectable(name, self._selected_preset_idx == i)[0]:
|
|
|
|
|
self._selected_preset_idx = i
|
|
|
|
|
self._editing_preset_name = name
|
|
|
|
|
p = self.controller.presets[name]
|
|
|
|
|
self._editing_preset_system_prompt = p.system_prompt
|
|
|
|
|
self._editing_preset_scope = self.controller.preset_manager.get_preset_scope(name)
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
try:
|
|
|
|
|
if imgui.button("New Preset", imgui.ImVec2(-1, 0)):
|
|
|
|
|
self._editing_preset_name = ""
|
|
|
|
|
self._editing_preset_system_prompt = ""
|
|
|
|
|
self._editing_preset_scope = "project"
|
|
|
|
|
self._selected_preset_idx = -1
|
|
|
|
|
imgui.separator()
|
|
|
|
|
preset_names = sorted(self.controller.presets.keys())
|
|
|
|
|
for i, name in enumerate(preset_names):
|
|
|
|
|
if name and imgui.selectable(f"{name}##p_{i}", self._selected_preset_idx == i)[0]:
|
|
|
|
|
self._selected_preset_idx = i
|
|
|
|
|
self._editing_preset_name = name
|
|
|
|
|
p = self.controller.presets[name]
|
|
|
|
|
self._editing_preset_system_prompt = p.system_prompt
|
|
|
|
|
self._editing_preset_scope = self.controller.preset_manager.get_preset_scope(name)
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
|
|
|
|
|
# Right Column: Editor
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
avail_r = imgui.get_content_region_avail()
|
|
|
|
|
# Subtract space for bottom buttons
|
|
|
|
|
imgui.begin_child("prompt_edit_pane", imgui.ImVec2(0, avail_r.y - 45), False)
|
|
|
|
|
try:
|
|
|
|
|
p_disp = self._editing_preset_name or "(New Preset)"
|
|
|
|
|
imgui.text_colored(C_IN, f"Editing Prompt Preset: {p_disp}")
|
|
|
|
|
imgui.separator()
|
|
|
|
|
|
|
|
|
|
p_disp = self._editing_preset_name or "(New Preset)"
|
|
|
|
|
imgui.text_colored(C_IN, f"Editing Prompt Preset: {p_disp}")
|
|
|
|
|
imgui.separator()
|
|
|
|
|
if imgui.begin_table("p_meta", 2):
|
|
|
|
|
try:
|
|
|
|
|
imgui.table_setup_column("L", imgui.TableColumnFlags_.width_fixed, 80)
|
|
|
|
|
imgui.table_setup_column("F", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
imgui.table_next_row()
|
|
|
|
|
imgui.table_next_column(); imgui.text("Name:")
|
|
|
|
|
imgui.table_next_column(); imgui.set_next_item_width(-1)
|
|
|
|
|
_, self._editing_preset_name = imgui.input_text("##epn", self._editing_preset_name)
|
|
|
|
|
imgui.table_next_row()
|
|
|
|
|
imgui.table_next_column(); imgui.text("Scope:")
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
if imgui.radio_button("Global", self._editing_preset_scope == "global"): self._editing_preset_scope = "global"
|
|
|
|
|
imgui.same_line()
|
|
|
|
|
if imgui.radio_button("Project", self._editing_preset_scope == "project"): self._editing_preset_scope = "project"
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
|
|
|
|
|
if imgui.begin_table("p_meta", 2):
|
|
|
|
|
imgui.table_setup_column("L", imgui.TableColumnFlags_.width_fixed, 80)
|
|
|
|
|
imgui.table_setup_column("F", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
imgui.table_next_row()
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
imgui.text("Name:")
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
imgui.set_next_item_width(-1)
|
|
|
|
|
_, self._editing_preset_name = imgui.input_text("##epn", self._editing_preset_name)
|
|
|
|
|
imgui.table_next_row()
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
imgui.text("Scope:")
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
if imgui.radio_button("Global", self._editing_preset_scope == "global"):
|
|
|
|
|
self._editing_preset_scope = "global"
|
|
|
|
|
imgui.dummy(imgui.ImVec2(0, 4))
|
|
|
|
|
imgui.separator()
|
|
|
|
|
imgui.text("Prompt Content:")
|
|
|
|
|
imgui.same_line()
|
|
|
|
|
if imgui.radio_button("Project", self._editing_preset_scope == "project"):
|
|
|
|
|
self._editing_preset_scope = "project"
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
if imgui.button("MD Preview" if not self._prompt_md_preview else "Edit Mode"):
|
|
|
|
|
self._prompt_md_preview = not self._prompt_md_preview
|
|
|
|
|
|
|
|
|
|
imgui.dummy(imgui.ImVec2(0, 4))
|
|
|
|
|
imgui.separator()
|
|
|
|
|
imgui.text("Prompt Content:")
|
|
|
|
|
imgui.same_line()
|
|
|
|
|
if imgui.button("MD Preview" if not self._prompt_md_preview else "Edit Mode"):
|
|
|
|
|
self._prompt_md_preview = not self._prompt_md_preview
|
|
|
|
|
|
|
|
|
|
if self._prompt_md_preview:
|
|
|
|
|
imgui.begin_child("prompt_preview", imgui.ImVec2(-1, imgui.get_content_region_avail().y), True)
|
|
|
|
|
self.markdown_renderer.render(self._editing_preset_system_prompt)
|
|
|
|
|
if self._prompt_md_preview:
|
|
|
|
|
imgui.begin_child("prompt_preview", imgui.ImVec2(-1, imgui.get_content_region_avail().y), True)
|
|
|
|
|
try:
|
|
|
|
|
markdown_helper.render(self._editing_preset_system_prompt, context_id="prompt_preset_preview")
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
else:
|
|
|
|
|
_, self._editing_preset_system_prompt = imgui.input_text_multiline("##pcont", self._editing_preset_system_prompt, imgui.ImVec2(-1, imgui.get_content_region_avail().y))
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
else:
|
|
|
|
|
_, self._editing_preset_system_prompt = imgui.input_text_multiline("##pcont", self._editing_preset_system_prompt, imgui.ImVec2(-1, imgui.get_content_region_avail().y))
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
|
|
|
|
|
# Bottom Buttons
|
|
|
|
|
imgui.separator()
|
|
|
|
|
@@ -1030,9 +1032,8 @@ class App:
|
|
|
|
|
imgui.same_line()
|
|
|
|
|
if imgui.button("Close", imgui.ImVec2(100, 0)):
|
|
|
|
|
self.show_preset_manager_window = False
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
finally:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
def _render_preset_manager_window(self, is_embedded: bool = False) -> None:
|
|
|
|
|
if not self.show_preset_manager_window and not is_embedded: return
|
|
|
|
|
@@ -1063,8 +1064,8 @@ class App:
|
|
|
|
|
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):
|
|
|
|
|
if imgui.begin_table("tp_main_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v):
|
|
|
|
|
try:
|
|
|
|
|
imgui.table_setup_column("List", imgui.TableColumnFlags_.width_fixed, 200)
|
|
|
|
|
imgui.table_setup_column("Editor", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
imgui.table_next_row()
|
|
|
|
|
@@ -1072,154 +1073,182 @@ class App:
|
|
|
|
|
# Left Sidebar
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
imgui.begin_child("tp_list_pane", imgui.ImVec2(0, 0), False)
|
|
|
|
|
if imgui.button("New Preset", imgui.ImVec2(-1, 0)):
|
|
|
|
|
self._editing_tool_preset_name = ""; self._editing_tool_preset_categories = {cat: {} for cat in models.DEFAULT_TOOL_CATEGORIES}
|
|
|
|
|
self._editing_tool_preset_scope = "project"; self._selected_tool_preset_idx = -1
|
|
|
|
|
imgui.separator()
|
|
|
|
|
preset_names = sorted(self.controller.tool_presets.keys())
|
|
|
|
|
for i, name in enumerate(preset_names):
|
|
|
|
|
if imgui.selectable(name, self._selected_tool_preset_idx == i)[0]:
|
|
|
|
|
self._selected_tool_preset_idx = i; self._editing_tool_preset_name = name
|
|
|
|
|
preset = self.controller.tool_presets[name]
|
|
|
|
|
self._editing_tool_preset_categories = {cat: copy.deepcopy(tools) for cat, tools in preset.categories.items()}
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
try:
|
|
|
|
|
if imgui.button("New Preset", imgui.ImVec2(-1, 0)):
|
|
|
|
|
self._editing_tool_preset_name = ""; self._editing_tool_preset_categories = {cat: {} for cat in models.DEFAULT_TOOL_CATEGORIES}
|
|
|
|
|
self._editing_tool_preset_scope = "project"; self._selected_tool_preset_idx = -1
|
|
|
|
|
imgui.separator()
|
|
|
|
|
preset_names = sorted(self.controller.tool_presets.keys())
|
|
|
|
|
for i, name in enumerate(preset_names):
|
|
|
|
|
if imgui.selectable(f"{name}##tp_{i}", self._selected_tool_preset_idx == i)[0]:
|
|
|
|
|
self._selected_tool_preset_idx = i; self._editing_tool_preset_name = name
|
|
|
|
|
preset = self.controller.tool_presets[name]
|
|
|
|
|
self._editing_tool_preset_categories = {cat: copy.deepcopy(tools) for cat, tools in preset.categories.items()}
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
|
|
|
|
|
# Right Editor
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
avail_r = imgui.get_content_region_avail()
|
|
|
|
|
# Bottom buttons reserved space
|
|
|
|
|
imgui.begin_child("tp_editor_content", imgui.ImVec2(0, avail_r.y - 45), False)
|
|
|
|
|
try:
|
|
|
|
|
p_name = self._editing_tool_preset_name or "(New Tool Preset)"
|
|
|
|
|
imgui.text_colored(C_IN, f"Editing Tool Preset: {p_name}"); imgui.separator()
|
|
|
|
|
|
|
|
|
|
p_name = self._editing_tool_preset_name or "(New Tool Preset)"
|
|
|
|
|
imgui.text_colored(C_IN, f"Editing Tool Preset: {p_name}"); imgui.separator()
|
|
|
|
|
if imgui.begin_table("tp_meta", 2):
|
|
|
|
|
try:
|
|
|
|
|
imgui.table_setup_column("L", imgui.TableColumnFlags_.width_fixed, 80); imgui.table_setup_column("F", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
imgui.table_next_row(); imgui.table_next_column(); imgui.text("Name:"); imgui.table_next_column(); imgui.set_next_item_width(-1); _, self._editing_tool_preset_name = imgui.input_text("##etpn", self._editing_tool_preset_name)
|
|
|
|
|
imgui.table_next_row(); imgui.table_next_column(); imgui.text("Scope:"); imgui.table_next_column()
|
|
|
|
|
if imgui.radio_button("Global", self._editing_tool_preset_scope == "global"): self._editing_tool_preset_scope = "global"
|
|
|
|
|
imgui.same_line();
|
|
|
|
|
if imgui.radio_button("Project", self._editing_tool_preset_scope == "project"): self._editing_tool_preset_scope = "project"
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
|
|
|
|
|
if imgui.begin_table("tp_meta", 2):
|
|
|
|
|
imgui.table_setup_column("L", imgui.TableColumnFlags_.width_fixed, 80); imgui.table_setup_column("F", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
imgui.table_next_row(); imgui.table_next_column(); imgui.text("Name:"); imgui.table_next_column(); imgui.set_next_item_width(-1); _, self._editing_tool_preset_name = imgui.input_text("##etpn", self._editing_tool_preset_name)
|
|
|
|
|
imgui.table_next_row(); imgui.table_next_column(); imgui.text("Scope:"); imgui.table_next_column()
|
|
|
|
|
if imgui.radio_button("Global", self._editing_tool_preset_scope == "global"): self._editing_tool_preset_scope = "global"
|
|
|
|
|
imgui.same_line();
|
|
|
|
|
if imgui.radio_button("Project", self._editing_tool_preset_scope == "project"): self._editing_tool_preset_scope = "project"
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
# 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
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
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
|
|
|
|
|
imgui.dummy(imgui.ImVec2(0, 4))
|
|
|
|
|
opened_tools = imgui.collapsing_header("Categories & Tools", imgui.TreeNodeFlags_.default_open)
|
|
|
|
|
if opened_tools != self._tool_list_open: self._tool_list_open = opened_tools
|
|
|
|
|
|
|
|
|
|
imgui.dummy(imgui.ImVec2(0, 4))
|
|
|
|
|
opened_tools = imgui.collapsing_header("Categories & Tools", imgui.TreeNodeFlags_.default_open)
|
|
|
|
|
if opened_tools != self._tool_list_open: self._tool_list_open = opened_tools
|
|
|
|
|
if self._tool_list_open:
|
|
|
|
|
imgui.text("Filter:"); imgui.same_line()
|
|
|
|
|
cat_opts = ["All"] + sorted(list(models.DEFAULT_TOOL_CATEGORIES.keys()))
|
|
|
|
|
f_idx = cat_opts.index(self.ui_tool_filter_category) if self.ui_tool_filter_category in cat_opts else 0
|
|
|
|
|
imgui.set_next_item_width(200); ch_cat, next_f_idx = imgui.combo("##tp_filter", f_idx, cat_opts)
|
|
|
|
|
if ch_cat: self.ui_tool_filter_category = cat_opts[next_f_idx]
|
|
|
|
|
|
|
|
|
|
if self._tool_list_open:
|
|
|
|
|
imgui.text("Filter:"); imgui.same_line()
|
|
|
|
|
cat_opts = ["All"] + sorted(list(models.DEFAULT_TOOL_CATEGORIES.keys()))
|
|
|
|
|
f_idx = cat_opts.index(self.ui_tool_filter_category) if self.ui_tool_filter_category in cat_opts else 0
|
|
|
|
|
imgui.set_next_item_width(200); ch_cat, next_f_idx = imgui.combo("##tp_filter", f_idx, cat_opts)
|
|
|
|
|
if ch_cat: self.ui_tool_filter_category = cat_opts[next_f_idx]
|
|
|
|
|
|
|
|
|
|
imgui.begin_child("tp_scroll", imgui.ImVec2(0, h1), True)
|
|
|
|
|
for cat_name, default_tools in models.DEFAULT_TOOL_CATEGORIES.items():
|
|
|
|
|
if self.ui_tool_filter_category != "All" and self.ui_tool_filter_category != cat_name: continue
|
|
|
|
|
if imgui.tree_node(cat_name):
|
|
|
|
|
if cat_name not in self._editing_tool_preset_categories: self._editing_tool_preset_categories[cat_name] = []
|
|
|
|
|
curr_cat_tools = self._editing_tool_preset_categories[cat_name]
|
|
|
|
|
if imgui.begin_table(f"tt_{cat_name}", 2, imgui.TableFlags_.borders_inner_v):
|
|
|
|
|
imgui.table_setup_column("Tool", imgui.TableColumnFlags_.width_fixed, 250); imgui.table_setup_column("Ctrls", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
for tool_name in default_tools:
|
|
|
|
|
tool = next((t for t in curr_cat_tools if t.name == tool_name), None)
|
|
|
|
|
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: 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)
|
|
|
|
|
else: tool.approval = "auto"
|
|
|
|
|
imgui.same_line();
|
|
|
|
|
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"
|
|
|
|
|
imgui.end_table(); imgui.tree_pop()
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
if self._bias_list_open:
|
|
|
|
|
imgui.button("###tool_splitter", imgui.ImVec2(-1, 4))
|
|
|
|
|
if imgui.is_item_active(): self._tool_split_v = max(0.1, min(0.9, self._tool_split_v + imgui.get_io().mouse_delta.y / rem_y))
|
|
|
|
|
|
|
|
|
|
imgui.dummy(imgui.ImVec2(0, 4))
|
|
|
|
|
opened_bias = imgui.collapsing_header("Bias Profiles", imgui.TreeNodeFlags_.default_open)
|
|
|
|
|
if opened_bias != self._bias_list_open: self._bias_list_open = opened_bias
|
|
|
|
|
|
|
|
|
|
if self._bias_list_open:
|
|
|
|
|
imgui.begin_child("bias_area", imgui.ImVec2(0, h2), True)
|
|
|
|
|
if imgui.begin_table("bias_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v):
|
|
|
|
|
imgui.table_setup_column("BList", imgui.TableColumnFlags_.width_fixed, 150); imgui.table_setup_column("BEdit", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
imgui.table_next_row(); imgui.table_next_column()
|
|
|
|
|
imgui.begin_child("blist_pane", imgui.ImVec2(0, 0), False)
|
|
|
|
|
if imgui.button("New Profile", imgui.ImVec2(-1, 0)):
|
|
|
|
|
self._editing_bias_profile_name = ""; self._editing_bias_profile_tool_weights = {}
|
|
|
|
|
self._editing_bias_profile_category_multipliers = {}; self._selected_bias_profile_idx = -1
|
|
|
|
|
imgui.separator(); bnames = sorted(self.bias_profiles.keys())
|
|
|
|
|
for i, bname in enumerate(bnames):
|
|
|
|
|
if imgui.selectable(bname, self._selected_bias_profile_idx == i)[0]:
|
|
|
|
|
self._selected_bias_profile_idx = i; self._editing_bias_profile_name = bname; prof = self.bias_profiles[bname]
|
|
|
|
|
self._editing_bias_profile_tool_weights = copy.deepcopy(prof.tool_weights); self._editing_bias_profile_category_multipliers = copy.deepcopy(prof.category_multipliers)
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
imgui.begin_child("tp_scroll", imgui.ImVec2(0, h1), True)
|
|
|
|
|
try:
|
|
|
|
|
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()
|
|
|
|
|
if self.ui_tool_filter_category != "All" and self.ui_tool_filter_category != cat_name: continue
|
|
|
|
|
if imgui.tree_node(cat_name):
|
|
|
|
|
if cat_name not in self._editing_tool_preset_categories: self._editing_tool_preset_categories[cat_name] = []
|
|
|
|
|
curr_cat_tools = self._editing_tool_preset_categories[cat_name]
|
|
|
|
|
if imgui.begin_table(f"tt_{cat_name}", 2, imgui.TableFlags_.borders_inner_v):
|
|
|
|
|
try:
|
|
|
|
|
imgui.table_setup_column("Tool", imgui.TableColumnFlags_.width_fixed, 250); imgui.table_setup_column("Ctrls", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
for tool_name in default_tools:
|
|
|
|
|
tool = next((t for t in curr_cat_tools if t.name == tool_name), None)
|
|
|
|
|
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)
|
|
|
|
|
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)
|
|
|
|
|
else: tool.approval = "auto"
|
|
|
|
|
imgui.same_line();
|
|
|
|
|
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"
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
imgui.tree_pop()
|
|
|
|
|
finally:
|
|
|
|
|
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))
|
|
|
|
|
if self._bias_list_open:
|
|
|
|
|
imgui.button("###tool_splitter", imgui.ImVec2(-1, 4))
|
|
|
|
|
if imgui.is_item_active(): self._tool_split_v = max(0.1, min(0.9, self._tool_split_v + imgui.get_io().mouse_delta.y / rem_y))
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
imgui.dummy(imgui.ImVec2(0, 4))
|
|
|
|
|
opened_bias = imgui.collapsing_header("Bias Profiles", imgui.TreeNodeFlags_.default_open)
|
|
|
|
|
if opened_bias != self._bias_list_open: self._bias_list_open = opened_bias
|
|
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
if self._bias_list_open:
|
|
|
|
|
imgui.begin_child("bias_area", imgui.ImVec2(0, h2), True)
|
|
|
|
|
try:
|
|
|
|
|
if imgui.begin_table("bias_split", 2, imgui.TableFlags_.resizable | imgui.TableFlags_.borders_inner_v):
|
|
|
|
|
try:
|
|
|
|
|
imgui.table_setup_column("BList", imgui.TableColumnFlags_.width_fixed, 150); imgui.table_setup_column("BEdit", imgui.TableColumnFlags_.width_stretch)
|
|
|
|
|
imgui.table_next_row(); imgui.table_next_column()
|
|
|
|
|
imgui.begin_child("blist_pane", imgui.ImVec2(0, 0), False)
|
|
|
|
|
try:
|
|
|
|
|
if imgui.button("New Profile", imgui.ImVec2(-1, 0)):
|
|
|
|
|
self._editing_bias_profile_name = ""; self._editing_bias_profile_tool_weights = {}
|
|
|
|
|
self._editing_bias_profile_category_multipliers = {}; self._selected_bias_profile_idx = -1
|
|
|
|
|
imgui.separator(); bnames = sorted(self.bias_profiles.keys())
|
|
|
|
|
for i, bname in enumerate(bnames):
|
|
|
|
|
if imgui.selectable(f"{bname}##b_{i}", self._selected_bias_profile_idx == i)[0]:
|
|
|
|
|
self._selected_bias_profile_idx = i; self._editing_bias_profile_name = bname; prof = self.bias_profiles[bname]
|
|
|
|
|
self._editing_bias_profile_tool_weights = copy.deepcopy(prof.tool_weights); self._editing_bias_profile_category_multipliers = copy.deepcopy(prof.category_multipliers)
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
imgui.table_next_column()
|
|
|
|
|
imgui.begin_child("bedit_pane", imgui.ImVec2(0, 0), False)
|
|
|
|
|
try:
|
|
|
|
|
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)
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
try:
|
|
|
|
|
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):
|
|
|
|
|
try:
|
|
|
|
|
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
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
imgui.tree_pop()
|
|
|
|
|
finally:
|
|
|
|
|
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))
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
try:
|
|
|
|
|
if imgui.begin_table("bcats", 2):
|
|
|
|
|
try:
|
|
|
|
|
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
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
finally:
|
|
|
|
|
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}"
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
imgui.end_child()
|
|
|
|
|
|
|
|
|
|
# --- Footer Buttons ---
|
|
|
|
|
imgui.separator()
|
|
|
|
|
@@ -1231,6 +1260,7 @@ class App:
|
|
|
|
|
imgui.same_line();
|
|
|
|
|
if not is_embedded:
|
|
|
|
|
if imgui.button("Close", imgui.ImVec2(100, 0)): self.show_tool_preset_manager_window = False
|
|
|
|
|
finally:
|
|
|
|
|
imgui.end_table()
|
|
|
|
|
finally:
|
|
|
|
|
pass
|
|
|
|
|
|