fix: improve provider and model data accuracy in dashboard
Some checks failed
CI / Lint (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Build (push) Has been cancelled

Updated handleGetProviders to include available models and last-used timestamps. Refined Model Pricing table to strictly filter by core providers and actual usage.
This commit is contained in:
2026-03-19 13:51:46 -04:00
parent 21e5908c35
commit 0ea2a3a985
3 changed files with 43 additions and 0 deletions

View File

@@ -859,6 +859,28 @@ func (s *Server) handleGetProviders(c *gin.Context) {
}
}
// Get last used for this provider
var lastUsedTime sql.NullTime
_ = s.database.Get(&lastUsedTime, "SELECT MAX(timestamp) FROM llm_requests WHERE provider = ?", id)
var lastUsed interface{}
if lastUsedTime.Valid && !lastUsedTime.Time.IsZero() {
lastUsed = lastUsedTime.Time
}
// Get models for this provider from registry
var models []string
if s.registry != nil {
registryID := id
if id == "gemini" { registryID = "google" }
if id == "grok" { registryID = "xai" }
if pInfo, ok := s.registry.Providers[registryID]; ok {
for mID := range pInfo.Models {
models = append(models, mID)
}
}
}
result = append(result, gin.H{
"id": id,
"name": name,
@@ -868,6 +890,8 @@ func (s *Server) handleGetProviders(c *gin.Context) {
"credit_balance": balance,
"low_credit_threshold": threshold,
"billing_mode": billingMode,
"last_used": lastUsed,
"models": models,
})
}