stage-6: model selection and advanced commands
/model (show/change), /restart (owner), /logs, set_session_model API, model reset on /clear. 20 new tests (161 total). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -271,6 +271,20 @@ def get_active_session(channel_id: str) -> dict | None:
|
||||
return sessions.get(channel_id)
|
||||
|
||||
|
||||
def set_session_model(channel_id: str, model: str) -> bool:
|
||||
"""Update the model for a channel's active session. Returns True if session existed."""
|
||||
if model not in VALID_MODELS:
|
||||
raise ValueError(
|
||||
f"Invalid model '{model}'. Must be one of: {', '.join(sorted(VALID_MODELS))}"
|
||||
)
|
||||
sessions = _load_sessions()
|
||||
if channel_id not in sessions:
|
||||
return False
|
||||
sessions[channel_id]["model"] = model
|
||||
_save_sessions(sessions)
|
||||
return True
|
||||
|
||||
|
||||
def list_sessions() -> dict:
|
||||
"""Return all channel→session mappings from active.json."""
|
||||
return _load_sessions()
|
||||
|
||||
Reference in New Issue
Block a user