the coolest token pot ever
0

Configure Feed

Select the types of activity you want to include in your feed.

feat: fully fetch base models

Kieran Klukas (May 24, 2026, 6:17 PM EDT) e804834d cdbe2c25

+60 -17
+60 -17
server/internal/pool/models_refresher.go
··· 120 120 121 121 now := time.Now().Unix() 122 122 upserted := 0 123 + 124 + // Build v1 index for enrichment. 125 + v1ByID := map[string]v1Model{} 123 126 for _, m := range v1Models { 124 - bm := baseByID[m.ID] 125 - label := m.DisplayName 126 - if label == "" { 127 - label = bm.Label 128 - } 127 + v1ByID[m.ID] = m 128 + } 129 + 130 + // Primary source: /base-models (includes models not in /v1, e.g. off-plan). 131 + for _, bm := range baseModels { 132 + vm := v1ByID[bm.ID] 133 + 134 + label := bm.Label 129 135 desc := bm.Description 130 136 tier := bm.Tier 131 - if tier == "" { 132 - tier = m.Tier 133 - } 134 137 135 - // Convert USD price per million tokens to micros per million. 136 138 var inputMicros, outputMicros int64 137 139 if bm.InputPricePerMil > 0 { 138 140 inputMicros = int64(math.Round(bm.InputPricePerMil * 1_000_000)) ··· 141 143 outputMicros = int64(math.Round(*bm.OutputPricePerMil * 1_000_000)) 142 144 } 143 145 144 - isChat := int64(1) // everything in /v1/models is chat-capable 145 - if bm.IsChatModel == false && bm.ID != "" { 146 - isChat = 0 146 + isChat := int64(0) 147 + if bm.IsChatModel { 148 + isChat = 1 147 149 } 148 150 149 - rawJSON, _ := json.Marshal(m) 151 + // Enrich with /v1 data where available. 152 + var ctxWindow, maxOutput int64 153 + var rawJSON []byte 154 + if vm.ID != "" { 155 + if vm.DisplayName != "" { 156 + label = vm.DisplayName 157 + } 158 + if vm.Tier != "" { 159 + tier = vm.Tier 160 + } 161 + ctxWindow = int64(vm.MaxInputTokens) 162 + maxOutput = int64(vm.MaxTokens) 163 + rawJSON, _ = json.Marshal(vm) 164 + } else { 165 + ctxWindow = bm.ContextWindow 166 + rawJSON, _ = json.Marshal(bm) 167 + } 150 168 151 169 _ = r.q.UpsertModelCatalog(ctx, store.UpsertModelCatalogParams{ 152 - ID: m.ID, 170 + ID: bm.ID, 153 171 Label: label, 154 172 Description: desc, 155 - ContextWindow: nullInt64(int64(m.MaxInputTokens)), 156 - MaxOutputTokens: nullInt64(int64(m.MaxTokens)), 173 + ContextWindow: nullInt64(ctxWindow), 174 + MaxOutputTokens: nullInt64(maxOutput), 157 175 IsChat: isChat, 158 176 Tier: nullString(tier), 159 177 InputPricePerMillionMicros: nullInt64(inputMicros), ··· 164 182 upserted++ 165 183 } 166 184 167 - r.log.Info("models refresher: catalog updated", "models", upserted) 185 + // Also upsert any models that only exist in /v1 (unlikely but don't lose them). 186 + for _, vm := range v1Models { 187 + if _, ok := baseByID[vm.ID]; ok { 188 + continue // already handled above 189 + } 190 + label := vm.DisplayName 191 + var inputMicros, outputMicros int64 192 + isChat := int64(1) 193 + rawJSON, _ := json.Marshal(vm) 194 + 195 + _ = r.q.UpsertModelCatalog(ctx, store.UpsertModelCatalogParams{ 196 + ID: vm.ID, 197 + Label: label, 198 + ContextWindow: nullInt64(int64(vm.MaxInputTokens)), 199 + MaxOutputTokens: nullInt64(int64(vm.MaxTokens)), 200 + IsChat: isChat, 201 + Tier: nullString(vm.Tier), 202 + InputPricePerMillionMicros: nullInt64(inputMicros), 203 + OutputPricePerMillionMicros: nullInt64(outputMicros), 204 + RawJson: string(rawJSON), 205 + RefreshedAt: now, 206 + }) 207 + upserted++ 208 + } 209 + 210 + r.log.Info("models refresher: catalog updated", "base_models", len(baseModels), "v1_models", len(v1Models), "upserted", upserted) 168 211 } 169 212 170 213 // pickKey returns a decrypted pioneer API key from the pool, or "" if none available.