mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-01 09:49:03 +08:00
- Implemented mergeObjects function to smartly merge objects, preserving existing values and allowing for configurable overwrite options. - Added mergeModelsList and mergeProvidersList functions to handle merging of model and provider lists, respectively, with case-insensitive ID matching. - Introduced preset merge strategies for common use cases. - Created a new API route for syncing provider models, handling data import and merge operations. - Developed ModelEditForm and ProviderEditForm components for editing model and provider details, respectively, with form validation and state management. - Added UI components for labels, selects, and notifications to enhance user experience.
42 lines
1.1 KiB
TypeScript
Executable File
42 lines
1.1 KiB
TypeScript
Executable File
#!/usr/bin/env tsx
|
|
|
|
/**
|
|
* Clean up models with invalid pricing (null values)
|
|
*/
|
|
|
|
import fs from 'fs/promises'
|
|
import path from 'path'
|
|
|
|
const DATA_DIR = path.join(__dirname, '../data')
|
|
|
|
async function cleanupInvalidPricing() {
|
|
console.log('Cleaning up models with invalid pricing...\n')
|
|
|
|
const modelsPath = path.join(DATA_DIR, 'models.json')
|
|
const modelsData = JSON.parse(await fs.readFile(modelsPath, 'utf-8'))
|
|
|
|
let fixed = 0
|
|
|
|
for (const model of modelsData.models) {
|
|
if (model.pricing) {
|
|
const hasNullInput = model.pricing.input?.per_million_tokens == null
|
|
const hasNullOutput = model.pricing.output?.per_million_tokens == null
|
|
|
|
if (hasNullInput || hasNullOutput) {
|
|
console.log(`Removing invalid pricing from: ${model.id}`)
|
|
delete model.pricing
|
|
fixed++
|
|
}
|
|
}
|
|
}
|
|
|
|
if (fixed > 0) {
|
|
await fs.writeFile(modelsPath, JSON.stringify(modelsData, null, 2) + '\n', 'utf-8')
|
|
console.log(`\n✓ Fixed ${fixed} models with invalid pricing`)
|
|
} else {
|
|
console.log('✓ No invalid pricing found')
|
|
}
|
|
}
|
|
|
|
cleanupInvalidPricing().catch(console.error)
|