mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-04-25 00:51:20 +00:00
feat: personality
This commit is contained in:
parent
ebd2d83ef2
commit
371efafc46
3 changed files with 18 additions and 2 deletions
|
|
@ -319,9 +319,13 @@ def _wire_callbacks(sid: str):
|
|||
|
||||
def _make_agent(sid: str, key: str, session_id: str | None = None):
|
||||
from run_agent import AIAgent
|
||||
cfg = _load_cfg()
|
||||
system_prompt = cfg.get("agent", {}).get("system_prompt", "") or ""
|
||||
return AIAgent(
|
||||
model=_resolve_model(), quiet_mode=True, platform="tui",
|
||||
session_id=session_id or key, session_db=_get_db(), **_agent_cbs(sid),
|
||||
session_id=session_id or key, session_db=_get_db(),
|
||||
ephemeral_system_prompt=system_prompt or None,
|
||||
**_agent_cbs(sid),
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -1119,6 +1123,11 @@ def _mirror_slash_side_effects(sid: str, session: dict, command: str):
|
|||
api_mode=result.api_mode,
|
||||
)
|
||||
_emit("session.info", sid, _session_info(agent))
|
||||
elif name in ("personality", "prompt") and agent:
|
||||
cfg = _load_cfg()
|
||||
new_prompt = cfg.get("agent", {}).get("system_prompt", "") or ""
|
||||
agent.ephemeral_system_prompt = new_prompt or None
|
||||
agent._cached_system_prompt = None
|
||||
elif name == "compress" and agent:
|
||||
(getattr(agent, "compress_context", None) or getattr(agent, "context_compressor", agent).compress)()
|
||||
elif name == "reload-mcp" and agent and hasattr(agent, "reload_mcp_tools"):
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import sys
|
|||
|
||||
import cli as cli_mod
|
||||
from cli import HermesCLI
|
||||
from rich.console import Console
|
||||
|
||||
|
||||
def _run(cli: HermesCLI, command: str) -> str:
|
||||
|
|
@ -22,6 +23,12 @@ def _run(cli: HermesCLI, command: str) -> str:
|
|||
cmd = f"/{cmd}"
|
||||
|
||||
buf = io.StringIO()
|
||||
|
||||
# Rich Console captures its file handle at construction time, so
|
||||
# contextlib.redirect_stdout won't affect it. Swap the console's
|
||||
# underlying file to our buffer so self.console.print() is captured.
|
||||
cli.console = Console(file=buf, force_terminal=True, width=120)
|
||||
|
||||
old = getattr(cli_mod, "_cprint", None)
|
||||
if old is not None:
|
||||
cli_mod._cprint = lambda text: print(text)
|
||||
|
|
|
|||
|
|
@ -842,7 +842,7 @@ export function App({ gw }: { gw: GatewayClient }) {
|
|||
return true
|
||||
|
||||
default:
|
||||
rpc('slash.exec', { command: cmd.slice(1), session_id: sid })
|
||||
gw.request('slash.exec', { command: cmd.slice(1), session_id: sid })
|
||||
.then((r: any) => {
|
||||
if (r?.output) {
|
||||
sys(r.output)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue