MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / record

Method record

uncommon_route/spend_control.py:207–216  ·  view source on GitHub ↗
(self, amount: float, model: str | None = None, action: str | None = None)

Source from the content-addressed store, hash-verified

205 return CheckResult(allowed=True)
206
207 def record(self, amount: float, model: str | None = None, action: str | None = None) -> None:
208 if amount < 0:
209 raise ValueError("Amount must be non-negative")
210 self._history.append(SpendRecord(
211 timestamp=self._now(), amount=amount, model=model, action=action,
212 ))
213 self._session_spent += amount
214 self._session_calls += 1
215 self._cleanup()
216 self._save()
217
218 def get_spending(self, window: Literal["hourly", "daily", "session"]) -> float:
219 now = self._now()

Calls 4

_cleanupMethod · 0.95
_saveMethod · 0.95
SpendRecordClass · 0.85
appendMethod · 0.45