feat: store and display backend + host metadata on chat messages
Each assistant message in the session JSON now carries: backend, backend_label, host (platform.node()) These fields are shown as model tags in the UI — on live responses and when loading session history. Session log entries (sessions/YYYY-MM-DD.md) include the backend label and host in the turn header. The local (OpenAI-compat) backend strips non-standard fields before sending messages to the API so extra fields don't leak upstream. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,13 @@ from config import settings
|
||||
from persona import persona_path
|
||||
|
||||
|
||||
def log_turn(session_id: str, user_msg: str, assistant_msg: str) -> None:
|
||||
def log_turn(
|
||||
session_id: str,
|
||||
user_msg: str,
|
||||
assistant_msg: str,
|
||||
backend_label: str = "",
|
||||
host: str = "",
|
||||
) -> None:
|
||||
today = datetime.now().strftime("%Y-%m-%d")
|
||||
sessions_dir = persona_path() / "sessions"
|
||||
sessions_dir.mkdir(exist_ok=True)
|
||||
@@ -12,11 +18,14 @@ def log_turn(session_id: str, user_msg: str, assistant_msg: str) -> None:
|
||||
timestamp = datetime.now().strftime("%H:%M")
|
||||
is_new = not log_file.exists()
|
||||
|
||||
meta_parts = [p for p in [backend_label, host] if p]
|
||||
meta = f" · {' / '.join(meta_parts)}" if meta_parts else ""
|
||||
|
||||
with open(log_file, "a") as f:
|
||||
if is_new:
|
||||
f.write(f"# Session Log — {today}\n")
|
||||
f.write(
|
||||
f"\n### [{timestamp}] `{session_id}`\n"
|
||||
f"\n### [{timestamp}] `{session_id}`{meta}\n"
|
||||
f"**{settings.user_name}:** {user_msg}\n\n"
|
||||
f"**{settings.agent_name}:** {assistant_msg}\n"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user