fix(gui): render persona editor modal correctly and align with Persona model attributes
This commit is contained in:
64
src/gui_2.py
64
src/gui_2.py
@@ -1197,13 +1197,10 @@ class App:
|
||||
imgui.end_popup()
|
||||
|
||||
def _render_persona_editor_modal(self) -> None:
|
||||
if not self.show_persona_editor_modal:
|
||||
return
|
||||
imgui.set_next_window_size(imgui.ImVec2(400, 350), imgui.Cond_.first_use_ever)
|
||||
expanded, _ = imgui.begin("Persona Editor", self.show_persona_editor_modal)
|
||||
if not expanded:
|
||||
imgui.end()
|
||||
return
|
||||
if not self.show_persona_editor_modal: return
|
||||
imgui.open_popup("Persona Editor")
|
||||
opened, self.show_persona_editor_modal = imgui.begin_popup_modal("Persona Editor", self.show_persona_editor_modal)
|
||||
if opened:
|
||||
try:
|
||||
imgui.text("Name:")
|
||||
imgui.same_line()
|
||||
@@ -1231,28 +1228,58 @@ class App:
|
||||
imgui.text("MaxTok:")
|
||||
imgui.same_line()
|
||||
_, self._editing_persona_max_tokens = imgui.input_int("##pmaxt", self._editing_persona_max_tokens)
|
||||
|
||||
# Tool Preset
|
||||
imgui.text("Tool Preset:")
|
||||
imgui.same_line()
|
||||
preset_names = ["None"] + sorted(self.controller.tool_presets.keys())
|
||||
t_idx = preset_names.index(self._editing_persona_tool_preset_id) if hasattr(self, '_editing_persona_tool_preset_id') and self._editing_persona_tool_preset_id in preset_names else 0
|
||||
imgui.push_item_width(150)
|
||||
_, t_idx = imgui.combo("##ptoolpreset", t_idx, preset_names)
|
||||
self._editing_persona_tool_preset_id = preset_names[t_idx] if t_idx > 0 else None
|
||||
imgui.pop_item_width()
|
||||
|
||||
# Bias Profile
|
||||
imgui.text("Bias Profile:")
|
||||
imgui.same_line()
|
||||
bias_names = ["None"] + sorted(self.controller.bias_profiles.keys())
|
||||
b_idx = bias_names.index(self._editing_persona_bias_profile_id) if hasattr(self, '_editing_persona_bias_profile_id') and self._editing_persona_bias_profile_id in bias_names else 0
|
||||
imgui.push_item_width(150)
|
||||
_, b_idx = imgui.combo("##pbiasprofile", b_idx, bias_names)
|
||||
self._editing_persona_bias_profile_id = bias_names[b_idx] if b_idx > 0 else None
|
||||
imgui.pop_item_width()
|
||||
|
||||
imgui.text("Pref Models (JSON):")
|
||||
_, self._editing_persona_preferred_models = imgui.input_text("##pprefmodels", self._editing_persona_preferred_models, 256)
|
||||
|
||||
imgui.text("Prompt:")
|
||||
_, self._editing_persona_system_prompt = imgui.input_text_multiline("##pprompt", self._editing_persona_system_prompt, imgui.ImVec2(350, 50))
|
||||
if imgui.button("Save##p", imgui.ImVec2(80, 0)):
|
||||
if self._editing_persona_name.strip():
|
||||
try:
|
||||
import json
|
||||
pref_models = []
|
||||
try:
|
||||
pref_models = json.loads(self._editing_persona_preferred_models)
|
||||
if not isinstance(pref_models, list):
|
||||
pref_models = []
|
||||
except:
|
||||
pass
|
||||
persona = models.Persona(
|
||||
id=self._editing_persona_name.strip(),
|
||||
name=self._editing_persona_name.strip(),
|
||||
description=self._editing_persona_description,
|
||||
provider=self._editing_persona_provider,
|
||||
model=self._editing_persona_model,
|
||||
provider=self._editing_persona_provider or None,
|
||||
model=self._editing_persona_model or None,
|
||||
system_prompt=self._editing_persona_system_prompt,
|
||||
temperature=self._editing_persona_temperature,
|
||||
max_tokens=self._editing_persona_max_tokens,
|
||||
tool_preset_id=None,
|
||||
bias_profile_id=None,
|
||||
preferred_models=[],
|
||||
tier_assignments={}
|
||||
max_output_tokens=self._editing_persona_max_tokens,
|
||||
tool_preset=getattr(self, '_editing_persona_tool_preset_id', None),
|
||||
bias_profile=getattr(self, '_editing_persona_bias_profile_id', None),
|
||||
preferred_models=pref_models,
|
||||
)
|
||||
self.controller._cb_save_persona(persona, "project")
|
||||
self.ai_status = f"Saved: {persona.id}"
|
||||
self.ai_status = f"Saved: {persona.name}"
|
||||
self.show_persona_editor_modal = False
|
||||
imgui.close_current_popup()
|
||||
except Exception as e:
|
||||
self.ai_status = f"Error: {e}"
|
||||
else:
|
||||
@@ -1260,8 +1287,9 @@ class App:
|
||||
imgui.same_line()
|
||||
if imgui.button("Cancel##p", imgui.ImVec2(80, 0)):
|
||||
self.show_persona_editor_modal = False
|
||||
imgui.close_current_popup()
|
||||
finally:
|
||||
imgui.end()
|
||||
imgui.end_popup()
|
||||
|
||||
|
||||
def _render_projects_panel(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user