feat(04-02): extend prototype and matrix pending state
- add saved session and last token tracking in prototype state - add matrix load/reset pending store helpers
This commit is contained in:
parent
6923b801a3
commit
2720ee2d6e
3 changed files with 97 additions and 0 deletions
|
|
@ -31,6 +31,8 @@ class PrototypeStateStore:
|
|||
def __init__(self) -> None:
|
||||
self._users: dict[str, User] = {}
|
||||
self._settings: dict[str, dict[str, Any]] = {}
|
||||
self._saved_sessions: dict[str, list[dict[str, str]]] = {}
|
||||
self._last_tokens_used: dict[str, int] = {}
|
||||
|
||||
async def get_or_create_user(
|
||||
self,
|
||||
|
|
@ -78,3 +80,16 @@ class PrototypeStateStore:
|
|||
elif action.action == "set_safety":
|
||||
safety = settings.setdefault("safety", DEFAULT_SAFETY.copy())
|
||||
safety[action.payload["trigger"]] = action.payload.get("enabled", True)
|
||||
|
||||
async def add_saved_session(self, user_id: str, name: str) -> None:
|
||||
sessions = self._saved_sessions.setdefault(user_id, [])
|
||||
sessions.append({"name": name, "created_at": datetime.now(UTC).isoformat()})
|
||||
|
||||
async def list_saved_sessions(self, user_id: str) -> list[dict[str, str]]:
|
||||
return list(self._saved_sessions.get(user_id, []))
|
||||
|
||||
async def get_last_tokens_used(self, user_id: str) -> int:
|
||||
return self._last_tokens_used.get(user_id, 0)
|
||||
|
||||
async def set_last_tokens_used(self, user_id: str, tokens: int) -> None:
|
||||
self._last_tokens_used[user_id] = tokens
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue