Fix GPT-5 API compatibility and add AIUsageLog migration
- Add AIUsageLog table migration for token tracking - Fix GPT-5 temperature parameter (not supported, like o-series) - Add usesNewTokenParam() and supportsTemperature() functions - Add GPT-5+ category to model selection UI - Update model sorting to show GPT-5+ first GPT-5 and newer models use max_completion_tokens and don't support custom temperature values, similar to reasoning models. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,8 @@ import { getAIUsageStats, getCurrentMonthCost, formatCost } from '@/server/utils
|
||||
*/
|
||||
function categorizeModel(modelId: string): string {
|
||||
const id = modelId.toLowerCase()
|
||||
// GPT-5+ series (newest models)
|
||||
if (id.startsWith('gpt-5') || id.startsWith('gpt-6') || id.startsWith('gpt-7')) return 'gpt-5+'
|
||||
if (id.startsWith('gpt-4o')) return 'gpt-4o'
|
||||
if (id.startsWith('gpt-4')) return 'gpt-4'
|
||||
if (id.startsWith('gpt-3.5')) return 'gpt-3.5'
|
||||
@@ -220,11 +222,11 @@ export const settingsRouter = router({
|
||||
category: categorizeModel(model),
|
||||
}))
|
||||
|
||||
// Sort: GPT-4o first, then other GPT-4, then GPT-3.5, then reasoning models
|
||||
// Sort: GPT-5+ first, then GPT-4o, then other GPT-4, then GPT-3.5, then reasoning models
|
||||
const sorted = categorizedModels.sort((a, b) => {
|
||||
const order = ['gpt-4o', 'gpt-4', 'gpt-3.5', 'reasoning']
|
||||
const aOrder = order.findIndex(cat => a.category.startsWith(cat))
|
||||
const bOrder = order.findIndex(cat => b.category.startsWith(cat))
|
||||
const order = ['gpt-5+', 'gpt-4o', 'gpt-4', 'gpt-3.5', 'reasoning', 'other']
|
||||
const aOrder = order.findIndex(cat => a.category === cat)
|
||||
const bOrder = order.findIndex(cat => b.category === cat)
|
||||
if (aOrder !== bOrder) return aOrder - bOrder
|
||||
return a.id.localeCompare(b.id)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user