fix(gui): render persona editor modal correctly and align with Persona model attributes
This commit is contained in:
158
src/gui_2.py
158
src/gui_2.py
@@ -1197,71 +1197,99 @@ class App:
|
|||||||
imgui.end_popup()
|
imgui.end_popup()
|
||||||
|
|
||||||
def _render_persona_editor_modal(self) -> None:
|
def _render_persona_editor_modal(self) -> None:
|
||||||
if not self.show_persona_editor_modal:
|
if not self.show_persona_editor_modal: return
|
||||||
return
|
imgui.open_popup("Persona Editor")
|
||||||
imgui.set_next_window_size(imgui.ImVec2(400, 350), imgui.Cond_.first_use_ever)
|
opened, self.show_persona_editor_modal = imgui.begin_popup_modal("Persona Editor", self.show_persona_editor_modal)
|
||||||
expanded, _ = imgui.begin("Persona Editor", self.show_persona_editor_modal)
|
if opened:
|
||||||
if not expanded:
|
try:
|
||||||
imgui.end()
|
imgui.text("Name:")
|
||||||
return
|
imgui.same_line()
|
||||||
try:
|
imgui.push_item_width(200)
|
||||||
imgui.text("Name:")
|
_, self._editing_persona_name = imgui.input_text("##pname", self._editing_persona_name, 128)
|
||||||
imgui.same_line()
|
imgui.pop_item_width()
|
||||||
imgui.push_item_width(200)
|
imgui.text("Provider:")
|
||||||
_, self._editing_persona_name = imgui.input_text("##pname", self._editing_persona_name, 128)
|
imgui.same_line()
|
||||||
imgui.pop_item_width()
|
providers = ["gemini", "anthropic", "deepseek"]
|
||||||
imgui.text("Provider:")
|
p_idx = providers.index(self._editing_persona_provider) + 1 if self._editing_persona_provider in providers else 0
|
||||||
imgui.same_line()
|
imgui.push_item_width(120)
|
||||||
providers = ["gemini", "anthropic", "deepseek"]
|
_, p_idx = imgui.combo("##pprov", p_idx, ["None"] + providers)
|
||||||
p_idx = providers.index(self._editing_persona_provider) + 1 if self._editing_persona_provider in providers else 0
|
self._editing_persona_provider = providers[p_idx - 1] if p_idx > 0 else ""
|
||||||
imgui.push_item_width(120)
|
imgui.pop_item_width()
|
||||||
_, p_idx = imgui.combo("##pprov", p_idx, ["None"] + providers)
|
imgui.text("Model:")
|
||||||
self._editing_persona_provider = providers[p_idx - 1] if p_idx > 0 else ""
|
all_models = ["gemini-2.5-flash", "gemini-3.1-pro-preview", "claude-3-5-sonnet", "deepseek-v3"]
|
||||||
imgui.pop_item_width()
|
m_idx = all_models.index(self._editing_persona_model) + 1 if self._editing_persona_model in all_models else 0
|
||||||
imgui.text("Model:")
|
imgui.push_item_width(150)
|
||||||
all_models = ["gemini-2.5-flash", "gemini-3.1-pro-preview", "claude-3-5-sonnet", "deepseek-v3"]
|
_, m_idx = imgui.combo("##pmodel", m_idx, ["None"] + all_models)
|
||||||
m_idx = all_models.index(self._editing_persona_model) + 1 if self._editing_persona_model in all_models else 0
|
self._editing_persona_model = all_models[m_idx - 1] if m_idx > 0 else ""
|
||||||
imgui.push_item_width(150)
|
imgui.pop_item_width()
|
||||||
_, m_idx = imgui.combo("##pmodel", m_idx, ["None"] + all_models)
|
imgui.text("Temp:")
|
||||||
self._editing_persona_model = all_models[m_idx - 1] if m_idx > 0 else ""
|
imgui.same_line()
|
||||||
imgui.pop_item_width()
|
_, self._editing_persona_temperature = imgui.slider_float("##ptemp", self._editing_persona_temperature, 0.0, 2.0)
|
||||||
imgui.text("Temp:")
|
imgui.text("MaxTok:")
|
||||||
imgui.same_line()
|
imgui.same_line()
|
||||||
_, self._editing_persona_temperature = imgui.slider_float("##ptemp", self._editing_persona_temperature, 0.0, 2.0)
|
_, self._editing_persona_max_tokens = imgui.input_int("##pmaxt", self._editing_persona_max_tokens)
|
||||||
imgui.text("MaxTok:")
|
|
||||||
imgui.same_line()
|
# Tool Preset
|
||||||
_, self._editing_persona_max_tokens = imgui.input_int("##pmaxt", self._editing_persona_max_tokens)
|
imgui.text("Tool Preset:")
|
||||||
imgui.text("Prompt:")
|
imgui.same_line()
|
||||||
_, self._editing_persona_system_prompt = imgui.input_text_multiline("##pprompt", self._editing_persona_system_prompt, imgui.ImVec2(350, 50))
|
preset_names = ["None"] + sorted(self.controller.tool_presets.keys())
|
||||||
if imgui.button("Save##p", imgui.ImVec2(80, 0)):
|
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
|
||||||
if self._editing_persona_name.strip():
|
imgui.push_item_width(150)
|
||||||
try:
|
_, t_idx = imgui.combo("##ptoolpreset", t_idx, preset_names)
|
||||||
persona = models.Persona(
|
self._editing_persona_tool_preset_id = preset_names[t_idx] if t_idx > 0 else None
|
||||||
id=self._editing_persona_name.strip(),
|
imgui.pop_item_width()
|
||||||
name=self._editing_persona_name.strip(),
|
|
||||||
description=self._editing_persona_description,
|
# Bias Profile
|
||||||
provider=self._editing_persona_provider,
|
imgui.text("Bias Profile:")
|
||||||
model=self._editing_persona_model,
|
imgui.same_line()
|
||||||
system_prompt=self._editing_persona_system_prompt,
|
bias_names = ["None"] + sorted(self.controller.bias_profiles.keys())
|
||||||
temperature=self._editing_persona_temperature,
|
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
|
||||||
max_tokens=self._editing_persona_max_tokens,
|
imgui.push_item_width(150)
|
||||||
tool_preset_id=None,
|
_, b_idx = imgui.combo("##pbiasprofile", b_idx, bias_names)
|
||||||
bias_profile_id=None,
|
self._editing_persona_bias_profile_id = bias_names[b_idx] if b_idx > 0 else None
|
||||||
preferred_models=[],
|
imgui.pop_item_width()
|
||||||
tier_assignments={}
|
|
||||||
)
|
imgui.text("Pref Models (JSON):")
|
||||||
self.controller._cb_save_persona(persona, "project")
|
_, self._editing_persona_preferred_models = imgui.input_text("##pprefmodels", self._editing_persona_preferred_models, 256)
|
||||||
self.ai_status = f"Saved: {persona.id}"
|
|
||||||
self.show_persona_editor_modal = False
|
imgui.text("Prompt:")
|
||||||
except Exception as e:
|
_, self._editing_persona_system_prompt = imgui.input_text_multiline("##pprompt", self._editing_persona_system_prompt, imgui.ImVec2(350, 50))
|
||||||
self.ai_status = f"Error: {e}"
|
if imgui.button("Save##p", imgui.ImVec2(80, 0)):
|
||||||
else:
|
if self._editing_persona_name.strip():
|
||||||
self.ai_status = "Name required"
|
try:
|
||||||
imgui.same_line()
|
import json
|
||||||
if imgui.button("Cancel##p", imgui.ImVec2(80, 0)):
|
pref_models = []
|
||||||
self.show_persona_editor_modal = False
|
try:
|
||||||
finally:
|
pref_models = json.loads(self._editing_persona_preferred_models)
|
||||||
imgui.end()
|
if not isinstance(pref_models, list):
|
||||||
|
pref_models = []
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
persona = models.Persona(
|
||||||
|
name=self._editing_persona_name.strip(),
|
||||||
|
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_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.name}"
|
||||||
|
self.show_persona_editor_modal = False
|
||||||
|
imgui.close_current_popup()
|
||||||
|
except Exception as e:
|
||||||
|
self.ai_status = f"Error: {e}"
|
||||||
|
else:
|
||||||
|
self.ai_status = "Name required"
|
||||||
|
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_popup()
|
||||||
|
|
||||||
|
|
||||||
def _render_projects_panel(self) -> None:
|
def _render_projects_panel(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user