system prompt suspport

This commit is contained in:
2026-02-21 22:06:57 -05:00
parent 9a23941e59
commit f6c06ec381
6 changed files with 66 additions and 7 deletions

40
gui.py
View File

@@ -465,6 +465,8 @@ class App:
dpg.set_value("project_name_text", f"Active: {name}")
if dpg.does_item_exist("project_git_dir"):
dpg.set_value("project_git_dir", proj.get("project", {}).get("git_dir", ""))
if dpg.does_item_exist("project_system_prompt"):
dpg.set_value("project_system_prompt", proj.get("project", {}).get("system_prompt", ""))
def _save_active_project(self):
"""Write self.project to the active project .toml file."""
@@ -688,6 +690,8 @@ class App:
proj.setdefault("project", {})
if dpg.does_item_exist("project_git_dir"):
proj["project"]["git_dir"] = dpg.get_value("project_git_dir")
if dpg.does_item_exist("project_system_prompt"):
proj["project"]["system_prompt"] = dpg.get_value("project_system_prompt")
# Discussion
self._flush_disc_entries_to_project()
@@ -701,6 +705,8 @@ class App:
"provider": self.current_provider,
"model": self.current_model,
}
if dpg.does_item_exist("global_system_prompt"):
self.config["ai"]["system_prompt"] = dpg.get_value("global_system_prompt")
self.config["projects"] = {
"paths": self.project_paths,
"active": self.active_project_path,
@@ -970,6 +976,13 @@ class App:
user_msg = dpg.get_value("ai_input")
base_dir = dpg.get_value("files_base_dir")
global_sp = dpg.get_value("global_system_prompt") if dpg.does_item_exist("global_system_prompt") else ""
project_sp = dpg.get_value("project_system_prompt") if dpg.does_item_exist("project_system_prompt") else ""
combined_sp = []
if global_sp: combined_sp.append(global_sp.strip())
if project_sp: combined_sp.append(project_sp.strip())
ai_client.set_custom_system_prompt("\n\n".join(combined_sp))
def do_send():
try:
response = ai_client.send(self.last_md, user_msg, base_dir, self.last_file_items)
@@ -1615,6 +1628,33 @@ class App:
with dpg.child_window(tag="comms_scroll", height=-1, border=False, horizontal_scrollbar=True):
pass
# ---- System Prompts panel ----
with dpg.window(
label="System Prompts",
tag="win_system_prompts",
pos=(416, 804),
width=400,
height=300,
no_close=True,
):
dpg.add_text("Global System Prompt (all projects)")
dpg.add_input_text(
tag="global_system_prompt",
default_value=self.config.get("ai", {}).get("system_prompt", ""),
multiline=True,
width=-1,
height=100,
)
dpg.add_separator()
dpg.add_text("Project System Prompt")
dpg.add_input_text(
tag="project_system_prompt",
default_value=self.project.get("project", {}).get("system_prompt", ""),
multiline=True,
width=-1,
height=100,
)
self._build_theme_window()
def run(self):