ollama-cloud-usage 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -4
- package/dist/cli.js +12 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,12 +70,18 @@ Snapshots are appended to `./ollama-usage.jsonl` (one JSON object per line), or
|
|
|
70
70
|
the path in `OLLAMA_USAGE_LOG`. Each line:
|
|
71
71
|
|
|
72
72
|
```json
|
|
73
|
-
{"timestamp":"...","session":{"used_percent":3.91,"remaining_percent":96.09,"resets_at":"2026-10-27T08:00:00Z"},"weekly":{"used_percent":16.67,"remaining_percent":83.33,"resets_at":"2026-11-02T00:00:00Z"},"purchased":{"balance_usd":0},"usage":{"range":"7d","totals":{"request_count":37796,"groups":[{"model":"deepseek-v4.1-flash:1017","request_count":32964},{"model":"glm-5.3-flash","request_count":4588}]}}}
|
|
73
|
+
{"timestamp":"...","session":{"used_percent":3.91,"remaining_percent":96.09,"resets_at":"2026-10-27T08:00:00Z"},"weekly":{"used_percent":16.67,"remaining_percent":83.33,"resets_at":"2026-11-02T00:00:00Z"},"purchased":{"balance_usd":0},"usage":{"range":"7d","totals":{"request_count":37796,"groups":[{"model":"deepseek-v4.1-flash:1017","request_count":32964},{"model":"glm-5.3-flash","request_count":4588}]},"partial":{"from":"2026-10-27T00:00:00Z","request_count":2084,"groups":[{"model":"deepseek-v4.1-flash:1017","request_count":1148},{"model":"glm-5.3-flash","request_count":911}]}}}
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
`usage.totals.groups` holds
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
`usage.totals.groups` holds per-model request counts (`group_by=model`, top 10).
|
|
77
|
+
|
|
78
|
+
`usage.partial` is the current (still-growing) bucket. Because a bucket is a
|
|
79
|
+
fixed time slice, differencing two snapshots gives the new requests per model —
|
|
80
|
+
the input a cost estimator needs. `totals` is a sliding 7-day window and cannot
|
|
81
|
+
be differenced that way.
|
|
82
|
+
|
|
83
|
+
The monitor only logs these — it does not display or interpret them; cost
|
|
84
|
+
analysis can be done later from the log.
|
|
79
85
|
|
|
80
86
|
The log never contains the API key or per-request content.
|
|
81
87
|
|
package/dist/cli.js
CHANGED
|
@@ -44,9 +44,21 @@ function logQuota(options) {
|
|
|
44
44
|
if (options.balance.purchased)
|
|
45
45
|
row.purchased = options.balance.purchased;
|
|
46
46
|
if (options.usage) {
|
|
47
|
+
// The partial bucket is a fixed, growing slice, so differencing two polls
|
|
48
|
+
// gives the new requests per model — the input a cost estimator needs.
|
|
49
|
+
// `totals` is a sliding window and cannot be differenced that way.
|
|
50
|
+
let buckets = options.usage.buckets;
|
|
51
|
+
let last = buckets && buckets.length > 0 ? buckets[buckets.length - 1] : undefined;
|
|
47
52
|
row.usage = {
|
|
48
53
|
range: options.usage.range,
|
|
49
54
|
totals: options.usage.totals,
|
|
55
|
+
partial: last
|
|
56
|
+
? {
|
|
57
|
+
from: last.from,
|
|
58
|
+
request_count: last.request_count,
|
|
59
|
+
groups: last.groups || [],
|
|
60
|
+
}
|
|
61
|
+
: null,
|
|
50
62
|
};
|
|
51
63
|
}
|
|
52
64
|
fs_1.default.appendFileSync(logFile, JSON.stringify(row) + "\n");
|