@shi-yangyang/dsh-token-dashboard 0.2.0 → 0.2.1
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.en.md +6 -5
- package/README.md +6 -5
- package/client/client.js +1185 -954
- package/lib/shared/builtin-prices.d.ts +10 -1
- package/lib/shared/builtin-prices.generated.d.ts +1 -1
- package/lib/shared/builtin-prices.generated.js +479 -95
- package/lib/shared/builtin-prices.js +25 -1
- package/lib/shared/pricing.d.ts +2 -0
- package/lib/shared/pricing.js +14 -1
- package/package.json +1 -1
|
@@ -87,11 +87,35 @@ for (const entry of BUILTIN_PRICES) {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
for (const entry of GENERATED_PRICES) {
|
|
90
|
-
|
|
90
|
+
const candidates = modelKeyCandidates(entry.id);
|
|
91
|
+
// The hand-maintained official DeepSeek rates win for the whole family,
|
|
92
|
+
// including a vendor-prefixed exact id from the OpenRouter snapshot.
|
|
93
|
+
if (candidates.some(candidate => BUILTIN_BY_KEY.has(candidate)))
|
|
94
|
+
continue;
|
|
95
|
+
for (const candidate of candidates) {
|
|
91
96
|
if (!BUILTIN_BY_KEY.has(candidate))
|
|
92
97
|
BUILTIN_BY_KEY.set(candidate, entry.price);
|
|
93
98
|
}
|
|
94
99
|
}
|
|
100
|
+
/** All built-in prices, including the hand-maintained DeepSeek families. */
|
|
101
|
+
export function builtinPriceRows() {
|
|
102
|
+
const rows = BUILTIN_PRICES.map(entry => ({
|
|
103
|
+
key: entry.id,
|
|
104
|
+
provider: 'DeepSeek official',
|
|
105
|
+
model: entry.id,
|
|
106
|
+
price: entry.price,
|
|
107
|
+
}));
|
|
108
|
+
for (const entry of GENERATED_PRICES) {
|
|
109
|
+
const slash = entry.id.indexOf('/');
|
|
110
|
+
rows.push({
|
|
111
|
+
key: entry.id,
|
|
112
|
+
provider: slash === -1 ? 'OpenRouter' : entry.id.slice(0, slash).replace(/^~/, ''),
|
|
113
|
+
model: entry.id,
|
|
114
|
+
price: entry.price,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return rows.sort((left, right) => left.key.localeCompare(right.key));
|
|
118
|
+
}
|
|
95
119
|
/** Resolve a built-in list price by model id, ignoring provider/date variants. */
|
|
96
120
|
export function builtinPriceFor(model) {
|
|
97
121
|
for (const key of modelKeyCandidates(model)) {
|
package/lib/shared/pricing.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export declare function serializeOnlinePricing(state: OnlinePricingState): strin
|
|
|
58
58
|
export declare function isPriceConfigured(price: ModelPrice | undefined): price is ModelPrice;
|
|
59
59
|
/** Estimated cost for one model, or null when no usable price exists. */
|
|
60
60
|
export declare function costOf(usage: Pick<TokenBuckets, 'uncachedInputTokens' | 'cacheReadTokens' | 'cacheWriteTokens' | 'outputTokens'>, price: ModelPrice | undefined): number | null;
|
|
61
|
+
/** Resolve a price by exact model key, then by normalized model-name candidates. */
|
|
62
|
+
export declare function priceForModel(table: PricingTable, key: string, model: string): ModelPrice | undefined;
|
|
61
63
|
/** Build the per-model estimate and currency totals for the current range. */
|
|
62
64
|
export declare function estimateCost(models: ModelUsage[], table: PricingTable): CostEstimate;
|
|
63
65
|
/** Parse a persisted pricing table defensively; unknown or invalid rows are dropped. */
|
package/lib/shared/pricing.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* a rate. All amounts are labelled "Estimated Cost".
|
|
5
5
|
*/
|
|
6
6
|
import { builtinPriceFor } from './builtin-prices.js';
|
|
7
|
+
import { modelKeyCandidates } from './builtin-prices.js';
|
|
7
8
|
/** Suggested currencies; the editor accepts any short code as well. */
|
|
8
9
|
export const SUGGESTED_CURRENCIES = ['CNY', 'USD', 'EUR', 'JPY'];
|
|
9
10
|
/** Resolve user overrides over online prices over built-in list prices. */
|
|
@@ -80,6 +81,18 @@ export function costOf(usage, price) {
|
|
|
80
81
|
+ usage.outputTokens * price.output) / 1_000_000;
|
|
81
82
|
return Number.isFinite(amount) ? amount : null;
|
|
82
83
|
}
|
|
84
|
+
/** Resolve a price by exact model key, then by normalized model-name candidates. */
|
|
85
|
+
export function priceForModel(table, key, model) {
|
|
86
|
+
const direct = table[key];
|
|
87
|
+
if (direct !== undefined)
|
|
88
|
+
return direct;
|
|
89
|
+
for (const candidate of modelKeyCandidates(model)) {
|
|
90
|
+
const price = table[candidate];
|
|
91
|
+
if (price !== undefined)
|
|
92
|
+
return price;
|
|
93
|
+
}
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
83
96
|
/** Build the per-model estimate and currency totals for the current range. */
|
|
84
97
|
export function estimateCost(models, table) {
|
|
85
98
|
const rows = [];
|
|
@@ -87,7 +100,7 @@ export function estimateCost(models, table) {
|
|
|
87
100
|
let pricedModels = 0;
|
|
88
101
|
let unpricedModels = 0;
|
|
89
102
|
for (const model of models) {
|
|
90
|
-
const price = table
|
|
103
|
+
const price = priceForModel(table, model.key, model.model);
|
|
91
104
|
const configured = isPriceConfigured(price);
|
|
92
105
|
const amount = configured ? costOf(model, price) : null;
|
|
93
106
|
if (configured && amount !== null) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shi-yangyang/dsh-token-dashboard",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Global Token usage analytics for every DeepSeek Harness session: totals, trends, models, sessions, and optional cost estimates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"deepseek",
|