34 lines
950 B
Go
34 lines
950 B
Go
package models
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type AIPricingConfig struct {
|
|
gorm.Model
|
|
Name string `gorm:"size:64;uniqueIndex" json:"name"`
|
|
Provider string `gorm:"size:64" json:"provider"`
|
|
InputPricePerMillion float64 `json:"inputPricePerMillion"`
|
|
OutputPricePerMillion float64 `json:"outputPricePerMillion"`
|
|
CacheHitPricePerMillion float64 `json:"cacheHitPricePerMillion"`
|
|
CacheMissPricePerMillion float64 `json:"cacheMissPricePerMillion"`
|
|
}
|
|
|
|
func EnsureDefaultAIPricing(db *gorm.DB) error {
|
|
var count int64
|
|
if err := db.Model(&AIPricingConfig{}).Count(&count).Error; err != nil {
|
|
return err
|
|
}
|
|
if count > 0 {
|
|
return nil
|
|
}
|
|
return db.Create(&AIPricingConfig{
|
|
Name: "deepseek-v4-flash",
|
|
Provider: "tencentmaas",
|
|
InputPricePerMillion: 1,
|
|
CacheHitPricePerMillion: 1,
|
|
CacheMissPricePerMillion: 0.02,
|
|
OutputPricePerMillion: 2,
|
|
}).Error
|
|
}
|