opencode-go-usage-tui 1.3.0 → 1.3.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 +19 -10
- package/README_EN.md +18 -9
- package/dist/tui.js +272 -112
- package/package.json +1 -1
- package/src/i18n.ts +39 -23
- package/src/index.tsx +988 -865
- package/src/pricing.ts +17 -3
package/src/pricing.ts
CHANGED
|
@@ -180,7 +180,8 @@ export async function fetchPricing(): Promise<PricingData> {
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
// 以限额表为准构建模型列表(限额表是权威的当前模型来源)
|
|
183
|
-
|
|
183
|
+
// 同一个 normalizeName(key) 只保留一个模型,若限额表出现分档行则合并 variants,避免重复
|
|
184
|
+
const modelMap = new Map<string, ModelPrice>()
|
|
184
185
|
for (const row of limitRows.slice(1)) {
|
|
185
186
|
if (row.length < 4) continue
|
|
186
187
|
const name = row[0]
|
|
@@ -205,7 +206,7 @@ export async function fetchPricing(): Promise<PricingData> {
|
|
|
205
206
|
const allReads = variants.map((v) => v.pricing.cachedRead).filter((v): v is number => v !== null)
|
|
206
207
|
const allWrites = variants.map((v) => v.pricing.cachedWrite).filter((v): v is number => v !== null)
|
|
207
208
|
|
|
208
|
-
|
|
209
|
+
const model: ModelPrice = {
|
|
209
210
|
id,
|
|
210
211
|
name,
|
|
211
212
|
variants,
|
|
@@ -225,8 +226,21 @@ export async function fetchPricing(): Promise<PricingData> {
|
|
|
225
226
|
sdk: endpointRow ? (endpointRow[3] || "") : "",
|
|
226
227
|
training: retentionRow ? (retentionRow[1] || "") : "",
|
|
227
228
|
retention: retentionRow ? (retentionRow[2] || "") : "",
|
|
228
|
-
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
if (modelMap.has(key)) {
|
|
232
|
+
const existing = modelMap.get(key)!
|
|
233
|
+
const merged = new Map(existing.variants.map((v) => [v.label, v]))
|
|
234
|
+
for (const v of model.variants) if (!merged.has(v.label)) merged.set(v.label, v)
|
|
235
|
+
const mv = [...merged.values()]
|
|
236
|
+
existing.variants = mv
|
|
237
|
+
if (mv.length === 1) existing.pricing = mv[0].pricing
|
|
238
|
+
modelMap.set(key, existing)
|
|
239
|
+
} else {
|
|
240
|
+
modelMap.set(key, model)
|
|
241
|
+
}
|
|
229
242
|
}
|
|
243
|
+
const models = [...modelMap.values()]
|
|
230
244
|
|
|
231
245
|
return { fetchTime: new Date().toISOString(), models }
|
|
232
246
|
}
|