Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Commit 3c6209c

Browse files
authored
Implement reseting system-prompt in CLI (#710)
This also cleans up the output of the `system-prompt show` sub-command Signed-off-by: Juan Antonio Osorio <[email protected]>
1 parent 66bb8e2 commit 3c6209c

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/codegate/pipeline/cli/commands.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ def subcommands(self) -> Dict[str, Callable[[List[str]], Awaitable[str]]]:
377377
return {
378378
"set": self._set_system_prompt,
379379
"show": self._show_system_prompt,
380+
"reset": self._reset_system_prompt,
380381
}
381382

382383
async def _set_system_prompt(self, flags: Dict[str, str], args: List[str]) -> str:
@@ -421,7 +422,30 @@ async def _show_system_prompt(self, flags: Dict[str, str], args: List[str]) -> s
421422
except crud.WorkspaceDoesNotExistError:
422423
return f"Workspace `{workspace_name}` doesn't exist"
423424

424-
return f"Workspace **{workspace.name}** system prompt:\n\n{workspace.system_prompt}."
425+
sysprompt = workspace.system_prompt
426+
if not sysprompt:
427+
return f"Workspace **{workspace.name}** system prompt is unset."
428+
429+
return f"Workspace **{workspace.name}** system prompt:\n\n{sysprompt}."
430+
431+
async def _reset_system_prompt(self, flags: Dict[str, str], args: List[str]) -> str:
432+
"""
433+
Reset the system prompt of a workspace
434+
If a workspace name is not provided, the active workspace is used
435+
"""
436+
workspace_name = flags.get("-w")
437+
if not workspace_name:
438+
active_workspace = await self.workspace_crud.get_active_workspace()
439+
workspace_name = active_workspace.name
440+
441+
try:
442+
updated_worksapce = await self.workspace_crud.update_workspace_system_prompt(
443+
workspace_name, [""]
444+
)
445+
except crud.WorkspaceDoesNotExistError:
446+
return f"Workspace `{workspace_name}` doesn't exist"
447+
448+
return f"Workspace `{updated_worksapce.name}` system prompt reset."
425449

426450
@property
427451
def help(self) -> str:

0 commit comments

Comments
 (0)