feat: pricing stat.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
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"`
|
||||
}
|
||||
|
||||
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,
|
||||
OutputPricePerMillion: 2,
|
||||
}).Error
|
||||
}
|
||||
Reference in New Issue
Block a user