fix: no skipping from free model price.
Some checks failed
CI / Unit tests (push) Has been cancelled
CI / commit_lint (push) Has been cancelled

This commit is contained in:
hjjjj 2026-03-20 17:50:11 +08:00
parent 5730b2a798
commit f67f4b8caf

View File

@ -684,14 +684,15 @@ func SyncZenmuxRatios(c *gin.Context) {
completionRatioMap = make(map[string]float64)
}
updated, skipped := 0, 0
updated := 0
for _, item := range catalog {
if item.InputPrice <= 0 {
skipped++
continue
// Only overwrite existing non-zero ratio if new price is also non-zero.
// This preserves manually configured ratios for models where Zenmux reports price=0
// (e.g. per-image billing models whose token price is not tracked here).
if item.InputPrice > 0 || modelRatioMap[item.Id] == 0 {
modelRatioMap[item.Id] = item.InputPrice
}
modelRatioMap[item.Id] = item.InputPrice
if item.OutputPrice > 0 {
if item.InputPrice > 0 && item.OutputPrice > 0 {
completionRatioMap[item.Id] = item.OutputPrice / item.InputPrice
}
updated++
@ -727,7 +728,7 @@ func SyncZenmuxRatios(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{
"success": true,
"message": fmt.Sprintf("synced ratios for %d models (%d skipped — no pricing)", updated, skipped),
"message": fmt.Sprintf("synced ratios for %d models", updated),
})
}