Internal function to save usage data to disk.
(data: Dict[str, int])
| 23 | |
| 24 | |
| 25 | def _save_usage_data(data: Dict[str, int]) -> None: |
| 26 | """Internal function to save usage data to disk.""" |
| 27 | try: |
| 28 | # Ensure directory exists |
| 29 | os.makedirs(os.path.dirname(USAGE_FILE), exist_ok=True) |
| 30 | with open(USAGE_FILE, "w", encoding="utf-8") as f: |
| 31 | json.dump(data, f, indent=2) |
| 32 | except IOError as e: |
| 33 | logger.error(f"Failed to save profile usage data: {e}") |
| 34 | |
| 35 | |
| 36 | async def increment_profile_usage(profile_path: str, tokens: int) -> None: |
no test coverage detected